Setting Metadata | API Solution for Node.js

How to set the font metadata into name table?

Aspose.Font for Node.js offers the capability to not just read font metadata, but also modify it in some cases (consult the documentation for specific use cases). Here’s how to personalize the name table using the AsposeFontSetInfo function:

  1. The nameId parameter allows you to specify the exact piece of information you want to change within the name table. This could be anything from the font family name to copyright information.
  2. The platformId, platformSpecificId (optional), and languageId (optional) parameters help define the context of your changes. These parameters ensure the modified information is targeted for the appropriate platform and language.

Important Considerations:

When modifying existing records, Aspose.Font will update the string data without adding a new record, as long as the combination of platformID, platformSpecificID, languageID, and nameID matches an existing one.

Always refer to the Aspose.Font for Node.js documentation for a detailed explanation of available enumerations and their corresponding values.

Examples of setting font metadata

  1. Define parameters and run the AsposeFontSetInfo function.
  1. Next, if the json.errorCode is 0, then you can get result data. If the json.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 the json.errorText.
  2. Resulting json object contains fileNameResult field with file name of saved font in memory file system. Use DownloadFile function to get it.
 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});

How to get the solution?

If you are interested in getting the library, go to Aspose.Font for Node.js product page. There you will find more opportunities that the solution gives you. You can download a free trial from or buy the product there.

If you have any troubles or questions left, feel free to post them at the Aspose.Font.Product Family section of the Free Support Forum and within a few hours our support team will clear everything up for you.

Have any questions about Aspose.Font?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.