CffFont

class CffFont

CFF (Compact Font Format, Adobe Tech Note 5176) parser.

Used by PDF /FontFile3 for /Subtype /Type1C (CFF Type 1) and /Subtype /CIDFontType0C (CFF CIDFont). About half the embedded fonts in modern PDFs land here rather than as TrueType (which uses /FontFile2).

Coverage:

  • Header + Name INDEX + Top DICT + String INDEX + Global/Local Subrs.

  • CharStrings INDEX with Type 2 charstring → io.github.yuroyami.kitepdf.render.PdfPath conversion (see CharstringInterpreter).

  • Charsets format 0/1/2 → glyph-name lookup.

  • Encodings format 0/1 — for non-CIDFonts only (byte → SID → glyph name → GID).

  • CID-keyed fonts via FDSelect/FDArray (format 0 and 3).

Not yet handled: hint operators are skipped (we don't rasterize, so hints are ignored); flex operators are approximated as cubic Béziers; the Encoding /Differences override comes from the PDF layer (PdfFont).

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun glyphIdForCodePoint(codePoint: Int): Int

Glyph id for a Unicode codepoint — uses Adobe Glyph List → name → gid.

Link copied to clipboard

Glyph id for a PostScript glyph name; -1 if unknown.

Link copied to clipboard
fun outline(glyphId: Int): PdfPath?

Returns the outline of glyphId, or null if it's empty / unparseable. Decoded outlines are cached: a glyph drawn N times runs the Type 2 charstring interpreter once, not N times.