PdfFont
A resolved PDF font.
The font knows how to:
decode show-text bytes into unicode (text extraction).
layoutBytes walk show-text bytes into a sequence of TextGlyphs, each tagged with its outline (if any), advance, and decoded text.
Simple fonts (Type 1, TrueType, Type1C, Type 3) consume one byte per glyph. Type 0 composite fonts (CIDFontType0/2 under a Type 0 parent) consume one code unit per glyph: typically 2 bytes via the Identity-H CMap, sometimes variable. layoutBytes is the unified iterator everything downstream uses.
Embedded outlines are pulled from whichever of these is present:
/FontFileโ Type 1 (PostScript)/FontFile2โ TrueType/FontFile3โ CFF (Type1C or CIDFontType0C)
Order tried matches what real fonts actually carry; falls back to the host system font (via baseFont) when no outlines are available.
Properties
Platform-neutral substitute-font descriptor, derived from baseFont, the font descriptor's Serif flag and a CIDFont's character collection, for canvases that render non-embedded fonts through a host typeface. Centralises the family/style choice the render backends used to each make inline.
True when the glyphs of this font have outlines: from the program the file embeds, or, for a standard 14 font that the file does not embed, from the metric-compatible program that KitePDF bundles (ISO 32000-1, 9.6.2.2). False when a canvas has to stand a host typeface in for the font, as fontSpec describes.
True when this font writes top to bottom: a Type 0 font whose CMap has writing mode 1, such as Identity-V (ISO 32000-1, 9.7.4.3 and 9.7.5.3). Each glyph then moves the pen down by its verticalMetrics, not right by its width.
An estimate of the memory that this font holds, in bytes: twice its embedded program, for the program and the outlines parsed from it, and a fixed share for its encoding tables. A cache of fonts stays within its budget by this number. A bundled standard 14 program is shared by every document, so it does not count.
The units per em of this font's outlines, or null without embedded outlines. A TrueType font reports its own. CFF and Type 1 outlines are already mapped through the program's FontMatrix into glyph space, where an em is 1000 units (ISO 32000-1, 9.2.4), so they report 1000.
Functions
True iff the underlying embedded font has its own advance metrics.
Invoke action once per glyph with its advance width (1/1000 em) and word-space flag, WITHOUT resolving any glyph outline or allocating a TextGlyph list. The fast path for advance/measurement (text positioning, width sums) where glyph shapes aren't needed. The renderer's advance calculation, text extraction, and redaction layout all use it.
Glyph id for a single byte code in a simple font. Returns 0 for composite fonts (their glyph IDs come from CIDs, not byte codes).
Per-byte outline lookup. Kept for backward compat with callers that pre-date the layoutBytes iterator; layoutBytes is the right path for any new code so composite Type 0 fonts work correctly.
The vertical metrics of each glyph in bytes, in the order layoutBytes lays them out, or null when this font is not isVertical. ISO 32000-1, 9.7.4.3 reads them from the CIDFont's /W2 array, else from /DW2, whose default is [880 -1000].
Width (1/1000 em) for a single byte code in a simple font. Composite use layoutBytes.