The Encoding maps character codes to glyph identifiers
Note: CFF is seldomly used on its own. For instance in OpenType fonts, there is a separate character map (
cmap) table that does the encoding. Therefore, the code in this module is untested. If you have a font file actually uses the CFF encodings that you can share, please open an issue on the repository.
Decode and encoding given the encoding format
The offset value is (a)bused to indicate the encoding format.
When the offset is 0 or 1 the encoding is not encoded at all.
The
Encodingmaps a character code to a glyph identifier.The character code can be found using
Char.toCode : Char -> Int. The glyph identifier is used as an index into the array of charstrings. It can also be used to get a character's name from theCharset.A pseudo-code example:
Note: In most cases the CFF encoding is not used. For instance, OpenType fonts define their own encoding in the
cmaptable. In those cases, the encoding is still present in the CFF (it often defaults to0, the standard encoding) but using it will give wrong results.