THPDFFontDecoder Record
Holds the resolved decode tables and width metrics for one loaded PDF font, built by the font decode fallback chain
Declaration
THPDFFontDecoder= record
FontKey: AnsiString; // resource key (e.g. /F1) for diagnostics
Subtype: AnsiString; // Type0, Type1, TrueType, CIDFontType2
Strategies: THPDFFontStrategies; // which fallbacks are populated
ToUnicodeMap: THPDFCMapParseResult;
EncodingMap: THPDFCMapParseResult; // /Encoding stream or named CMap
PredefinedEncoding: AnsiString; // 'WinAnsiEncoding' etc
CIDToGIDIdentity: boolean;
CIDToGIDs: array of Word; // binary CIDToGIDMap stream
CIDToUnicode: THPDFCIDToUnicodeTable; // cid2code.txt fallback
GlyphNameUnicode: array[0.. 255] of Cardinal;
GIDToUnicode: THPDFUnicodeByGID;
// v2.505.0 simple-font /Widths (PDF 1.7 9.6.3 Table 111). Index =
// (code - FirstChar); values are 1/1000-em glyph advances. Empty when
// the font has no /Widths array (the interpreter falls back to 0.5*fs)
Widths: array of Double;
FirstChar: Integer;
LastChar: Integer;
CIDWidths: THPDFCIDWidthRanges;
CIDDefaultWidth: Double;
// Vertical (WMode 1) counterparts from the descendant CIDFont /W2 and
// /DW2 (ISO 32000-1 9.7.4.3). Each /W2 metric is a [w1y v1x v1y]
// triple: w1y is the displacement along the writing axis, v1x/v1y the
// position vector from the glyph's horizontal origin to its vertical
// origin. A range entry (cFirst cLast w1y v1x v1y) stores one triple;
// a list entry (c [w1y v1x v1y ...]) stores one triple per CID from
// FirstCID to LastCID. VerticalWriting gates the resolver's vertical
// branch
CIDVertWidths: THPDFCIDWidthRanges;
CIDVertDefaultAdvance: Double; // /DW2 w1y (second entry); default -1000
CIDVertDefaultOriginY: Double; // /DW2 v1y (first entry); default 880
VerticalWriting: boolean;
Ascent: Double;
Descent: Double;
HasVerticalMetrics: boolean;
CodeUnitBytes: Integer; // bytes per char code
OK: boolean;
end;
Unit
HPDFTextExtraction
Fields
| Field | Purpose |
|---|---|
FontKey | Resource key such as /F1 naming the font, kept for diagnostics |
Subtype | Font dictionary subtype: Type0, Type1, TrueType, CIDFontType2 and friends |
Strategies | Set of fallback strategies that were populated successfully |
ToUnicodeMap | Parsed /ToUnicode CMap with bfchar and bfrange entries, highest priority |
EncodingMap | Parsed /Encoding stream or named CMap |
PredefinedEncoding | Predefined encoding name such as WinAnsiEncoding |
CIDToGIDIdentity | True when the CIDToGIDMap is Identity and no explicit table is needed |
CIDToGIDs | Binary CIDToGIDMap stream expanded to one Word per CID |
CIDToUnicode | CID to Unicode table from the cid2code.txt fallback |
GlyphNameUnicode | 256-entry glyph name to Unicode table used by /Differences recovery |
GIDToUnicode | Embedded cmap reversed from glyph ID to Unicode |
Widths | Simple-font /Widths advances in 1/1000 em, indexed by code minus FirstChar |
FirstChar | First supported char code of the Widths array |
LastChar | Last supported char code of the Widths array |
CIDWidths | CID width ranges from the CIDFont /W array |
CIDDefaultWidth | Default CID advance from /DW |
CIDVertWidths | Vertical /W2 metrics stored as [w1y v1x v1y] triples per CID or range |
CIDVertDefaultAdvance | Default vertical displacement from /DW2 w1y, -1000 by default |
CIDVertDefaultOriginY | Default vertical origin from /DW2 v1y, 880 by default |
VerticalWriting | True when WMode 1 metrics gate the resolver's vertical branch |
Ascent | Font ascent read from the font descriptor metrics |
Descent | Font descent read from the font descriptor metrics |
HasVerticalMetrics | True when vertical metrics were found for the font |
CodeUnitBytes | Bytes per char code, answered to the content interpreter for the font |
OK | True when at least one decode strategy is usable |
Usage notes
- Build with
HPDFBuildFontDecoder; the plain record keeps a page worth of fonts cheap with no heap allocation of its own HPDFDecodeCharCodewalks the strategies in priority order and returns 0 on miss; missing streams degrade silently to the next strategy- Call
HPDFCloneFontDecoderwhen a decoder must outlive the cache that produced it, since the dynamic arrays are shared by reference