summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2016-02-18 10:27:38 -0800
committerRaph Levien <raph@google.com>2016-02-18 10:33:14 -0800
commitaa736d00548da691e75a09a70deb886e1f68b060 (patch)
tree29716607cd8c19ad2756237f76a9aee71397872a
parentbcb024df56c8ae7a5914d6f060ac99a2b5d118d9 (diff)
downloadandroid_frameworks_minikin-aa736d00548da691e75a09a70deb886e1f68b060.tar.gz
android_frameworks_minikin-aa736d00548da691e75a09a70deb886e1f68b060.tar.bz2
android_frameworks_minikin-aa736d00548da691e75a09a70deb886e1f68b060.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;