Skip to content

Commit 8c0326b

Browse files
committed
Revert "libtxt: more accurate tracking of run positioning and width for justified text (flutter#8214)"
This reverts commit 29860cd.
1 parent b0696f7 commit 8c0326b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

third_party/txt/src/txt/paragraph.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,6 @@ void Paragraph::Layout(double width, bool force) {
677677
const SkTextBlobBuilder::RunBuffer& blob_buffer =
678678
builder.allocRunPos(font, glyph_blob.end - glyph_blob.start);
679679

680-
double justify_x_offset_delta = 0;
681-
682680
for (size_t glyph_index = glyph_blob.start;
683681
glyph_index < glyph_blob.end;) {
684682
size_t cluster_start_glyph_index = glyph_index;
@@ -692,7 +690,7 @@ void Paragraph::Layout(double width, bool force) {
692690

693691
size_t pos_index = blob_index * 2;
694692
blob_buffer.pos[pos_index] =
695-
layout.getX(glyph_index) + justify_x_offset_delta;
693+
layout.getX(glyph_index) + justify_x_offset;
696694
blob_buffer.pos[pos_index + 1] = layout.getY(glyph_index);
697695

698696
if (glyph_index == cluster_start_glyph_index)
@@ -772,7 +770,7 @@ void Paragraph::Layout(double width, bool force) {
772770

773771
if (at_word_end) {
774772
if (justify_line) {
775-
justify_x_offset_delta += word_gap_width;
773+
justify_x_offset += word_gap_width;
776774
}
777775
word_index++;
778776

@@ -789,11 +787,9 @@ void Paragraph::Layout(double width, bool force) {
789787
continue;
790788
SkFontMetrics metrics;
791789
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());
797793

798794
line_glyph_positions.insert(line_glyph_positions.end(),
799795
glyph_positions.begin(),
@@ -1054,7 +1050,13 @@ void Paragraph::PaintDecorations(SkCanvas* canvas,
10541050
// Filled when drawing wavy decorations.
10551051
SkPath path;
10561052

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+
}
10581060

10591061
SkScalar underline_thickness;
10601062
if ((metrics.fFlags &

0 commit comments

Comments
 (0)