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:
- The
nameId
parameter allows you to specify the exact piece of information you want to change within thename
table. This could be anything from the font family name to copyright information. - The
platformId
,platformSpecificId
(optional), andlanguageId
(optional) parameters help define the context of your changes. These parameters ensure the modified information is targeted for the appropriate platform and language.
platformId
- indicates the operating system affected by the change (refer to TtfNameTablePlatformId enumerations).platformSpecificId
(Optional) may be needed for some platforms.languageId
(Optional) - used to spesify the language for the modified string data.
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
- Define parameters and run the AsposeFontSetInfo function.
- Use enum
TtfNameTableNameId and
TtfNameTablePlatformIdfor
nameId
andplatformId
, TtfNameTableMacPlatformSpecificId, TtfNameTableMSPlatformSpecificId, or TtfNameTableUnicodePlatformSpecificId forplatformSpecificId
, and TtfNameTableMacLanguageId, or TtfNameTableMSLanguageId forlanguageId
parameters.
- Next, if the
json.errorCode
is 0, then you can get result data. 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
. - 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.