简体   繁体   中英

Getting the Glyph Name from a TTF or OTF font file

Hi anyone know how to get the Glyph Name from a TTF or OFT font file from C#, I'm willing to parse the file directly to get them if necessary? I found this post here Access opentype glyph names from WPF but it got no answer.

PS I have created the font myself and am creating an program to create a CSS (LESS or SASS) file to use the Glyphs I have made easily in web pages like Bootstrap or FontAwesome :)

In TrueType-based fonts (.TTF files), you can try parsing the 'post' table . It's fairly easy to figure out. But , only format 2.0 explicitly stores glyph names. If the post table is format 3.0, there are no glyph names stored (there are a couple of other formats defined, but fonts using them are very, very rare). In that case, your only option is to back-track using Unicode values from the 'cmap'...there are some standard references for Unicode-to-glyph names that may be useful.

For CFF-based fonts (.OTF files), glyph names are stored inside of the 'CFF ' table . That's a bit trickier to parse, but if you're only looking for the glyph name references it shouldn't be too difficult to figure out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM