CFF and OpenType Font Subsetting Functions

PDF Filter Support

 

Top  EnableFontSubsetting  Contents

These unit-level functions expose the public CFF, OpenType-CFF, and sfnt font-inspection 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;

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 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. HPDFExtractTTFPostScriptName reads name ID 6 from the sfnt name table and returns the PostScript font name when present

 

The subsetter recognizes 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 covers CJK / Indic / Arabic OpenType-CFF fonts; 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 are implementation details behind this public helper surface

 

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