[trak] Keep tracking fractional#404
Merged
Merged
Conversation
The trak tracking value is interpolated per point size and is generally not a whole font unit, but get_h_tracking/get_v_tracking rounded it to an integer before scaling. HarfBuzz keeps it fractional and rounds once, after scaling to output units (get_h_tracking is em_scalef_x(get_tracking())). Return the fractional tracking and scale it with the Scale::scale_x_f /scale_y_f helpers. For SFNSItalic this removes an up-to-half-font-unit per-glyph advance difference from the "ot" shaper at point sizes where the tracking interpolates to a fractional value (e.g. 20.5, 24.5); integer-tracking sizes were already exact. Assisted-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Follow-up to #403, applying the same fix to the AAT
traktable.Problem
The
traktracking value is interpolated by point size and is generally not awhole font unit, but
get_h_tracking/get_v_trackingrounded it to aninteger before scaling. HarfBuzz keeps it fractional and rounds only once,
after scaling to output units (
get_h_trackingisem_scalef_x(get_tracking())).Fix
Return the fractional tracking and scale it with the
Scale::scale_x_f/scale_y_fhelpers (added in #403).Testing
Comparing the
otandharfrustshapers onSFNSItalic.ttf("System italic", size 20, weight 500) across point sizes 14–26 in 0.5 steps:(20.5, 21.5, 22.5, 23.5, 24.5, 25.0, 25.5) every glyph's advance differed
from
otby up to ±0.5 font units (±0.0049px); integer-tracking sizesalready matched.
0.000000pxmatch at every size.cargo test -p harfrust: 6027 passed, 0 failed.