summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2016-02-18 10:27:38 -0800
committerThe Android Automerger <android-build@google.com>2016-02-18 11:29:37 -0800
commitf6273869d929bf83e72f687303b816714744541f (patch)
treebeb7562d82b21bc3455dbe62c484d56efcbb455e
parent6c62d48fc677042c0bdeace136d2791c2964dbf3 (diff)
downloadandroid_frameworks_minikin-f6273869d929bf83e72f687303b816714744541f.tar.gz
android_frameworks_minikin-f6273869d929bf83e72f687303b816714744541f.tar.bz2
android_frameworks_minikin-f6273869d929bf83e72f687303b816714744541f.zip
Disable hyphenation when word overlaps style boundary
In cases when a word (as defined by the ICU break iterator) overlaps a style boundary, the returned wordStart can be extend before the range currently being measured for layout. When we try to hyphenate the resulting substrings, we get a negative range, which crashes. This patch disables hyphenation in this case. Bug: 27237112 Change-Id: I76d04b39dd3b4d6d267aaaf4bebc9ab361891646
-rw-r--r--libs/minikin/LineBreaker.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libs/minikin/LineBreaker.cpp b/libs/minikin/LineBreaker.cpp
index 9cf07d5..22c3954 100644
--- a/libs/minikin/LineBreaker.cpp
+++ b/libs/minikin/LineBreaker.cpp
@@ -174,7 +174,8 @@ float LineBreaker::addStyleRun(MinikinPaint* paint, const FontCollection* typefa
if (paint != nullptr && mHyphenator != nullptr &&
mHyphenationFrequency != kHyphenationFrequency_None &&
!wordEndsInHyphen && !temporarilySkipHyphenation &&
- wordEnd > wordStart && wordEnd - wordStart <= LONGEST_HYPHENATED_WORD) {
+ wordStart >= start && wordEnd > wordStart &&
+ wordEnd - wordStart <= LONGEST_HYPHENATED_WORD) {
mHyphenator->hyphenate(&mHyphBuf, &mTextBuf[wordStart], wordEnd - wordStart);
#if VERBOSE_DEBUG
std::string hyphenatedString;