CFF and OpenType Font Subsetting Functions

PDF Filter Support

 

Top  EnableFontSubsetting  Inhalt

These unit-level functions expose the public CFF and OpenType-CFF font subsetting surface used by HotPDF's embedded font pipeline. HotPDF also ships reusable Type 1 PFB and CFF parser units for callers that need lower-level font inspection.

 

Delphi syntax

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;

 

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 detects an sfnt container whose version is OTTO. HPDFOTFFindCFFTable locates the embedded 'CFF ' table. HPDFSubsetOTFContainer combines these steps by subsetting the embedded CFF table and returning an OTF container with the original sfnt table layout preserved.

 

The subsetter recognises both name-keyed CFF (single Private DICT, single Local Subr INDEX) and CID-keyed CFF (Top DICT ROS operator, FDArray of multiple sub-font Private DICTs, FDSelect glyph-to-FD map, per-FD Local Subr INDEXes). CID support since v2.40.0 covers CJK / Indic / Arabic OpenType-CFF fonts such as the Adobe Fan/Gothic/Heiti/Ming/Myungjo/Song Std family, Kozuka Pr6N, and Source Han Sans - the closure scan tracks each kept CharString's FD context so per-FD Local Subr INDEXes are independently subsetted.

 

The lower-level CFF integer decoders, FDArray / FDSelect parsers, and subroutine scanners used by the subsetter implementation are internal to HPDFDoc.pas.

 

Type 1 and CFF parser units

HPDFType1Core, HPDFType1Glyphs, HPDFType1CFFHandler, and HPDFType1PFBHandler provide reusable byte-array readers, Type 1 glyph-outline command extraction, CFF Header / INDEX / dictionary / charset / encoding parsing, and Type 1 PFB metadata plus glyph lookup helpers. 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.

 

See also: EnableFontSubsetting, FontEmbedding, PDF Filter Support