CFF and OpenType Font Subsetting Functions

PDF Filter Support

 

Top  EnableFontSubsetting  Contents

These unit-level functions expose the public CFF and OpenType-CFF font subsetting surface used by HotPDF's embedded font pipeline.

 

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 implementation are internal to HPDFDoc.pas and are not part of the public unit interface.

 

See also: EnableFontSubsetting, FontEmbedding, PDF Filter Support