Skip to content

Commit

Permalink
libtxt: be more resilient if the minikin glyphs and the grapheme brea…
Browse files Browse the repository at this point in the history
…ker get out of sync (flutter#4590)
  • Loading branch information
jason-simmons authored Jan 26, 2018
1 parent a1e4f2f commit c9b1e03
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions third_party/txt/src/txt/paragraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,17 +545,23 @@ void Paragraph::Layout(double width, bool force) {
int32_t next_grapheme;
if (run.is_rtl()) {
next_grapheme = grapheme_breaker_->previous();
if (next_grapheme == icu::BreakIterator::DONE)
break;
subglyph_code_unit_counts.push_back(current_grapheme -
next_grapheme);
} else {
next_grapheme = grapheme_breaker_->next();
if (next_grapheme == icu::BreakIterator::DONE)
break;
subglyph_code_unit_counts.push_back(next_grapheme -
current_grapheme);
while (next_grapheme < static_cast<int32_t>(text_count)) {
if (layout.getCharAdvance(next_grapheme) != 0)
break;
size_t sub_grapheme = grapheme_breaker_->current();
next_grapheme = grapheme_breaker_->next();
if (grapheme_breaker_->next() == icu::BreakIterator::DONE)
break;
size_t sub_grapheme = next_grapheme;
next_grapheme = grapheme_breaker_->current();
subglyph_code_unit_counts.push_back(next_grapheme - sub_grapheme);
}
}
Expand Down Expand Up @@ -590,6 +596,9 @@ void Paragraph::Layout(double width, bool force) {
}
}

if (glyph_positions.empty())
continue;

SkPaint::FontMetrics metrics;
paint.getFontMetrics(&metrics);
paint_records.emplace_back(run.style(), SkPoint::Make(run_x_offset, 0),
Expand Down

0 comments on commit c9b1e03

Please sign in to comment.