Persistent Font-Subset Cache

The persistent font-subset cache avoids repeating expensive TrueType or OpenType subsetting when later documents use the same font content and glyph set

Configuration

property FontSubsetCacheFolder: AnsiString;
property FontSubsetCacheMaxBytes: Int64;
function GetFontSubsetCacheInfo: THPDFFontSubsetCacheInfo;
procedure ClearFontSubsetCache;

An empty FontSubsetCacheFolder disables disk caching without changing font output

FontSubsetCacheMaxBytes defaults to 256 MiB and may be reduced at runtime, which triggers immediate least-recently-used eviction

Statistics

THPDFFontSubsetCacheInfo contains HitCount, MissCount, WriteCount, EvictionCount, CorruptCount, RejectedCount, WriteFailureCount, CurrentBytes, and FileCount

Correctness and recovery

Example

var
  Info: THPDFFontSubsetCacheInfo;
begin
  PDF.EnableFontSubsetting := True;
  PDF.FontSubsetCacheFolder := 'C:\ProgramData\MyApp\HotPDF\FontSubsets';
  PDF.FontSubsetCacheMaxBytes := 256 * 1024 * 1024;
  { create documents that use embedded TrueType or OpenType fonts }
  Info := PDF.GetFontSubsetCacheInfo;
end;

See also