How get symbols of glyphs in CFF font

562 views Asked by At

I am parsing a CFF file. I get table with glyphs, whick looks like GC4G38GFCGD7G70G4BGEAG39GFDG4CGEBGFEG72G4DGEC... with names. I have offsets to each glyph and have offsets to CharStringINDEX. I have to associate glyphs manes with symbols. What do I have to do? All offsets don't explain where is the symbol.

1

There are 1 answers

0
Mike 'Pomax' Kamermans On

It depends on what kind of encoding the CFF relies on: does it follow any of the predefined charset/encodings, or is it a free charset/encoding CFF block? (which type it is is recorded in the TOP DICT structure)

If the first, the glyph names are simply defined by Adobe's charset/encoding specifications and not stored in the font itself. If you're writing a parser, you'll need to code up those predefined encodings with their associated glyph names. If a font follows one of these, it must contain every character in the set, in predefined glyph ordering (so a CFF following encoding X will always have a glyph named by the 23rd name string in glyph position 23).

If the second, the names for each glyph are stored in the String block, like every other string in a CFF (but offset by 390, because there are that many documentation-specified strings that apply to all CFF and thus do not need to be stored explicitly in the CFF data). To find the glyph's name, you use the Charset structure, which tells you which string ID belongs to which glyph. You then look in the String INDEX to find the offset that id will be at, and then you grab the string from the String data block on that offset.

I wrote http://pomax.github.io/CFF-glyphlet-fonts specifically for the purposes of explaining the CFF layout, so you'll probably want to give that a look-over.