Getting Metadata | API Solution for Node.js
How to read the font metadata from name
table?
Aspose.Font for Node.js lets unlock the hidden information within fonts. Here’s how to access the treasures stored in the TrueType or OpenType name
table:
Use the AsposeFontGetInfo function. This function serves as your key to unlocking the font metadata.
Each piece of information within the
name
table is represented by a specific record. Aspose.Font provides enumerations to help you identify these record values. The function itself will even return the names of these enumerations for clarity.To precisely access the data you need, you’ll use several parameters:
nameId
- specifies the specific type of information you’re looking for, like font family name or copyright notice (enumeration values provided by TtfNameTableNameId).platformId
- indicates the operating system the information is intended for (enumeration values from TtfNameTablePlatformId).platformSpecificId
(Optional) - For some platforms like Macintosh, this might be used for further refinement within the platform (enumeration values from TtfNameTableMacPlatformSpecificId, TtfNameTableMSPlatformSpecificId, or TtfNameTableUnicodePlatformSpecificId).languageId
(Optional) - can be used to specify the language for the retrieved information (enumeration values from TtfNameTableMacLanguageId or TtfNameTableMSLanguageId).
Examples of getting metadata
- Run the AsposeFontGetInfo function.
- In case the
json.errorCode
is 0, you can get the result data. When thejson.errorCode
parameter is not equal to 0 and, accordingly, you will receive an error in your file, then information about such an error will be contained in thejson.errorText
. - The resulting json object contains
records
array. Each record contains fieldsNameId
,PlatformId
,PlatformSpecificId
,LanguageId
,Info
with information fromname
table of font.
1 const AsposeFont = require('asposefontnodejs');
2
3 const font_file = "./fonts/12380_C0_0.cff";
4
5 console.log('Aspose.Font for Node.js via C++ example');
6
7 AsposeFont().then(AsposeFontModule => {
8
9 //AsposeFontGetInfo - get metadata information
10 const json = AsposeFontModule.AsposeFontGetInfo(font_file);
11 console.log("AsposeFontGetInfo => %O", json.errorCode == 0 ? json.records.reduce((ret, a) => ret +
12 "\nNameId : " + a.NameId
13 + "; PlatformId : " + a.PlatformId
14 + "; PlatformSpecificId : " + a.PlatformSpecificId
15 + "; LanguageId : " + a.LanguageId
16 + "; Info : " + a.Info,"") : json.errorText);
17
18 },
19 reason => {console.log(`The unknown error has occurred: ${reason}`);}
20 );
How to get the solution?
To get the Solution, go to Aspose.Font for Node.js product page. It will give you more information about the benefits. 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.
Also, check our Font Metadata cross-platform application to understand the functionality completely and the way API can be used for creating your own app.