folkertdev / elm-cff / CompactFontFormat

Decoding Compact Font Format (CFF) tables.


type alias CompactFont =
{ version : { major : Basics.Int
, minor : Basics.Int }
, name : String
, topLevelDict : Dict.Top.Top
, strings : Strings
, subroutines : Charstring.Subroutines
, glyphs : Glyphs 
}

A single compact font

A single font is much easier to work with than a fontset, so it is the main abstraction.

parse : Bytes -> Maybe CompactFont

Parse Bytes into a CFF font.

This function is defined in terms of decodeCompactFontSet and picks the first font in the font set. In most cases, there is only one font in the font set.

Utility functions

characterToName : CompactFont -> (Char -> Basics.Int) -> Char -> String

Find the name of a character in this font

Lowlevel helpers


type alias CompactFontSet =
{ version : { major : Basics.Int
, minor : Basics.Int }
, names : Array String
, tops : Array Dict.Top.Top
, strings : Array String
, subroutines : Charstring.Subroutines 
}

A compact font set

This is the raw decoded data. This means little safety and convenience, but maximum flexibility.

pickFont : Bytes -> CompactFontSet -> Basics.Int -> Maybe CompactFont

Pick a font from a fontset

decodeCompactFont : Bytes -> Bytes.Decode.Decoder CompactFont

The CFF table decoder

decodeCompactFontSet : Bytes.Decode.Decoder CompactFontSet

The CFF table decoder