From e4c9fad5aee5eead748717188dc7e1c36360287c Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 24 Oct 2017 14:35:02 -0700 Subject: [PATCH] libtxt: insert a placeholder paint record representing the font metrics of an empty run (flutter/engine#4272) --- .../src/flutter/third_party/txt/src/txt/paragraph.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/engine/src/flutter/third_party/txt/src/txt/paragraph.cc b/engine/src/flutter/third_party/txt/src/txt/paragraph.cc index a59d5d19a0e..8a543c22f9a 100644 --- a/engine/src/flutter/third_party/txt/src/txt/paragraph.cc +++ b/engine/src/flutter/third_party/txt/src/txt/paragraph.cc @@ -380,6 +380,17 @@ void Paragraph::Layout(double width, bool force) { layout.doLayout(text_ptr, 0, text_count, text_count, bidiFlags, font, minikin_paint, minikin_font_collection); + if (layout.nGlyphs() == 0) { + // This run is empty, so insert a placeholder paint record that captures + // the current font metrics. + SkPaint::FontMetrics metrics; + paint.getFontMetrics(&metrics); + paint_records.emplace_back(run.style, SkPoint::Make(run_x_offset, 0), + builder.make(), metrics, line_number, + layout.getAdvance()); + continue; + } + // Break the layout into blobs that share the same SkPaint parameters. std::vector glyph_blobs; for (size_t blob_start = 0; blob_start < layout.nGlyphs();) {