From 1b3bfb262437625ca4e6efb93b7b90543d6b5ec3 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Tue, 30 Jun 2015 10:15:43 -0700 Subject: [PATCH] Allow clusters to start with zero-width characters The logic in getRunAdvance() assumed that any zero-width character was part of the preceding cluster, which is valid most of the time. However, characters such as ZWNBSP (U+FEFF) renders as a zero width glyph and is also a grapheme cluster boundary. This patch adds a clause to handle that case. Bug: 22121742 Change-Id: Iad79a7d988bded1ef05f0fd7905d20669ea22051 --- engine/src/flutter/libs/minikin/Measurement.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/libs/minikin/Measurement.cpp b/engine/src/flutter/libs/minikin/Measurement.cpp index 0b68ac5f64..a7bc64bea1 100644 --- a/engine/src/flutter/libs/minikin/Measurement.cpp +++ b/engine/src/flutter/libs/minikin/Measurement.cpp @@ -41,7 +41,8 @@ static float getRunAdvance(Layout& layout, const uint16_t* buf, size_t layoutSta clusterWidth = charAdvance; } } - if (offset < start + count && layout.getCharAdvance(offset - layoutStart) == 0.0f) { + if (offset < start + count && layout.getCharAdvance(offset - layoutStart) == 0.0f && + !GraphemeBreak::isGraphemeBreak(buf, start, count, offset)) { // In the middle of a cluster, distribute width of cluster so that each grapheme cluster // gets an equal share. // TODO: get caret information out of font when that's available