CFF and OpenType Font Subsetting Functions

PDF 篩選器支援

 

傳回頂部  EnableFontSubsetting  目錄

這些 unit-level functions 會暴露 HotPDF embedded font pipeline 使用的公開 CFF、OpenType-CFF 與 sfnt font-inspection surface。HotPDF 也隨附可重複使用的 Type 1 PFB 與 CFF parser units,供需要較低階 font inspection 的呼叫端使用

 

Delphi 語法

function HPDFSubsetCFF(const CFFBytes: TBytes; const KeepGlyph: array of Boolean): TBytes;

function HPDFSfntIsOTF(const Data: TBytes): Boolean;

function HPDFOTFFindCFFTable(const Data: TBytes; out TableOff: Cardinal; out TableLen: Cardinal): Boolean;

function HPDFSubsetOTFContainer(const OTFBytes: TBytes; const KeepGlyph: array of Boolean): TBytes;

function HPDFExtractTTFPostScriptName(const Data: TBytes): AnsiString;

 

說明

function HPDFSubsetOTFContainer(const OTFBytes: TBytes; const KeepGlyph: array of Boolean): TBytes;

function HPDFExtractTTFPostScriptName(const Data: TBytes): AnsiString;

 

Description

HPDFSubsetCFF rewrites a CFF font payload in place, preserving glyph IDs and replacing unused CharStrings and subroutines with minimal stubs. This is the helper for callers that already extracted a CFF table from a font container

 

HPDFSfntIsOTF 會偵測 version 為 OTTO 的 sfnt container。HPDFOTFFindCFFTable 會定位內嵌的 CFF table。HPDFSubsetOTFContainer 會合併這些步驟,將內嵌 CFF table 子集化,並傳回保留原始 sfnt table layout 的 OTF container。HPDFExtractTTFPostScriptName 會從 sfnt VVAR, and MVAR metrics, removes variable tables, and returns a checksum-correct static sfnt

 

HPDFSubsetCFF2Font performs the same default-coordinate instancing while replacing unused glyph programs with empty CharStrings. It preserves glyph IDs, multi-FD dictionaries, private hint data, and font matrices

 

HPDFIsTrueTypeVariableFont detects an sfnt containing fvar, glyf, and loca. HPDFInstantiateTrueTypeVariableFont maps selected axes through avar, evaluates gvar tuples and IUP interpolation, updates simple and composite outlines plus phantom-point metrics, applies HVAR, VVAR, and MVAR where applicable, removes variation tables, and returns a checksum-correct static sfnt

 

HPDFSfntIsOTF detects an sfnt container whose version is OTTO. HPDFOTFFindCFFTable locates the embedded 'CFF ' table. HPDFSubsetOTFContainer subsets embedded CFF or CFF2 data and returns an OTF container with valid sfnt checksums. HPDFExtractTTFPostScriptName reads name ID 6 from the sfnt name table 讀取 name ID 6,並在存在時傳回 PostScript font name

 

subsetter 會同時識別 name-keyed CFF(單一 Private DICT、單一 Local Subr INDEX)與 CID-keyed CFF(Top DICT ROS operator、多個 sub-font Private DICT 的 FDArray、FDSelect glyph-to-FD map、per-FD Local Subr INDEXes)。CID 支援涵蓋 CJK / Indic / Arabic OpenType-CFF fonts;closure scan 會追蹤每個保留 CharString 的 FD context,因此 per-FD Local Subr INDEXes 可獨立子集化

 

較低階的 CFF integer decoders、FDArray / FDSelect parsers 與 subroutine scanners 都是此公開 helper surface 後方的實作細節

 

Type 1 and CFF parser units

HPDFType1Core、HPDFType1Glyphs、HPDFType1CFFHandler 與 HPDFType1PFBHandler 提供可重複使用的 byte-array readers、Type 1 glyph-outline command extraction、CFF Header / INDEX / dictionary / charset / encoding parsing,以及 Type 1 PFB metadata 與 glyph lookup helpers。HPDFType1CB 提供 C++Builder-friendly parser entry point。這些 units 已包含在 Delphi 與 C++Builder package projects 中,因此應用程式可檢查 Type 1 PFB 與 CFF data,而不必重新實作 binary parsersSyntheticBase inheritance across a FontSet for Top and Private DICT values, CharStrings, charset, Encoding, and Local Subrs while rejecting invalid indices, cycles, and excessive depth. HPDFType1CB provides a C++Builder-friendly parser entry point. The units are included in the Delphi and C++Builder package projects so applications can inspect Type 1 PFB and CFF data without reimplementing the binary parsers

 

請參閱: EnableFontSubsetting, FontEmbedding, PDF 篩選器支援

Type 2 堆疊運算與子常式安全

原生字形轉譯器實作標準的 Type 2 布林、算術、條件、暫存陣列與堆疊運算,包括 put、get、ifelse、random、dup、exch、index 與 roll

暫存值會在每個字形重設,隨機值可重現,而運算元、暫存陣列、遞迴與執行上限會拒絕格式錯誤的程式,不會回傳不完整的外框

子集掃描器會解析本地與全域子常式呼叫用到的算術與暫存陣列運算式,包括 Type 2 16.16 定點數運算元

當隨機值、未知暫存狀態或跨程序的堆疊效應讓呼叫目標無法確定時,子集化會保留每一個候選子常式,而不是丟掉可能還連得到的外框相依

保留與已棄用的 Multiple Master 運算仍不支援,並會明確失敗