TrueType format glyf table

Janic's picture

Hi
I am trying to create software to look at TrueType fonts but I can not understand all things in the spec for glyf table perhaps because my English is no so good. Is there any where I can get help?

thank you

Theunis de Jong's picture

This Apple documentation shows the basics, in quite short sentences ;-)

Do you want to render the font data yourself as outlines? That's really hard. If you don't want to get involved into extremely low level programming, you can always use the FreeType libraries to load and rasterize (= convert from math outlines to a bitmapped image) fonts. FreeType can create a monochrome or grayscale image of any character, so all you have to do is write a function to put it up onto your display.

Janic's picture

Thank you Theunis
I do need to get the glyph data to display. FreeType is not for me as glyphs can only be got from cmap. I need to get all glyphs even if no cmap entry.
I am stuck on glyf table 'flags'. How can I calculate the size of flag array?

Janic

Theunis de Jong's picture

Ah -- okay. The Microsoft page is a little less vague on this subject.

Apparently, the number of flags should be equal to the number of points in one glyph. However, Bit 3 specifies a "repeat" of the current flag value, and the number of repeats is in the next byte in the same array. So if you have 10 points defining the glyph, its flags may be

0: some flags for pt #0
1: some flags for pt #1 + "repeat" bit set
2: a literal value "8"
3: some flags for pt #9

.. so the table only has 4 bytes but defines flags for all 10 points.

At least, that's what it sounds like. It's not really clear from this page what the difference is in "number of contours" and "number of points" -- the number of contours is specifically declared in the first table, and the number of points could be the same.

Janic's picture

Theunis
Thank you for your help. I think I understand now.

Janic

Syndicate content Syndicate content