summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2015-06-30 10:15:43 -0700
committerRaph Levien <raph@google.com>2015-06-30 10:15:43 -0700
commit3e0fc64da064b8c4156daf53242b8eeb47830f64 (patch)
tree3f6719300c3494497a3ae8ceaa23d2e8f1a443d0
parent91425f0564581e258d3f9b2f44d13f3b6d7a60ea (diff)
downloadandroid_frameworks_minikin-3e0fc64da064b8c4156daf53242b8eeb47830f64.tar.gz
android_frameworks_minikin-3e0fc64da064b8c4156daf53242b8eeb47830f64.tar.bz2
android_frameworks_minikin-3e0fc64da064b8c4156daf53242b8eeb47830f64.zip
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
-rw-r--r--libs/minikin/Measurement.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libs/minikin/Measurement.cpp b/libs/minikin/Measurement.cpp
index 0b68ac5..a7bc64b 100644
--- a/libs/minikin/Measurement.cpp
+++ b/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