Measure a run's advance with its own font - #514
Merged
Conversation
The word break between two runs on a line is decided by the gap between them minus the advance width of the first run. That advance was measured with the font of the second run, so on a line that changes font mid-way the glyph widths of the wrong font were used and a space appeared or went missing. Each run's font is now carried to the next iteration and used to measure its own advance. Six samples change, all on lines that switch font. Words that were run together or split apart are now separated correctly: "accusamusEt", "perspiciatisQuo" and "debitisQui" in gdocs-lorem-ipsum-with-titles-and-formatting, and the product name "VistalinkTM" in text-objects-across-multiple-streams, which was split into "Vista linkTM" twice. The spacing around punctuation shifts either way: three spaces before a full stop disappear in word365-lorem-ipsum-with-titles-and-formatting, one appears in issue-457 and one in issue-235. In issue-457 the formula "x + y = 56" loses two spaces: the "+" and "=" are OpenSymbol glyphs whose advance includes wide side bearings, so the gap left over is smaller than the word break threshold once the advance is measured with the font that actually draws them.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #514 +/- ##
============================================
- Coverage 49.94% 49.90% -0.05%
- Complexity 1874 1875 +1
============================================
Files 108 108
Lines 3588 3591 +3
============================================
Hits 1792 1792
- Misses 1796 1799 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 word break between two runs on a line is decided by the gap between them minus the advance width of the first run. That advance was measured with the font of the second run, so on a line that changes font mid-way the glyph widths of the wrong font were used and a space appeared or went missing. Each run's font is now carried to the next iteration and used to measure its own advance.
Six samples change, all on lines that switch font. Words that were run together or split apart are now separated correctly: "accusamusEt", "perspiciatisQuo" and "debitisQui" in gdocs-lorem-ipsum-with-titles-and-formatting, and the product name "VistalinkTM" in text-objects-across-multiple-streams, which was split into "Vista linkTM" twice.
The spacing around punctuation shifts either way: three spaces before a full stop disappear in word365-lorem-ipsum-with-titles-and-formatting, one appears in issue-457 and one in issue-235. In issue-457 the formula "x + y = 56" loses two spaces: the "+" and "=" are OpenSymbol glyphs whose advance includes wide side bearings, so the gap left over is smaller than the word break threshold once the advance is measured with the font that actually draws them.