Skip to content

[colr] Scale relative gradient coordinates and quantize clip boxes#1755

Merged
anthrotype merged 3 commits into
mainfrom
scale-gradient-coordinates
Nov 14, 2025
Merged

[colr] Scale relative gradient coordinates and quantize clip boxes#1755
anthrotype merged 3 commits into
mainfrom
scale-gradient-coordinates

Conversation

@anthrotype

Copy link
Copy Markdown
Member

Scale COLR gradient coordinates from percentages (0.0-1.0) to absolute font units like Glyphs.app does, using the glyph bounding boxes. We do this in the backend to avoid having to compute these twice.

Also quantize COLR ClipBox coordinates to multiples of 1/10th of the font's UPEM (e.g. 100 units for 1000 upem etc.) to maximize clipbox reuse across glyphs, matching ufo2ft/fontmake behavior.

I would like to add more tailored unit tests but from local testing this patch already makes the simple COLRv1 test .glyphs pass "output is identical" in ttx-diff.

LinearGradient.p2 and RadialGradient radiuses need to be computed in fontbe because we need the bounding boxes
Scale COLR gradient coordinates from percentages (0.0-1.0) to absolute
font units using glyph bounding boxes. This fixes the core gradient
geometry issue where Glyphs.app stores coordinates as percentages of
the layer bounds.
Quantize COLR ClipBox coordinates to multiples of 1/10th of the font's UPEM
(e.g. 100 units for 1000 upem etc.) to maximize clipbox reuse across glyphs.
This matches ufo2ft/fontmake behavior and should reduce table size by allowing
more glyphs to share the same ClipBox.

@rsheeter rsheeter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the extensive refs back to python!

@anthrotype anthrotype added this pull request to the merge queue Nov 14, 2025
Merged via the queue into main with commit 1a4c814 Nov 14, 2025
12 checks passed
@anthrotype anthrotype deleted the scale-gradient-coordinates branch November 14, 2025 19:00
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.

2 participants