OpenTPW

COMPAT-003: Verify GDI glyph coverage#

Status and classification (updated)#

Current state (source-verified at this baseline, allowlisted files only)#

Substantive gap filled by this change#

No test pinned (a) each of the 17 GdiGray4 levels with a constructed shape, (b) exact multi-byte GdiGray4 output for a slanted edge, (c) vertical half-open rows across multiple rows in the gray model, (d) negative-coordinate OriginX/OriginY under the gray model, (e) empty-glyph paths (default-model placed list, degenerate contours, the .notdef/empty-loca font path), (f) same-process determinism through the public API in the gray model, or (g) a direct gray-vs-linear divergence pin. All are characterization of existing behaviour only; no code change was needed or made.

New test file: source/OpenTPW.Tests/GdiGray4CoverageContractTests.cs#

Exact claims, each with a hand-derived pinned literal (derivation in the test comments; analytic sample-boundary fixtures use dyadic coordinates):

TestPinned expectation
EveryNonzeroSampleCountMapsToItsPinnedGrayByte (16 DataRows)levels 1..16 map to 16, 32, 48, 64, 80, 96, 112, 128, 143, 159, 175, 191, 207, 223, 239, 255; 1x1 bitmap, origin (0,0). Note the asymmetry: level 8 -> 128 but level 9 -> 143, not 144. Shapes covering counts a rectangle cannot produce (5, 7, 10, 11, 13, 14, 15) combine two side-by-side rectangles. Level 1's geometry coincides with an existing pin in GdiGrayCoverageTests; the row is kept so the table is complete, and the overlap is disclosed.
ASlantedEdgeWhoseCrossingsLandOnSamplePositionsIsPinnedright triangle with hypotenuse x == y: rows [96,0,0,0], [255,96,0,0], [255,255,96,0], [255,255,255,96], 4x4, origin (0,0). Diagonal pixels hold 0+1+2+3 = 6 samples -> 96.
VerticalSampleRangeIsTopInclusiveAndBottomExclusiveAcrossRowsrows [0.125, 2.375): [255, 255, 64], 1x3, origin (0,0).
AGlyphLeftOfAndAboveTheOriginGetsPositiveOriginsAndPinnedCoveragespan [-1.25, -0.75) x [-2, -1]: bytes [64, 64], 2x1, origin (2,2).
EmptyAndDegenerateOutlinesProduceTheSharedEmptyBitmapempty placed list, a one-point contour and an all-horizontal contour each return CoverageBitmap.Empty under the default model.
AnEmptyFontGlyphRasterizesToTheEmptyBitmapglyph 0 of a synthetic font (empty loca entry) rasterizes to CoverageBitmap.Empty through RasterizeGlyph (reuses TrueTypeFontTests.FontBuilder, same assembly).
RepeatedRasterizationOfTheSameSceneIsByteIdenticaltwo runs of the same composite scene produce byte-identical coverage, equal ComputeHash(), dims (6,4), origin (0,0), spot values 96 and 80. Composite-scene hash literals are intentionally not pinned here because no execution was possible to generate them; the existing Linear composite hash pin is the template to reproduce on exact-head CI.
TheGrayModelDiffersFromLinearOnFractionalCoveragesame rectangle [0, 0.3) x [0, 1): GdiGray4 pins 64 (one sample column, 4 samples); the two models must disagree (Linear's 77 is already pinned in GdiGrayCoverageTests).

Exact tested claims vs. unproven cases#

Tested (once executed on exact head): the 17-level gray byte map on constructed sample counts; sampled (not integrated) fractional coverage with half-open spans on both axes; exact slanted-edge samples when crossings land on sample positions; origin handling for glyphs left of/above the pen; empty and degenerate outline paths, including the font .notdef path; byte-level repeatability of repeated rasterization in one process.

Unproven and explicitly not claimed:

Evidence still needed (unchanged requirement)#

Matched Windows GDI grayscale DIB outputs, including LOGFONT, hinting and palette settings, to verify the byte mapping, sample positions and gamma against real GDI. Any original captures/assets remain private; fixtures must stay synthetic or be references/hashes. No supporting evidence was needed from outside the allowlist for this deliverable.

Ownership and overlap#

Completion boundary#

Historical plan (2026-10-18 draft, baseline 5ccddcab — preserved verbatim, superseded by the sections above)#

Status and classification#

Source-verified residual#

GdiGray4 rasterization uses 4x4 samples and a 17-level byte map without hinting; the compositor already implements the documented blur/relief arithmetic.

Source sites#

Implementation cross-check#

Evidence needed#

Bounded investigation and implementation plan#

  1. Confirm current ownership and rebase the proposal against the latest main before runtime changes.

  2. Build a pixel-comparison harness for coverage before blur; isolate sample positions, hinting and byte mapping rather than rewriting proven compositor arithmetic.

  3. Turn each verified behavioral distinction into a small deterministic regression fixture before editing runtime paths.

  4. Keep unknown behavior explicitly unresolved; an evidence-only outcome is valid if no mismatch is established.

  5. Submit any later implementation with exact evidence, changed scope and test output for review.

Acceptance tests to author and run later#

Ownership and overlap#

Completion boundary#

Source: docs/proposals/compat-003-verify-gdi-glyph-coverage.md in the project repository.