summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2015-07-20 15:37:54 -0700
committerRaph Levien <raph@google.com>2015-07-20 15:37:54 -0700
commite9ec9a1d1b9e177659b7cc2cd3a102760fcfec14 (patch)
tree5be75c3c3124c9f7667f0bc1f6f024ebabda8117
parentcdd19dadd11a611409c24bb69e6629eab6812d98 (diff)
downloadandroid_frameworks_minikin-e9ec9a1d1b9e177659b7cc2cd3a102760fcfec14.tar.gz
android_frameworks_minikin-e9ec9a1d1b9e177659b7cc2cd3a102760fcfec14.tar.bz2
android_frameworks_minikin-e9ec9a1d1b9e177659b7cc2cd3a102760fcfec14.zip
Consistently apply break opportunities in text spans
It's essential not to apply a break opportunity within a replacement span, otherwise things can happen such as displaying the span twice. The old code tested this case based on zero-width characters. However, this test was both imprecise, and also in some cases read uninitialized values from the mCharWidths array, which in turn led to inconsistent line breaking of the same text. This patch applies all line break opportunities (as identified by ICU) within text (as opposed to replacement spans), and also applies break opportunities at the beginning and end of replacement spans, but avoids breaks within a replacement span. Bug: 20138621 Change-Id: I36baeb44d6808356649e1bb69ca57f093fc8c723
-rw-r--r--libs/minikin/LineBreaker.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libs/minikin/LineBreaker.cpp b/libs/minikin/LineBreaker.cpp
index 72e5c18..a832ca2 100644
--- a/libs/minikin/LineBreaker.cpp
+++ b/libs/minikin/LineBreaker.cpp
@@ -214,8 +214,8 @@ float LineBreaker::addStyleRun(MinikinPaint* paint, const FontCollection* typefa
// Skip hyphenating the next word if and only if the present word ends in a hyphen
temporarilySkipHyphenation = wordEndsInHyphen;
- // Skip break for zero-width characters.
- if (current == mTextBuf.size() || mCharWidths[current] > 0) {
+ // Skip break for zero-width characters inside replacement span
+ if (paint != nullptr || current == end || mCharWidths[current] > 0) {
addWordBreak(current, mWidth, postBreak, 0.0, 0);
}
lastBreak = current;