@@ -677,6 +677,8 @@ 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
+
680
682
for (size_t glyph_index = glyph_blob.start ;
681
683
glyph_index < glyph_blob.end ;) {
682
684
size_t cluster_start_glyph_index = glyph_index;
@@ -690,7 +692,7 @@ void Paragraph::Layout(double width, bool force) {
690
692
691
693
size_t pos_index = blob_index * 2 ;
692
694
blob_buffer.pos [pos_index] =
693
- layout.getX (glyph_index) + justify_x_offset ;
695
+ layout.getX (glyph_index) + justify_x_offset_delta ;
694
696
blob_buffer.pos [pos_index + 1 ] = layout.getY (glyph_index);
695
697
696
698
if (glyph_index == cluster_start_glyph_index)
@@ -770,7 +772,7 @@ void Paragraph::Layout(double width, bool force) {
770
772
771
773
if (at_word_end) {
772
774
if (justify_line) {
773
- justify_x_offset += word_gap_width;
775
+ justify_x_offset_delta += word_gap_width;
774
776
}
775
777
word_index++;
776
778
@@ -787,9 +789,11 @@ void Paragraph::Layout(double width, bool force) {
787
789
continue ;
788
790
SkFontMetrics metrics;
789
791
font.getMetrics (&metrics);
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 ());
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;
793
797
794
798
line_glyph_positions.insert (line_glyph_positions.end (),
795
799
glyph_positions.begin (),
@@ -1050,13 +1054,7 @@ void Paragraph::PaintDecorations(SkCanvas* canvas,
1050
1054
// Filled when drawing wavy decorations.
1051
1055
SkPath path;
1052
1056
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
- }
1057
+ double width = record.GetRunWidth ();
1060
1058
1061
1059
SkScalar underline_thickness;
1062
1060
if ((metrics.fFlags &
0 commit comments