TrueType design outlines and finite colour-glyph clip coverage
Version 2.1104.0 adds an unhinted TrueType outline API and uses conservative outline coverage to retain transformed uniform COLRv1 paints within a finite root ClipBox
Extracting TrueType design outlines
function HPDFGetTrueTypeGlyphOutline(const FontBytes: TBytes; GlyphID: Word;
out Commands: THPDFCFF2OutlineCommandArray; out UnitsPerEm: Word): Boolean;
The HPDFOpenTypeAdvanced function reads an ordinary sfnt glyf outline and returns the same Double move, line, cubic and close command representation as HPDFGetCFF2GlyphOutline. Coordinates use font design units and an upward Y axis; scale by the desired font size divided by UnitsPerEm
Simple glyphs retain on-curve and implicit midpoint semantics. Quadratic curves are elevated to cubic curves; composite glyphs retain component order, signed offsets, scaled or unscaled offset interpretation, 2-by-2 transforms and point attachment, including available horizontal and vertical phantom points
A valid empty glyph returns True with empty Commands and a valid UnitsPerEm. Failed extraction returns False with empty Commands and zero UnitsPerEm, including failure in a later component. Vertical phantom-point references require vhea/vmtx metadata
The API returns unhinted design geometry. It has no device ppem, does not execute hint bytecode or device-grid ROUND_XY_TO_GRID rounding, and does not promise equivalence with a hinted system-font path. For non-default variable axes, pass bytes from the existing outline instancing workflow
Extraction uses finite recursion, byte-span, component, point and allocation budgets: 64 composite levels, 4096 component records per glyph, 262144 flattened points/contours, 1000000 traversal/output operations and 128 MiB cumulative allocation admission. TTC selection remains outside this entry point
Exact source coordinates and quadratic commands
Version 2.1105.0 adds two outline entry points in HPDFOpenTypeAdvanced
function HPDFGetTrueTypeGlyphQuadraticOutline(const FontBytes: TBytes; GlyphID: Word;
out Commands: THPDFTrueTypeOutlineCommandArray; out UnitsPerEm: Word): Boolean;
function HPDFGetTrueTypeGlyphExactOutline(const FontBytes: TBytes; GlyphID: Word;
out Commands: THPDFTrueTypeExactOutlineCommandArray; out UnitsPerEm: Word): Boolean;
Both return move, line, quadratic and close commands using THPDFTrueTypeOutlineCommandKind. Each quadratic entry is a THPDFTrueTypeOutlineCommand record with Kind plus X1/Y1 and X2/Y2 Double coordinates, and each exact entry is a THPDFTrueTypeExactOutlineCommand record whose coordinates are THPDFTrueTypeExactCoordinate values. Move and line use X1/Y1; quadratic commands use X1/Y1 for the control point and X2/Y2 for the endpoint. Coordinates remain in font design units
The quadratic API retains the quadratic representation with Double coordinates. It does not recover precision already rounded during component resolution. The existing cubic API retains its Double contract
The exact API instead resolves original integer points, F2Dot14 component transforms, offsets, point attachments, available phantom points and implicit midpoints without an intermediate Double conversion. Each THPDFTrueTypeExactCoordinate is Negative, Exponent and Magnitude, representing a signed unsigned-big-endian integer magnitude multiplied by 2 to the Exponent power. Nonzero magnitudes are canonical odd integers with no leading zero byte; zero has empty Magnitude, Negative=False and Exponent=0
A successful empty glyph returns empty Commands and valid UnitsPerEm. Failure clears Commands and UnitsPerEm; EOutOfMemory propagates. The exact extractor additionally bounds magnitudes and absolute exponents to 8192, charges 16000000 limb-work units and retains the existing 128 MiB cumulative admission, recursion, component, point and command limits. Unhinted and variable-axis requirements remain the same as the original API
Bounded genuine curves
Version 2.1105.0 extends uniform-chain root clipping to genuine quadratic and cubic curves. TrueType source geometry stays exact through component resolution and affine composition. Quadratic pieces are elevated with exact rational controls only after their coordinates are bounded; final output coordinates are rounded to nearest-even Double
Exact dyadic De Casteljau subdivision retains each curve whose complete control hull lies within the construction frame, one root width and height beyond the actual root rectangle. Only pieces whose full hull lies in one closed outside half-plane of the actual root are replaced by chords. This preserves winding inside the actual root without using a flatness epsilon, and the original Form BBox remains the actual clip
Curve preparation uses a heap stack with depth limit 1024 and a 64000000 arithmetic-work budget; line-only clipping retains its 32000000 budget. The other transform, integer, command, vertex, cache and content limits still apply. Known full coverage skips only the current proved glyph clip; known empty coverage emits an empty clip. A failed calculation continues through the previous path without claiming completed native support
The 2.1105.0 DCC64 Win64 integration executes 83 configurations successfully. All 3036 certified curve interior samples match, against 1707 failures on the preceding source, and 144 protected complete-page comparisons remain identical. All 21 exact curved CFF2 page comparisons pass; composite comparisons retain six Poppler edge failures among eighteen, and bounded tangent diagnostics retain three endpoint edge failures among twelve
Independent finite root drawing matches all six composite Poppler source pages, whilst adding an explicit coincident root clip matches their original references. These observations attribute different boundary coverage to equivalent clipping representations without claiming a normative unique pixel or erasing the failed comparisons. The exact TrueType extractor passes 9106 assertions across 45 inputs, including 4400 canonical coordinate checks; broader paint fields, boundary compatibility and platform matrices remain separate
Finite root-clip coverage
Version 2.1104.1 also handles partial polygon coverage in uniform chains. If complete coverage cannot be proved, exact signed-dyadic affine arithmetic and homogeneous clipping restrict every line contour to the actual finite root ClipBox before coordinates are emitted. Different glyph and referenced-box nodes remain successive clip intersections; all contours of one glyph share a single nonzero-winding path
The calculation preserves small offsets beside huge transformed coordinates, contour orientation, holes and self-intersections. It rounds final bounded coordinates to nearest-even Double values, uses the original projected font size without an intermediate Single scale, and preserves the existing final transparency group and caller opacity
The interval proof distinguishes known-empty coverage from an unknown result. Proved-empty coverage emits an empty clip rather than coincident opposite contours that can produce reader edge artefacts. In 2.1104.1 unknown curves continued through the preceding native path; 2.1105.0 adds the bounded curve calculation above, whilst unsupported or budget-limited calculations still retain the preceding path and are not counted as completed drawing support
Finite per-calculation budgets are 64 transforms, 65536 input commands, 8192-bit exact integers, 131072 intermediate vertices, 262144 output commands and 32000000 charged arithmetic work units. One draw bounds accumulated clip content to 16 MiB; these budgets do not promise unrestricted graph or curve coverage
For a transform/glyph/referenced-glyph chain ending in a uniform solid, native COLRv1 drawing can prove that every glyph and referenced clip covers the complete actual root ClipBox. The uniform paint is then emitted in that finite root frame with its original colour, alpha and final transparency group, without the large intermediate matrices
The proof conservatively encloses the inverse-transformed clip with outward-rounded Double intervals. Every line or subdivided cubic control hull must remain outside the open target rectangle; the resulting complete contours must have nonzero total winding. Bounding-box containment alone is insufficient, and holes and winding direction are retained
A failed, singular, ambiguous or budget-limited proof continues through the existing drawing path. It does not mean the glyph is empty. Ordinary gradients, layers and composites are excluded before outline decoding, and repeated glyph outlines within one draw share a bounded cache
The focused Delphi Win64 profile covers deep scale, reflection, rotation, translation, quadratic and CFF2 curves, referenced ClipBoxes and caller opacity. All 27 complete source/reference page comparisons are pixel-identical across MuPDF 1.28.5, Poppler 26.09.0 and Ghostscript 10.08.0, against 27 failed baseline comparisons; the selected interiors contain 243 samples
The hole control retains empty output. The original deeply transformed partial-square control is repaired in 2.1104.1. Bounded uniform-chain curve clipping follows in 2.1105.0; transformed nonuniform paint fields, sweep-centre integration and broader reader compatibility remain separate work
Verification boundary
The 2.1104.1 Delphi Win64 integration executes 49 native configurations successfully, repairing seven preceding finite-operand exceptions. Across three readers, all 19422 independently selected interior pixels match finite references, against 4092 failures among 8844 available baseline pixels and 21 reader comparisons unavailable because of the native exceptions. All 105 protected complete-page comparisons retain their original pixels
The native finite-font comparison remains stricter than this interior result: 25 of 72 complete-page comparisons retain boundary pixel differences, and those failures are not relabelled. A genuine partial quadratic control preserves its earlier native result and output without claiming curve correctness. The independent exact-arithmetic controls cover 80 cases, 516 correctly rounded coordinates and separate exact/rounded winding checks; 42 coverage-classification checks retain the original full-coverage contract
The independent TrueType outline controls cover 32 cases with 226 assertions and 4128 oriented segment-coordinate comparisons, including composite transforms, both loca formats, small coordinates, point attachment and atomic invalid-input failures. A separate geometry control covers 28 Pascal checks and 14 exact-rational cases
This release uses the stated Delphi Win64 executions and finite reader controls. It does not claim a full compiler/platform matrix or unrestricted native rendering compatibility
See DrawRegisteredColorGlyph, COLRv1 paint graphs and CFF2 outline commands