fix: stop applying PX_TO_PT to font-size twice (#502) - #503
Merged
Conversation
The viewport group already carries the px-to-pt conversion, but font-size was converted again below it: applyStyleOnShape mapped it through convertLengthToPt, and convertText measured advance widths in points before adding them to x coordinates in user units. Text therefore rendered at 0.75x the size of the geometry around it, and multi-tspan runs were laid out in the wrong unit. Both now stay in user units, leaving the single conversion to the viewport transform. Three tests in tests/test_units.py asserted the stored String.fontSize in points and so encoded the bug; they now assert the rendered size instead. The relational tests there and in test_basic.py are untouched and still pass. Adds regression coverage for the text-to-geometry ratio across seven root variants, for multi-tspan positioning and for per-character positioning; all six fail without the source change.
Owner
|
Thanks for the detailed writeup and repro — this is a genuine regression from the 2.0b1 unit rework, not expected behaviour like #471. Verified independently: your repro script now emits Fix is well-scoped, the rewritten tests correctly assert rendered size instead of raw |
This was referenced Aug 10, 2026
Merged
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.
The viewport group already carries the px-to-pt conversion, but font-size was converted again below it: applyStyleOnShape mapped it through convertLengthToPt, and convertText measured advance widths in points before adding them to x coordinates in user units. Text therefore rendered at 0.75x the size of the geometry around it, and multi-tspan runs were laid out in the wrong unit. Both now stay in user units, leaving the single conversion to the viewport transform.
Three tests in tests/test_units.py asserted the stored String.fontSize in points and so encoded the bug; they now assert the rendered size instead. The relational tests there and in test_basic.py are untouched and still pass. Adds regression coverage for the text-to-geometry ratio across seven root variants, for multi-tspan positioning and for per-character positioning; all six fail without the source change.