THPDFFontDecoder Record

Holds the resolved decode tables and width metrics for a single 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

FieldPurpose
FontKeyResource key such as /F1 naming the font, kept to hand for diagnostics
SubtypeFont dictionary subtype: Type0, Type1, TrueType, CIDFontType2 and friends
StrategiesSet of fallback strategies filled in successfully
ToUnicodeMapParsed /ToUnicode CMap with bfchar and bfrange entries, carrying the highest priority
EncodingMapParsed /Encoding stream or named CMap
PredefinedEncodingPredefined encoding name such as WinAnsiEncoding
CIDToGIDIdentityTrue when the CIDToGIDMap is Identity and no explicit table is required
CIDToGIDsBinary CIDToGIDMap stream expanded to one Word per CID
CIDToUnicodeCID to Unicode table from the cid2code.txt fallback
GlyphNameUnicode256-entry glyph name to Unicode table used by /Differences recovery
GIDToUnicodeEmbedded cmap reversed from glyph ID to Unicode
WidthsSimple-font /Widths advances in 1/1000 em, indexed by code minus FirstChar
FirstCharFirst supported char code of the Widths array
LastCharLast supported char code of the Widths array
CIDWidthsCID width ranges from the CIDFont /W array
CIDDefaultWidthDefault CID advance from /DW
CIDVertWidthsVertical /W2 metrics stored as [w1y v1x v1y] triples per CID or range
CIDVertDefaultAdvanceDefault vertical displacement from /DW2 w1y, -1000 by default
CIDVertDefaultOriginYDefault vertical origin from /DW2 v1y, 880 by default
VerticalWritingTrue when WMode 1 metrics gate the resolver's vertical branch
AscentFont ascent read from the font descriptor metrics
DescentFont descent read from the font descriptor metrics
HasVerticalMetricsTrue when vertical metrics were found for the font
CodeUnitBytesBytes per char code, answered to the content interpreter on the font's behalf
OKTrue when at least one decode strategy can be used

Usage notes

Related APIs