设置元数据| node.js的API解决方案

如何将字体元数据设置为“名称”表?

aspose.font for node.js提供了不仅可以读取字体元数据的功能,而且在某些情况下对其进行了修改(有关特定用例的文档咨询文档)。这是使用 asposefontsetInfo函数个性化`名称表的方法:

  1. nameId 参数允许您指定要在 name 表中更改的具体信息。这可以是任何内容,从字体系列名称到版权信息。
  2. platformIdplatformSpecificId(可选)和 languageId(可选)参数有助于定义更改的上下文。这些参数确保修改的信息针对相应的平台和语言。

重要考虑因素:

修改现有记录时,只要 platformIDplatformSpecificIDlanguageIDnameID 的组合与现有记录匹配,Aspose.Font 就会更新字符串数据而不添加新记录。

请务必参考 Aspose.Font for Node.js 文档,以获取有关可用枚举及其对应值的详细说明。

设置字体元数据的示例

  1. 定义参数并运行 AsposeFontSetInfo 函数。
  1. 接下来,如果json.errorcode为0,则可以获取结果数据。如果“ JSON.ERRORCODE”参数不等于0,因此您的文件中会有错误,则有关此类错误的信息将包含在json.erortext中。
  2. 结果JSON对象包含“ FILENAMERESULT”字段,并在存储器文件系统中保存字体的文件名。使用下载文件函数获取它。
 1    const AsposeFont = require('asposefontnodejs');
 2    const font_file = "./fonts/Lora-Regular.ttf";
 3
 4    AsposeFont().then(AsposeFontModule => {
 5        //AsposeSetInfo - set metadata info into font
 6        const nameId = AsposeFontModule.TtfNameTableNameId.Description;
 7        const platformId = AsposeFontModule.TtfNameTablePlatformId.Microsoft;
 8        const platformSpecificId = AsposeFontModule.TtfNameTableMSPlatformSpecificId.Unicode_BMP_UCS2.value;
 9        const langID = Module.TtfNameTableMSLanguageId.English_United_States.value;
10        const text = "Updated description";
11    
12        const json = AsposeFontSetInfo(font_file, nameId, platformId, platformSpecificId, langID, text);
13        console.log("AsposeFontSetInfo => %O",  json.errorCode == 0 ? json.fileNameResult : json.errorText);
14});

如何获取解决方案?

如果您有兴趣获取库,请转到 aspose.font for Node.js产品页面。在这里,您会发现解决方案给您的更多机会。您可以从那里下载免费试用版或在那里购买产品。

如果您剩下任何麻烦或问题,请随时在 aspose.font.product family 免费支持论坛的一节中发布它们,我们的支持团队将为您清除所有内容。

Have any questions about Aspose.Font?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.