未验证 提交 c9b1e039 编写于 作者: J Jason Simmons 提交者: GitHub

libtxt: be more resilient if the minikin glyphs and the grapheme breaker get out of sync (#4590)

上级 a1e4f2f9
......@@ -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);
}
}
......@@ -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),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册