TrueTypeFont

Pure-Kotlin TrueType / OpenType font parser.

Reads the subset of SFNT tables needed to render glyphs: head, maxp, hhea, hmtx, cmap, loca, glyf. Composite glyphs are supported with argument transforms; emoji-style colour tables (COLR/CPAL/sbix/CBDT) are not yet handled — those are extras layered on top of plain outline data, so without them you still get monochrome shapes.

The font keeps the original byte buffer alive; lookups are lazy and cached via Cache. That keeps memory flat — most PDFs reference 50–200 glyphs from a font containing thousands.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
val head: Head
Link copied to clipboard
val hhea: Hhea
Link copied to clipboard
val hmtx: Hmtx
Link copied to clipboard
val maxp: Maxp
Link copied to clipboard
Link copied to clipboard

SFNT version: 0x00010000 (TrueType outlines) or "OTTO" / "true" / "typ1".

Functions

Link copied to clipboard
fun advanceWidth(glyphId: Int): Int

Glyph advance width in font design units.

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

Convert a unicode codepoint to a glyph index, or 0 (.notdef) if unmapped.

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

Get the outline for glyphId, or null if the glyph slot is empty (zero-length).

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

Outline as a PdfPath, cached — the GlyphOutline → PdfPath conversion is built once per glyph, not on every draw.