Repository navigation
Commit a040fd4
Reland "[skparagraph] Cap letter spacing line shift"
This is a reland of commit 9628428
The original change broke the Flutter roll: the SkParagraph kitchensink
test in the web engine CanvasKit suite pinned LineMetrics.left to 2.5 on
a line that starts with letter spacing 5 and ends with an unspaced "!",
where the capped shift is 0. That test now accepts both values
(flutter/flutter#196148). The code is the same
as in the original change.
Original change's description:
> [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.
>
> Bug: flutter/flutter#184815
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1418376
> Reviewed-by: Florin Malita <[email protected]>
Without the fix, SkParagraph_LetterSpacingStaysInsideLineWidth fails 16
asserts, e.g. glyphs end at 348.80 while the max intrinsic width is
333.80.
Tested:
- Skia dm unit tests, SkParagraph (Linux x86_64, Debug and Release, Clang
22.1.0, FreeType + Fontconfig + HarfBuzz, ICU, extra_fonts): 235/235 pass
in both builds (234/234 before, plus the new test).
- Flutter engine text tests (Linux x86_64 host_debug_unopt, ICU), Flutter
7ce4746c92ea with this change vs the parent Skia: 2413/2413 pass on both
sides (103 txt/ui C++ unit tests, 2310 Dart framework and engine tests).
- Flutter web CanvasKit suite (chrome-dart2js-canvaskit-canvaskit, wasm
release rebuilt with each Skia): 362 passed, 1 skipped, 0 failed on both
sides, including the SkParagraph kitchensink test.
- google3 SkParagraph clients (1151 test targets): no regressions (one
golden test is flaky with and without this change).
- Flutter txt_benchmarks (Linux x86_64, 20 interleaved rounds on one
core): ShortLayout, LongLayout, JustifyLayout and TextBigO/1024 are
within 2% of the parent Skia.
- Skia trybots pass:
Test-Ubuntu24.04-Clang-GCE-CPU-AVX2-x86_64-Debug-All-NativeFonts_FreeType_ASAN_Upload
Test-Mac14-Clang-MacMini8.1-CPU-AVX2-x86_64-Debug-All-NativeFonts_Fontations
Not tested: Windows, Android, iOS.
Bug: flutter/flutter#184815
Assisted-by: Claude Opus 5.5 (Medium)
Change-Id: Id0e890c4aeaa64f0ed54554ae0cca341987a4d35
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1422517
Commit-Queue: Julia Lavrova <[email protected]>
Reviewed-by: Florin Malita <[email protected]>1 parent 108e8ef commit a040fd4
2 files changed
Lines changed: 144 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
214 | 231 | | |
215 | 232 | | |
216 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12811 | 12811 | | |
12812 | 12812 | | |
12813 | 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 | + | |
| 12892 | + | |
| 12893 | + | |
| 12894 | + | |
| 12895 | + | |
| 12896 | + | |
| 12897 | + | |
| 12898 | + | |
| 12899 | + | |
| 12900 | + | |
| 12901 | + | |
| 12902 | + | |
| 12903 | + | |
| 12904 | + | |
| 12905 | + | |
| 12906 | + | |
| 12907 | + | |
| 12908 | + | |
| 12909 | + | |
| 12910 | + | |
| 12911 | + | |
| 12912 | + | |
| 12913 | + | |
| 12914 | + | |
| 12915 | + | |
| 12916 | + | |
| 12917 | + | |
| 12918 | + | |
| 12919 | + | |
| 12920 | + | |
| 12921 | + | |
| 12922 | + | |
| 12923 | + | |
| 12924 | + | |
| 12925 | + | |
| 12926 | + | |
| 12927 | + | |
| 12928 | + | |
| 12929 | + | |
| 12930 | + | |
| 12931 | + | |
| 12932 | + | |
| 12933 | + | |
| 12934 | + | |
| 12935 | + | |
| 12936 | + | |
| 12937 | + | |
| 12938 | + | |
| 12939 | + | |
| 12940 | + | |
12814 | 12941 | | |
12815 | 12942 | | |
12816 | 12943 | | |
| |||
0 commit comments