Fix bug in COLRv1 glyph splitting, layers start_idx=0, and ot-rounding#1768
Merged
Conversation
`Colrv1RunType` only stored gradient colors when determining if consecutive shapes should be grouped into the same run. Two shapes with identical colors but different gradient geometry (e.g., different angles for linear gradients) were incorrectly treated as the same run and merged into a single `.colorN` glyph. Fixes #1766
When building `PaintColrLayers`, the code computed `start_idx` from `layer_list.num_layers`, which was always 0 during processing. The field was only set once at the very end of all processing. This caused all glyphs to incorrectly reference layers starting at index 0, making them share/overwrite each other's layers. Fixes #1767
This fixes two issues with gradient coordinate rounding: 1. Compound rounding error: When calculating perpendicular points for linear gradients (when p2 is not explicitly provided), the code rounded p0 and p1 to i16 first, then calculated the perpendicular from the rounded values. This caused compound rounding errors. 2. Wrong rounding mode: Used Rust's `.round()` (round half away from zero) instead of fontTools' `otRound` (round half up per OpenType spec).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1766 and #1767
plus, use OtRound to round gradient's geometry as fontTools does
we now match
ttx-diff resources/testdata/glyphs3/COLRv1-manyshapes-per-glyph.glyphswith "output is indentical"