@@ -677,8 +677,6 @@ void Paragraph::Layout(double width, bool force) {
677
677
const SkTextBlobBuilder::RunBuffer& blob_buffer =
678
678
builder.allocRunPos (font, glyph_blob.end - glyph_blob.start );
679
679
680
- double justify_x_offset_delta = 0 ;
681
-
682
680
for (size_t glyph_index = glyph_blob.start ;
683
681
glyph_index < glyph_blob.end ;) {
684
682
size_t cluster_start_glyph_index = glyph_index;
@@ -692,7 +690,7 @@ void Paragraph::Layout(double width, bool force) {
692
690
693
691
size_t pos_index = blob_index * 2 ;
694
692
blob_buffer.pos [pos_index] =
695
- layout.getX (glyph_index) + justify_x_offset_delta ;
693
+ layout.getX (glyph_index) + justify_x_offset ;
696
694
blob_buffer.pos [pos_index + 1 ] = layout.getY (glyph_index);
697
695
698
696
if (glyph_index == cluster_start_glyph_index)
@@ -772,7 +770,7 @@ void Paragraph::Layout(double width, bool force) {
772
770
773
771
if (at_word_end) {
774
772
if (justify_line) {
775
- justify_x_offset_delta += word_gap_width;
773
+ justify_x_offset += word_gap_width;
776
774
}
777
775
word_index++;
778
776
@@ -789,11 +787,9 @@ void Paragraph::Layout(double width, bool force) {
789
787
continue ;
790
788
SkFontMetrics metrics;
791
789
font.getMetrics (&metrics);
792
- paint_records.emplace_back (
793
- run.style (), SkPoint::Make (run_x_offset + justify_x_offset, 0 ),
794
- builder.make (), metrics, line_number,
795
- layout.getAdvance () + justify_x_offset_delta, run.is_ghost ());
796
- justify_x_offset += justify_x_offset_delta;
790
+ paint_records.emplace_back (run.style (), SkPoint::Make (run_x_offset, 0 ),
791
+ builder.make (), metrics, line_number,
792
+ layout.getAdvance (), run.is_ghost ());
797
793
798
794
line_glyph_positions.insert (line_glyph_positions.end (),
799
795
glyph_positions.begin (),
@@ -1054,7 +1050,13 @@ void Paragraph::PaintDecorations(SkCanvas* canvas,
1054
1050
// Filled when drawing wavy decorations.
1055
1051
SkPath path;
1056
1052
1057
- double width = record.GetRunWidth ();
1053
+ double width = 0 ;
1054
+ if (paragraph_style_.text_align == TextAlign::justify &&
1055
+ record.line () != GetLineCount () - 1 ) {
1056
+ width = width_;
1057
+ } else {
1058
+ width = record.GetRunWidth ();
1059
+ }
1058
1060
1059
1061
SkScalar underline_thickness;
1060
1062
if ((metrics.fFlags &
0 commit comments