Package-level declarations

Types

Link copied to clipboard
class CffFont

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

Link copied to clipboard

Subsets a CFF font program (the outlines inside an OpenType .otf) down to the glyphs a document uses, and re-emits it as a CID-keyed CFF.

Link copied to clipboard
class CMap

CMap parser for PDF /ToUnicode streams (ISO 32000-1 §9.10.3, Adobe Tech Note 5014).

Link copied to clipboard
data class Contour(val points: List<GlyphPoint>)

One contour = sequence of points around a closed loop.

Link copied to clipboard
object Encodings

Character encoding tables ported from MuPDF (source/fitz/encodings.h, AGPL-3.0). Each table maps a 1-byte code (0..255) to either a unicode codepoint (Int, 0 for undefined) or a PostScript glyph name (String?, null for undefined).

Link copied to clipboard

Broad typeface family a non-embedded font substitutes into.

Link copied to clipboard
data class FontSpec(val family: FontFamily, val bold: Boolean, val italic: Boolean, val name: String = "")

Platform-neutral descriptor for picking a substitute system font when a document font ships no embedded outlines (e.g. the PDF Standard-14, or a CSS font with no @font-face file). Render backends map family + bold + italic to a host typeface. No PDF (or other format) types cross the canvas seam, so every document handler (PDF, EPUB, ...) feeds the same FontSpec.

Link copied to clipboard
data class GlyphBbox(val xMin: Int, val yMin: Int, val xMax: Int, val yMax: Int)
Link copied to clipboard
object GlyphList

Adobe Glyph List → Unicode mapping, ported from MuPDF (scripts/glyphlist.txt). Maps PostScript glyph names (e.g. "Adieresis", "fi") to unicode codepoints.

Link copied to clipboard
data class GlyphOutline(val contours: List<Contour>, val bbox: GlyphBbox)

Parsed glyph outline. TrueType outlines are sequences of contours, where each contour is points with on/off-curve flags. Off-curve points are quadratic Bézier control points; consecutive off-curve points imply an implied on-curve point at their midpoint.

Link copied to clipboard
data class GlyphPoint(val x: Int, val y: Int, val onCurve: Boolean)

A single glyph point in font design units.

Link copied to clipboard
data class Head(val flags: Int, val unitsPerEm: Int, val xMin: Int, val yMin: Int, val xMax: Int, val yMax: Int, val indexToLocFormat: Int)
Link copied to clipboard
data class Hhea(val ascent: Int, val descent: Int, val lineGap: Int, val numberOfHMetrics: Int)
Link copied to clipboard
class Hmtx(widths: IntArray)
Link copied to clipboard
data class Maxp(val numGlyphs: Int)
Link copied to clipboard

The substitution half of OpenType shaping (GSUB), scoped to the two lookup types that carry the highest-value features for reflowable text:

Link copied to clipboard

Horizontal kerning for an SFNT font, from either the legacy kern table (format 0) or OpenType GPOS pair adjustment (lookup type 2, the kern feature). Returns the x-advance adjustment between two glyphs in font design units. Callers normalise to 1/1000 em like every other advance.

Link copied to clipboard

GPOS mark-to-base attachment (lookup type 4): the positioning offset that places a combining mark's anchor onto its base glyph's anchor (Arabic harakat, Hebrew points, Latin/Vietnamese diacritics). The offset is returned in font design units (base anchor − mark anchor); the caller applies it to the mark glyph's origin without touching the pen advance (marks are zero-advance).

Link copied to clipboard
class PdfFont

A resolved PDF font.

Link copied to clipboard

Standard 14 base font widths, ported from the URW++ AFM files MuPDF ships. Metric-compatible with Adobe Helvetica / Times / Courier / Symbol / ZapfDingbats.

Link copied to clipboard
data class Table(val tag: String, val offset: Int, val length: Int)

SFNT table location in the byte buffer. Public so TtfCMap can take one as a parameter.

Link copied to clipboard
data class TextGlyph(val byteOffset: Int, val byteCount: Int, val gid: Int, val text: String, val advanceWidth: Double, val outline: KitePath?, val isWordSpace: Boolean, val xOffset: Double = 0.0, val yOffset: Double = 0.0)

One glyph laid out from a Tj / TJ show-text byte string.

Link copied to clipboard

Pure-Kotlin TrueType / OpenType font parser.

Link copied to clipboard

Produces a subset TrueType font containing only the glyphs a document uses (plus their composite-glyph dependencies and .notdef).

Link copied to clipboard
class TtfCMap

TrueType / OpenType cmap table: character-code → glyph-index lookup.

Link copied to clipboard
Link copied to clipboard
class TtfReader(val bytes: ByteArray)

Big-endian binary reader for SFNT / TrueType / OpenType tables.