AsposefontConvertTowoff | Node.js

如何使用node.js使用aspose.font将字体转换为woff格式?

  1. 调用 AsposeFontConvertTowoff函数。
  2. json.filenameresult中设置了结果名称文件。
  3. 接下来,如果json.errorcode为0,则获取链接以结果文件。如果“ JSON.ERRORCODE”参数不等于0,因此您的文件中会有错误,则有关此类错误的信息将包含在json.erortext中。

以下是将“ OTF”字体转换为woff格式的示例。

 1    const AsposeFont = require('asposefontnodejs');
 2
 3    const font_file = "./fonts/Montserrat-Regular.eot";
 4
 5    console.log('Aspose.Font for Node.js via C++ example');
 6
 7    AsposeFont().then(AsposeFontModule => {
 8        //call AsposeFontConvertToWOFF to convert font
 9        const json = AsposeFontModule.AsposeFontConvertToWOFF(font_file,AsposeFontModule.FontType.OTF);
10        console.log("AsposeFontConvertToWOFF : %O",  json.errorCode == 0 ? font_file + ' => ' + json.fileNameResult : json.errorText);
11    });

*将 path/to/your/font.eot 替换为字体文件的实际路径。

Have any questions about Aspose.Font?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.