I want to check the contents of the woff2 file.

Asked 2 years ago, Updated 2 years ago, 100 views

I would like to see what kind of data is in the woff2 file, so I would like to display the contents.

To be honest, I think font files are in the form of characters (code point column) and corresponding vector image data, so I think it is possible to parse them as hash structures in the form of code point column > image data (binary?).

What tools (preferably command-line tools) do you have for checking the contents of woff2 files?

font

2022-09-30 18:07

1 Answers

For data specifications for WOFF2 files, please refer to the WOFF2 site.

https://www.w3.org/TR/WOFF2/ #FileStructure

"Just to check the contents, for example, when I searched ""WOFF2parser"", I found the following npm package."

https://www.npmjs.com/package/woff2-parser

Usage:

varfs=require('fs');
var parser=require('woff2-parser');

fs.readFile('font.woff2', function(err, contents){
    if(err)throwerr;
    parser(contents).then(function(result){
        console.log(result);
    });
});

Output:

{
    ...
    "name": {
        "format": 0,
        "nameRecords": {
            "English": {
                "fontFamily": "Source Sans Pro",
                "fontSubFamily": "Regular",
                "uniqueFontId": "1.050; ADBE; SourceSansPro-Regular; ADOBE",
                "fullName": "Source Sans Pro",
                "version": "Version 1.050; PS Version 1.000; hotconv 1.0.70; makeotf.lib 2.5.5900",
                "postscriptName": "SourceSansPro-Regular",
                "licenseUrl": "http://www.adobe.com/type/legal.html"
            }
        }
    },
    ...
}


2022-09-30 18:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.