Fix signed fractional CFF coordinates - #556
Closed
Artromskiy wants to merge 1 commit into
Closed
Conversation
|
|
Contributor
Author
|
Closing this PR to recreate it with the corrected Artromskiy commit identity. |
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.
Problem
CFF Type 2 32-bit numbers are signed 16.16 fixed-point values. In
v3.1.0, the fractional word was read as a signedshort. Whenever bit 15 of the fractional word was set, the decoded value was one design unit too small. On a CFF glyph this error accumulated across relative curve coordinates and produced visibly incorrect outlines.The issue was reproduced with glyph 54 (
R) from an external Igrunok OTF. The font is not included because its local license does not establish that redistribution in this test repository is permitted. The regression uses the raw Type 2 prefix from that glyph, without distributing the font.Fix
Read the integer word as signed and the fractional word as unsigned, which is the correct signed 16.16 decomposition.
Tests
dotnet build src/SixLabors.Fonts/SixLabors.Fonts.csproj -c Release— passed, 0 warnings/errors.CffEvaluationEngineTests— 2 passed.The full test suite was not used as acceptance for this local clone because test fonts were unavailable as LFS objects after a smudge/download timeout.