AsposeFontConvertToWOFF2 | API Solution for Node.js
Contents
[
Hide
Show
]How to convert fonts into WOFF2 format using Aspose.Font for Node.js?
- Call AsposeFontConvertToWOFF2 function.
- The resulting name file is set, in
json.fileNameResult
. - Next, if the
json.errorCode
is 0, then you can get links to result files. If thejson.errorCode
parameter is not equal to 0 and, accordingly, there will be an error in your file, then information about such an error will be contained in thejson.errorText
.
Below is the sample which converts CFF
font to WOFF2
format.
1 const AsposeFont = require('asposefontnodejs');
2
3 const font_file = "./fonts/12380_C0_0.cff";
4
5 console.log('Aspose.Font for Node.js via C++ example');
6
7 AsposeFont().then(AsposeFontModule => {
8 //call AsposeFontConvertToWOFF2 to convert font
9 const json = AsposeFontModule.AsposeFontConvertToWOFF2(font_file,AsposeFontModule.FontType.CFF);
10 console.log("AsposeFontConvertToWOFF2 : %O", json.errorCode == 0 ? font_file + ' => ' + json.fileNameResult : json.errorText);
11 });
*Replace path/to/your/font.cff with the actual path to your font file.