Extracting glyph-path information from ttf files
Asked Answered
B

3

12

I'm trying to figure out a way to extract the information encoded in ttf files. namely: The char-to-glyph table and the individual glyph path data.

Does anyone have a good reference explaining the ttf file structure, or some other solution?

Keep in mind that I'm not interested in any libraries that can do it for me either (unless they are open source and I can see how they are doing it). The "master" goal is to implement it in Javascript.

Thanks!

Beestings answered 5/6, 2010 at 17:7 Comment(1)
This is quite tricky. Check out my similar Question #2957941 the python library is a good source of info.Grenier
F
5

Take a look at OpenType.js at http://opentype.js.org/

opentype.js provides you with raw access to the glyphs so you can modify them as you please.

One can inspect all the tables in an OpenType and TrueType font using Font Inspector, and enumerate all the glyphs using Glyph Inspector

Fouquet answered 31/5, 2016 at 3:41 Comment(0)
A
3

This toolkit has an utility called ttf2svg, it is open source written in java. http://xmlgraphics.apache.org/batik/

You can try to extract the ttf parsing logic and implement it as you want.

In a past situation I used this utility to generate a svg file and use it in a web page targeting ipad users (@fontface css feature).

Anthesis answered 7/1, 2011 at 17:7 Comment(0)
D
3

OpenType.js is perfect in a javascript environment, browser or Node.js (I contributed to the lib). Fast & easy to use. Just keep in mind that the implementation is not complete, if you need something that is not yet implemented you can open an issue and we will help you if we can!

For a more complete tool, fontTools will be more powerful in command line (& complete parsing/writing) https://github.com/behdad/fonttools/

If you do ttx myfont.ttf it will generate an xml file (myfont.ttx) with all infos, you can modify the infos and do ttx myfont.ttx and it will generate a font based on it!

By the way I did an awesome list for typography recently with a lot of resources concerning ttf / otf: https://github.com/Jolg42/awesome-typography
There are a lot of librairies in different languages from javascript to C 😉

Dilator answered 4/7, 2016 at 15:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.