Repository navigation
Commit 9628428
[skparagraph] Cap letter spacing line shift
TextLine shifts the whole line right by half the letter spacing of its
first cluster, so glyphs look centered in their spaced cells as Flutter
expects. Cluster widths keep the whole spacing after the glyph, and line
widths do not count the shift. When a line starts with letter spaced
text and ends with plain text, negative spacing, or a cursive script
(which gets no spacing), the last glyphs and their boxes end up to half
the spacing past the line width. Flutter clips text at the max intrinsic
width when maxLines is reached, so the last characters disappear.
Now the shift is at most the half spacing of the visually rightmost
text cluster of the line, and never negative. Glyphs of right to left
runs are laid out left to right as well, each with its spacing on the
right, so for such a run that cluster is its logical start. Lines with
the same spacing at both visual ends keep the old shift, so uniform
letter spacing and right to left lines that start letter spaced do not
change. Trailing placeholders keep the shift, as the inline placeholder
tests expect.
Without the fix, SkParagraph_LetterSpacingStaysInsideLineWidth fails 16
asserts, e.g. glyphs end at 348.80 while the max intrinsic width is
333.80.
Not covered: a letter spaced line with an ellipsis or a soft hyphen
still draws it past the width (they are added after the shift is set).
Tested:
- Skia dm --src tests --nogpu --nativeFonts --paragraph_fonts
extra_fonts -m SkParagraph, Linux x86_64, Clang, FreeType, ICU, Debug
(234 tests) and Release (232 tests): all pass except
SkParagraph_MultiStyle_Zalgo, which fails the same way without this
change (checked in both builds)
- Flutter engine paragraph corpus on Linux x86_64 (host_debug_unopt,
Clang, FreeType, ICU): 2409 tests (99 C++ tests in txt_unittests and
ui_unittests plus 2310 Dart layout, editing, and text field tests), 0
regressions; full framework corpus (20198 tests in 921 files): same
results with and without the final version of the change (only the
pre-existing cupertino popup_surface_test golden fails in both)
- Flutter engine txt_benchmarks A/B on Linux x86_64 (host_release,
Clang, FreeType, ICU, 20 interleaved rounds): neutral across all 4
benchmarks (ShortLayout ratio 0.9941, 95% CI [0.9866, 1.0005];
LongLayout 1.0068, [0.9901, 1.0145]; JustifyLayout 1.0032,
[0.9966, 1.0121]; TextBigO/1024 0.9908, [0.9824, 1.0041])
- google3 SkParagraph clients (1151 test targets, including slow tier,
Linux x86_64): no regressions
- Skia trybots, green:
Test-Ubuntu24.04-Clang-GCE-CPU-AVX2-x86_64-Debug-All-NativeFonts_FreeType_ASAN_Upload
Test-Ubuntu24.04-Clang-GCE-CPU-AVX2-x86_64-Release-All
Test-Ubuntu24.04-Clang-GCE-CPU-AVX2-x86_64-Release-All-MSAN
Test-Ubuntu24.04-Clang-GCE-CPU-AVX2-x86_64-Release-All-NativeFonts_Fontations
Test-Mac14-Clang-MacMini8.1-CPU-AVX2-x86_64-Debug-All-NativeFonts_Fontations
Test-Mac15-Clang-MacMini16.10-CPU-AppleM4-arm64-Debug-All-NativeFonts
Test-Win11-Clang-GCE-CPU-AVX2-x86_64-Debug-All-NativeFonts
Test-Win11-MSVC-GCE-CPU-AVX2-x86_64-Release-All
Test-Android-Clang-GalaxyS24-CPU-Adreno750-arm64-Release-All-Android_NativeFonts_AndroidNDKFonts
(the new test is skipped there: no paragraph test fonts on Android)
Not tested: the new test on Android or iOS, Canary-Chromium,
Canary-Android
Bug: flutter/flutter#184815
Assisted-by: Claude Opus 5.5 (Medium)
Change-Id: I5f1b165d12eae076b3be8e9d51e49a80020b0181
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1418376
Commit-Queue: Julia Lavrova <[email protected]>
Reviewed-by: Florin Malita <[email protected]>1 parent b11315d commit 9628428
2 files changed
Lines changed: 144 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
225 | 242 | | |
226 | 243 | | |
227 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12762 | 12762 | | |
12763 | 12763 | | |
12764 | 12764 | | |
| 12765 | + | |
| 12766 | + | |
| 12767 | + | |
| 12768 | + | |
| 12769 | + | |
| 12770 | + | |
| 12771 | + | |
| 12772 | + | |
| 12773 | + | |
| 12774 | + | |
| 12775 | + | |
| 12776 | + | |
| 12777 | + | |
| 12778 | + | |
| 12779 | + | |
| 12780 | + | |
| 12781 | + | |
| 12782 | + | |
| 12783 | + | |
| 12784 | + | |
| 12785 | + | |
| 12786 | + | |
| 12787 | + | |
| 12788 | + | |
| 12789 | + | |
| 12790 | + | |
| 12791 | + | |
| 12792 | + | |
| 12793 | + | |
| 12794 | + | |
| 12795 | + | |
| 12796 | + | |
| 12797 | + | |
| 12798 | + | |
| 12799 | + | |
| 12800 | + | |
| 12801 | + | |
| 12802 | + | |
| 12803 | + | |
| 12804 | + | |
| 12805 | + | |
| 12806 | + | |
| 12807 | + | |
| 12808 | + | |
| 12809 | + | |
| 12810 | + | |
| 12811 | + | |
| 12812 | + | |
| 12813 | + | |
| 12814 | + | |
| 12815 | + | |
| 12816 | + | |
| 12817 | + | |
| 12818 | + | |
| 12819 | + | |
| 12820 | + | |
| 12821 | + | |
| 12822 | + | |
| 12823 | + | |
| 12824 | + | |
| 12825 | + | |
| 12826 | + | |
| 12827 | + | |
| 12828 | + | |
| 12829 | + | |
| 12830 | + | |
| 12831 | + | |
| 12832 | + | |
| 12833 | + | |
| 12834 | + | |
| 12835 | + | |
| 12836 | + | |
| 12837 | + | |
| 12838 | + | |
| 12839 | + | |
| 12840 | + | |
| 12841 | + | |
| 12842 | + | |
| 12843 | + | |
| 12844 | + | |
| 12845 | + | |
| 12846 | + | |
| 12847 | + | |
| 12848 | + | |
| 12849 | + | |
| 12850 | + | |
| 12851 | + | |
| 12852 | + | |
| 12853 | + | |
| 12854 | + | |
| 12855 | + | |
| 12856 | + | |
| 12857 | + | |
| 12858 | + | |
| 12859 | + | |
| 12860 | + | |
| 12861 | + | |
| 12862 | + | |
| 12863 | + | |
| 12864 | + | |
| 12865 | + | |
| 12866 | + | |
| 12867 | + | |
| 12868 | + | |
| 12869 | + | |
| 12870 | + | |
| 12871 | + | |
| 12872 | + | |
| 12873 | + | |
| 12874 | + | |
| 12875 | + | |
| 12876 | + | |
| 12877 | + | |
| 12878 | + | |
| 12879 | + | |
| 12880 | + | |
| 12881 | + | |
| 12882 | + | |
| 12883 | + | |
| 12884 | + | |
| 12885 | + | |
| 12886 | + | |
| 12887 | + | |
| 12888 | + | |
| 12889 | + | |
| 12890 | + | |
| 12891 | + | |
0 commit comments