Controlled TrueType variable-font instancing

HPDFInstantiateTrueTypeVariableFontControlled in HPDFOpenTypeAdvanced accepts original TrueType variable-font bytes, axis selections, and an optional THPDFVariableFontControl

The existing HPDFInstantiateTrueTypeVariableFont entry remains available and delegates with no explicit control object

Instance engine

For selected colour values outside static field encodings, version 2.1098.0 adds HPDFInstantiateVariableFontOutlines and axis-aware colour inspection. The selected-axis colour programmes and static outlines workflow keeps original colour bytes and registration coordinates separately; complete static-font instance APIs retain their existing output contract

Version 2.1097.0 evaluates supported COLRv1 variable paint fields, stop positions and opacity, and affine or compact transforms before removing axis tables. It emits corresponding static paint formats with independently appended colour lines and matrices; values that cannot fit static target encodings still fail conversion. See COLRv1 paint graphs for the retained negative-radius and representation boundaries

Version 2.1096.1 also freezes COLRv1 variable ClipBoxes using the normalised axis coordinates. The shared CFF2 instancer uses the same path; see COLRv1 paint graphs for mapping, rounding and static-coordinate limits. The ClipBox-specific scope is extended by variable paint-field instancing in version 2.1097.0

The engine resolves gvar tuples and IUP interpolation, simple-glyph points, composite placement, phantom-point metrics, HVAR, VVAR, and MVAR, then rebuilds static glyph data, loca, dependent metrics, and checksums

The resulting hhea.advanceWidthMax uses all final horizontal advances; minLeftSideBearing, minRightSideBearing, and xMaxExtent use glyphs with contours and become zero for an all-empty font

When vertical metrics are present, vhea.advanceHeightMax, minTopSideBearing, minBottomSideBearing, and yMaxExtent are rebuilt from final vmtx values and glyph heights after either gvar or VVAR processing; empty glyphs affect maximum advance, while an all-empty font has zero outline-dependent vertical measurements

Bounds aggregation distinguishes a contour whose points coincide from a glyph with no outline points. Degenerate contours and their composite children retain their point bounds; genuinely empty composites are excluded from outline-dependent header measurements, and global bounds are written as zero when the entire font has no outline points

Derived signed header values are range-checked before encoding; an unrepresentable value does not wrap into a misleading signed field

Layout variation references are resolved against the selected coordinates before their shared store is removed, including supported GPOS and BASE references, feature variations, and GPOS lookups embedded in JSTF

JSTF table instancing is separate from choosing justification priorities or applying full paragraph justification in a PDF layout engine; finite table-branch checks do not establish the latter behaviour

For fonts with cvar, the engine applies control-value deltas at the normalised axis coordinates before removing the variation tables, while preserving glyph hinting instructions and the prep and fpgm programs

Control-value tuples support private or shared point selections, all-value tuples and intermediate regions; unselected values receive no inferred deltas, and accumulated values are rounded to the nearest integer with halves toward positive infinity

Composite bounds use recursively transformed outline points rather than transformed bounding-box corners. Point attachments align the selected parent and child points, including phantom references; scaled component offsets are transformed after their variation deltas, while unscaled or unspecified offsets retain their coordinates

Nested calculations retain fractional point coordinates until each glyph's bounds are encoded. Original component records, point indices, transforms and instructions are preserved; pixel-grid rounding remains a rasteriser operation

The engine also resolves registered wght, wdth, and slnt style metadata from user-space coordinates before writing final sfnt checksums; this metadata follows the selected axes independently of normalisation and avar outline mapping. See selected-axis style metadata for rounding and field semantics; the direct instancer retains its existing rejection of out-of-range coordinates

Resource controls

THPDFVariableFontControl accepts maximum output bytes, cumulative working-admission bytes, and a cancellation callback; internal table, glyph, tuple, metric, layout, checksum, and output-building work uses that same control, the read-only THPDFVariableFontControl.AdmittedBytes property reports the cumulative admitted working bytes, and THPDFVariableFontControl.CheckOutput charges and enforces the output-byte limit as the instance is built

Cancellation or a resource rejection leaves the caller's input bytes unchanged and does not return a partial static font; later calls can retry from the original source

The admission counter is conservative allocation accounting rather than exact live-heap accounting; callback checks are checkpoints and do not promise asynchronous interruption between every machine instruction

The low-level engine preserves the original naming contract; the headless wrapper separately gives a static instance its deterministic PostScript name while retaining original notices

See headless variable-font instances and advanced OpenType font workflows