text: project kerning offset onto rotated text-flow axis#1046
Open
benface wants to merge 1 commit into
Open
Conversation
The kerning offset added by not-fl3#1035 is always added to `dest.x`, ignoring `TextParams.rotation`. At `rot = 0` text flows along +X and that's correct; at `rot = π/2` text flows along +Y so the offset lands perpendicular to the text-flow axis instead of along it. Multiply by `(rot_cos, rot_sin)` to route the offset into the correct axis for any rotation.
Contributor
Author
|
FYI: the failing |
Owner
|
Thanks for PR! |
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 #1045.
Summary
draw_text_exalways addskerning_offsettodest.x, ignoringTextParams.rotation. Atrotation = 0text flows along +X and that's correct; atrotation = π / 2text flows along +Y so the offset lands perpendicular to the text-flow axis. Multiplying by(rot_cos, rot_sin)routes the offset into the correct axis for any rotation.Cause
In
draw_text_ex:(offset_x + total_width)accumulates along the unrotated text-flow axis (+X in glyph-local space) and the rotation matrix correctly routes it intodest_x/dest_y. The kerning offset is an additional text-flow advance but gets added todest.xwithout the same routing.Fix
Project
kerning_offset(logical-pixel-converted, same as the existing/ dpi_scaling) onto the rotation basis vectors:At
rotation = 0:rot_cos = 1, rot_sin = 0→ identical to the previous behaviour.At
rotation = π / 2:rot_cos = 0, rot_sin = 1→ offset routes intodest.y.Any other angle: offset projects onto the rotated flow direction.
total_width += char_data.advance * font_scale_x + kerning_offset;(line 386) is unchanged —total_widthstays in unrotated glyph-local space and is itself routed through the rotation matrix on the next iteration.Verification
Tested with the originally-reported reproducer: a font with kerning entries (OstrichSans-Heavy) drawn at
rotation = π / 2. Before the patch, kerned pairs in strings likeRESTART LEVELshow per-character perpendicular shifts in screen space that vary with the surrounding kerning context. With the patch, the shift disappears and the rotated text reads as a clean baseline.