THPDFFontDecoder Record
保存單一已載入 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 |
CIDToGIDIdentity | CIDToGIDMap 為 Identity、不需要明確表格時為 True |
CIDToGIDs | 展開為每個 CID 一個 Word 的二進位 CIDToGIDMap 串流 |
CIDToUnicode | 來自 cid2code.txt 後備的 CID 對 Unicode 表 |
GlyphNameUnicode | 256 項的字形名稱對 Unicode 表,供 /Differences 復原使用 |
GIDToUnicode | 由內嵌 cmap 反轉而成的字形 ID 對 Unicode 表 |
Widths | 簡單字型 /Widths 的前進量(1/1000 em),以字元碼減 FirstChar 索引 |
FirstChar | Widths 陣列支援的第一個字元碼 |
LastChar | Widths 陣列支援的最後一個字元碼 |
CIDWidths | 來自 CIDFont /W 陣列的 CID 寬度範圍 |
CIDDefaultWidth | /DW 的預設 CID 前進量 |
CIDVertWidths | 直排 /W2 量測,每個 CID 或範圍存成 [w1y v1x v1y] 三元組 |
CIDVertDefaultAdvance | /DW2 w1y 的預設垂直位移,預設 -1000 |
CIDVertDefaultOriginY | /DW2 v1y 的預設垂直原點,預設 880 |
VerticalWriting | 當 WMode 1 量測讓解析器走直排分支時為 True |
Ascent | 從字型描述器量測讀到的字型 ascent |
Descent | 從字型描述器量測讀到的字型 descent |
HasVerticalMetrics | 找到此字型的直排量測時為 True |
CodeUnitBytes | 每個字元碼的位元組數,針對此字型回答內容解譯器 |
OK | 至少一個解碼策略可用時為 True |
使用說明
- 用
HPDFBuildFontDecoder建構;單純記錄讓一整頁的字型都很省成本,自身不做任何堆積配置 HPDFDecodeCharCode按優先順序走訪各策略,未命中時傳回 0;缺少串流時默默降級到下一個策略- 當解碼器必須活得比產生它的快取更久時,請呼叫
HPDFCloneFontDecoder,因為動態陣列是以參照方式共用的