folkertdev/elm-cff/1.0.0

CompactFontFormat

Decoding Compact Font Format (CFF) tables.

type alias CompactFont =
{ version :
{ major : Int
, minor : Int
}
, name : String
, topLevelDict : Top
, strings : Strings
, subroutines : 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.

  • version: font version
  • name: font name
  • tops: top-level dictionary
  • strings: glyph names
  • subroutines: global subroutines
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 -> Int) -> Char -> String

Find the name of a character in this font

Lowlevel helpers

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

A compact font set

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

  • version: font set version
  • name: font names
  • tops: top-level dictionaries
  • strings: glyph names of all fonts
  • subroutines: global subroutines
pickFont : Bytes -> CompactFontSet -> Int -> Maybe CompactFont

Pick a font from a fontset

decodeCompactFont : Bytes -> Decoder CompactFont

The CFF table decoder

decodeCompactFontSet : Decoder CompactFontSet

The CFF table decoder