THPDFFontDecoder レコード
フォントデコードフォールバックチェーンが構築した、ロード済み PDF フォント 1 個分の確定済みデコードテーブルと幅メトリクスを保持します
宣言
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 | bfchar と bfrange エントリを含む解析済み /ToUnicode CMap。最優先の戦略です |
EncodingMap | 解析済みの /Encoding ストリームまたは名前付き CMap |
PredefinedEncoding | WinAnsiEncoding などの定義済みエンコーディング名 |
CIDToGIDIdentity | CIDToGIDMap が Identity で、明示的なテーブルが不要な場合に True |
CIDToGIDs | バイナリの CIDToGIDMap ストリームを CID ごとに 1 Word へ展開したもの |
CIDToUnicode | cid2code.txt フォールバックによる CID から Unicode へのテーブル |
GlyphNameUnicode | /Differences リカバリで使われる、256 項目のグリフ名から Unicode へのテーブル |
GIDToUnicode | 埋め込み cmap をグリフ ID から Unicode へ逆引きしたもの |
Widths | 単純フォントの /Widths アドバンス(1/1000 em 単位)。code から FirstChar を引いた値でインデックスします |
FirstChar | Widths 配列がサポートする最初の文字コード |
LastChar | Widths 配列がサポートする最後の文字コード |
CIDWidths | CIDFont の /W 配列による CID 幅範囲 |
CIDDefaultWidth | /DW による既定の CID アドバンス |
CIDVertWidths | 縦書き /W2 メトリクス。CID または範囲ごとに [w1y v1x v1y] の 3 つ組で保存されます |
CIDVertDefaultAdvance | /DW2 w1y による既定の縦方向変位。既定値は -1000 |
CIDVertDefaultOriginY | /DW2 v1y による既定の縦書き原点。既定値は 880 |
VerticalWriting | WMode 1 のメトリクスがリゾルバの縦書き分岐を制御する場合に True |
Ascent | フォントディスクリプタのメトリクスから読んだフォントのアセント |
Descent | フォントディスクリプタのメトリクスから読んだフォントのディセント |
HasVerticalMetrics | フォントの縦書きメトリクスが見つかった場合に True |
CodeUnitBytes | 文字コードあたりのバイト数。そのフォントについてコンテンツインタプリタへ答えます |
OK | 少なくとも 1 つのデコード戦略が使える場合に True |
使用上の注意
- 構築は
HPDFBuildFontDecoderで行います。単純なレコードなので、1 ページ分のフォントを自前のヒープ確保なしで安価に保持できます HPDFDecodeCharCodeは戦略を優先度順にたどり、見つからなければ 0 を返します。欠けているストリームは黙って次の戦略へ縮退します- デコーダが生成元のキャッシュより長く生きる必要があるなら
HPDFCloneFontDecoderを呼びます。動的配列は参照で共有されます