Skip to content

Preserve COLRv1 alpha bounds and periodic angles - #2283

Closed
behdad wants to merge 16 commits into
skera-color-instance-precisionfrom
skera-color-bounds
Closed

behdad wants to merge 16 commits into
skera-color-instance-precisionfrom
skera-color-bounds

Conversation

@behdad

@behdad behdad commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Full COLRv1 instances must clamp alpha to [0, 1], while rotation and skew angles must preserve their periodic effect when variation takes them outside the stored F2Dot14 range. Skera previously used the same signed-width clamp for all of these fields, changing rotations above 360 degrees.

Clamp solid and gradient alpha only after full instancing. Preserve the unclamped base in partial instances because retained axes can bring it back into range. Normalize rotation and skew angles modulo 720 degrees before narrowing to F2Dot14, matching HarfBuzz's periodic representation.

Validation: focused color instancing tests, clippy, rustfmt, and typos pass. A synthetic two-axis font checks positive and negative alpha, gradient stops, and partial-then-full recovery of a base alpha of 1.5. A fresh HarfBuzz reference checks rotations above the stored angle range. The new angle test fails before this change.

The synthetic font was generated with fontTools FontBuilder; its weight and width rows respectively increase and decrease the first alpha. It is also used for a HarfBuzz regression fix.

Stacked on #2282.

Readers use read-fonts directly. write-fonts handles font assembly and owned table rebuilding; Skera retains its direct serializers and repacker. There is no separate generated Skera table tree.

@behdad
behdad added this pull request to stack #2267 October 10, 2026 06:00
@behdad
behdad force-pushed the skera-color-bounds branch from 9a8f7b2 to 74e4fba Compare October 10, 2026 18:08
@behdad
behdad requested a review from qxliu76 October 10, 2026 18:10
@behdad
behdad force-pushed the skera-color-bounds branch from 74e4fba to cd9fb39 Compare October 12, 2026 03:19
@behdad
behdad removed this pull request from stack #2267 October 12, 2026 03:28
@behdad
behdad added this pull request to stack #2335 October 12, 2026 03:29
@behdad
behdad force-pushed the skera-color-bounds branch 2 times, most recently from 3d3171a to e344763 Compare October 12, 2026 20:53
@behdad
behdad force-pushed the skera-color-bounds branch from e344763 to 07eb108 Compare October 12, 2026 22:04
@behdad
behdad force-pushed the skera-color-bounds branch from 07eb108 to afdb403 Compare October 14, 2026 23:11
behdad added 14 commits October 15, 2026 14:52
Propagate reviewed fixes and repaired ancestry through #2283.

Assisted-by: OpenAI Codex
This tree is unchanged; the replacement evaluator already handles missing
variation rows. Preserve the repaired parent ancestry.

Assisted-by: OpenAI Codex
Preserve reviewed parent ancestry and each PR's existing feature changes.

Assisted-by: OpenAI Codex
Preserve the independently validated TrueType changes and all feature code.

Assisted-by: OpenAI Codex
Keep empty record counts and allocation bounds at each PR boundary.

Assisted-by: OpenAI Codex
Move the existing #2338 correction into the width-reduction PR.

Assisted-by: OpenAI Codex
Reject unsupported versions and oversized arrays before ownership.
Keep current HarfBuzz references with complete feature parameters.

Assisted-by: OpenAI Codex
Preserve zero float32 products and reject subnormal condition pinning.

Assisted-by: OpenAI Codex
Bound pairwise work after deduplication, avoid temporary pair vectors,
and keep the corrected HarfBuzz column order at introduction.

Assisted-by: OpenAI Codex
@behdad

behdad commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Self-review in progress: full-instance alpha clamping and preserving an out-of-range but representable partial base are appropriate; rotation/skew wrapping by 720 degrees preserves their periodic effect within F2Dot14.

The new angle helper still adds 0.5 in float32 before flooring. It needs the same widened rounding boundary now moved into #2282. I will add a condition-independent scalar-product case that produces 0.5's immediate float32 predecessor, then use the shared helper. I am also checking partial alpha values beyond F2Dot14's storage range; keeping a base such as 1.5 does not by itself establish that larger intermediate values survive serialization.

@behdad

behdad commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by the rebuilt, consolidated instancing stack in #2416–#2423. MATH and name-table overrides remain separately covered by #2415 and #2411.

@behdad behdad closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant