Skip to content
cff

cff

Mojo module 🡭

cff

CFF (Compact Font Format) outlines, for OpenType-CFF (OTTO) fonts: the CFF table’s INDEX and DICT structures, and a Type 2 charstring interpreter that turns a glyph’s program into a RawGlyphOutline of cubic contours. Layout and operator semantics follow Adobe Technical Notes #5176 (CFF) and #5177 (Type 2 charstrings).

Scope:

  • Type 2 charstrings only. CFF version 1 with Type 2 programs, which is every OpenType-CFF font; a CharstringType of 1 raises. CFF2 (variable CFF) is a different table and is not read.
  • CID-keyed fonts (ROS in the Top DICT) are supported: each glyph’s Private DICT and local subroutines come from FDArray through FDSelect (formats 0 and 3).
  • Every path operator, the four flex operators, subroutine calls with the size-dependent bias, and the deprecated endchar accent composition (seac) via the charset and Standard Encoding. Hint operators are counted so hintmask bytes are skipped and otherwise ignored, as glyf hinting is. The arithmetic operators a Type 1 conversion can leave behind (abs, add, sub, div, neg, mul, sqrt, drop, dup, exch, put, get) are honored; the rest raise.
  • Coordinates round to whole font units. Charstrings can carry fractions (16.16 numbers, div); RawGlyphOutline holds integer units, so a point rounds to its nearest unit, 1/1000 em in nearly every CFF font. FontMatrix is not read: head’s unitsPerEm is taken as the charstring unit, which holds for every font whose matrix is the default 1/1000.