folkertdev/elm-cff - version: 1.0.0

for more information visit the package's GitHub page

Package contains the following modules:

Compact Font Format in Elm

This package is a parser for Compact Font Format (CFF) data. CFF is commonly used in opentype fonts. In opentype fonts, it is one of the ways to actually store the glyph data (the shape of the characters, as bezier curves).

Type 2 Charstrings

The actual drawing instructions (moveto, lineto, curveto) are stored as type 2 charstrings.

Such a charstring is really a stream of bytes (8-bit chunks) which can be parsed into the drawing instructions. The bytes are read and pushed onto a stack until an operator byte is encountered. The arguments and the operator can then be combined into an Operation.

Because the first 32 (0..31) numbers are used for operators, arguments cannot contain bytes representing those numbers. Therefore, the arguments are shifted out of that range. There are also ways to encode numbers that need more than 8 bits.

A large complication is that the decoding process is not linear:

A further minor annoyance in an elm context is that there are no separators. We only know the size (in bytes) of a charstring and its starting location. Thus we need to keep track carefully of the number of bytes that we've decoded to not step out of bounds.

Resources

Specs

Implementations