THPDFFontDecoder 记录

保存一个已加载 PDF 字体的解析结果:解码表和宽度度量,由字体解码回退链构建

声明

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;

单元

HPDFTextExtraction

字段

字段用途
FontKey命名字体的资源键,例如 /F1,保留用于诊断
Subtype字体字典子类型:Type0、Type1、TrueType、CIDFontType2 等
Strategies成功填充的回退策略集合
ToUnicodeMap解析出的 /ToUnicode CMap,含 bfchar 和 bfrange 条目,优先级最高
EncodingMap解析出的 /Encoding 流或命名 CMap
PredefinedEncoding预定义编码名称,例如 WinAnsiEncoding
CIDToGIDIdentityCIDToGIDMap 为 Identity 且不需要显式表时为 True
CIDToGIDs二进制 CIDToGIDMap 流,已展开为每个 CID 一个 Word
CIDToUnicode来自 cid2code.txt 回退的 CID 到 Unicode 表
GlyphNameUnicode供 /Differences 恢复使用的 256 项字形名到 Unicode 表
GIDToUnicode嵌入 cmap 反转得到的字形 ID 到 Unicode 映射
Widths简单字体的 /Widths 步进,单位为 1/1000 em,以码值减去 FirstChar 作为索引
FirstCharWidths 数组支持的第一个字符码
LastCharWidths 数组支持的最后一个字符码
CIDWidths来自 CIDFont /W 数组的 CID 宽度区间
CIDDefaultWidth来自 /DW 的默认 CID 前进量
CIDVertWidths垂直 /W2 度量,按 CID 或区间存储为 [w1y v1x v1y] 三元组
CIDVertDefaultAdvance来自 /DW2 w1y 的默认垂直位移,默认为 -1000
CIDVertDefaultOriginY来自 /DW2 v1y 的默认垂直原点,默认为 880
VerticalWritingWMode 1 度量决定解析器走垂直分支时为 True
Ascent从字体描述符度量读取的字体上伸值
Descent从字体描述符度量读取的字体下伸值
HasVerticalMetrics找到该字体的垂直度量时为 True
CodeUnitBytes每个字符码的字节数,向内容解释器报告该字体的这一取值
OK至少有一个解码策略可用时为 True

使用说明

相关 API