AsposefontConvertTosvg | node.js的API解决方案
Contents
[
Hide
Show
]如何使用node.js使用aspose.font将字体转换为SVG格式?
- 调用 AsposeFontConvertTosvg函数。
- 在
json.filenameresult
中设置了结果名称文件。 - 接下来,如果“ JSON.ERRORCODE”为0,则可以获取结果文件的链接。如果“ JSON.ERRORCODE”参数不等于0,因此您的文件中会有错误,则有关此类错误的信息将包含在
json.erortext
中。
以下是将字体从ttf
转换为woff
格式的示例。
1 const AsposeFont = require('asposefontnodejs');
2
3 const font_file = "./fonts/Lora-Regular.ttf";
4
5 console.log('Aspose.Font for Node.js via C++ example');
6
7 AsposeFont().then(AsposeFontModule => {
8 //call AsposeFontConvertToSVG to convert font
9 const json = AsposeFontModule.AsposeFontConvertToSVG(font_file,AsposeFontModule.FontType.TTF);
10 console.log("AsposeFontConvertToSVG : %O", json.errorCode == 0 ? font_file + ' => ' + json.fileNameResult : json.errorText);
11 });
*将路径/您/font.ttf替换为字体文件的实际路径。