Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Round scale to nearest 26.6 fixed point. #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

dmitshur
Copy link

@dmitshur dmitshur commented Oct 24, 2021

With this change, the computation of the scale factor becomes
identical across the freetype and truetype packages, removing
deviations in the font metrics that are derived from scale.

Apply the same change to the Context.PointToFixed method to
keep it in sync.

The rounding computation is newer; it was introduced when the
truetype.Face type was added in commit 6deea24.

Fixes #85.

With this change, the computation of the scale factor becomes
identical across the freetype and truetype packages, removing
deviations in the font metrics that are derived from scale.

The rounding computation is newer; it was introduced when the
truetype.Face type was added in commit 6deea24.

Fixes #85.
@dmitshur
Copy link
Author

dmitshur commented Nov 6, 2021

I just noticed there's a Context.PointToFixed method that does the same conversion:

return fixed.Int26_6(x * float64(c.dpi) * (64.0 / 72.0))

We should not change one without also changing the other, as that would fix #85 but introduce another inconsistency within this package. Hmm.

Otherwise there may be deviations between the scale computation
and the conversion done by PointToFixed in the same package.
@nigeltao
Copy link
Contributor

We should not change one without also changing the other, as that would fix #85 but introduce another inconsistency within this package. Hmm.

Yeah, that's unfortunate. :-/

@dmitshur
Copy link
Author

dmitshur commented Nov 16, 2021

Commit 5ca4844 in this PR updates PointToFixed too, and 51c1af1 adds more test cases.

@rcoreilly
Copy link

applied this to https://github.com/goki/freetype

rcoreilly added a commit to goki/freetype that referenced this pull request Mar 28, 2023
…inding = true in rasterizer; return !ok in GlyphAdvance if rune index == 0, consistent with opentype.
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.

discrepancy in scale factor conversion between freetype and truetype packages
3 participants