summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorRoozbeh Pournader <roozbeh@google.com>2017-03-06 19:19:06 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-03-06 19:19:11 +0000
commitb85f02e9add59192b4d45ec3b52f9c01747edfc2 (patch)
tree2825ddaad0e103c1861af72ae5c675aedc0cb309 /core/java/android
parent272fe5c33866ccc9f590e8fa383f7d96577f8068 (diff)
parent46c6f4c5ea7846fee4e6ef40c035ef2bee1adcbb (diff)
Merge "Frameworks support for hyphenation for various complex cases"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/text/TextLine.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java
index fcff9a2e5fca..756e9a0e2f2a 100644
--- a/core/java/android/text/TextLine.java
+++ b/core/java/android/text/TextLine.java
@@ -852,6 +852,18 @@ class TextLine {
return runIsRtl ? -ret : ret;
}
+ private int adjustHyphenEdit(int start, int limit, int hyphenEdit) {
+ int result = hyphenEdit;
+ // Only draw hyphens on first or last run in line. Disable them otherwise.
+ if (start > 0) { // not the first run
+ result &= ~Paint.HYPHENEDIT_MASK_START_OF_LINE;
+ }
+ if (limit < mLen) { // not the last run
+ result &= ~Paint.HYPHENEDIT_MASK_END_OF_LINE;
+ }
+ return result;
+ }
+
/**
* Utility function for handling a unidirectional run. The run must not
* contain tabs but can contain styles.
@@ -893,9 +905,9 @@ class TextLine {
if (mSpanned == null) {
TextPaint wp = mWorkPaint;
wp.set(mPaint);
- final int mlimit = measureLimit;
+ wp.setHyphenEdit(adjustHyphenEdit(start, limit, wp.getHyphenEdit()));
return handleText(wp, start, limit, start, limit, runIsRtl, c, x, top,
- y, bottom, fmi, needWidth || mlimit < measureLimit, mlimit);
+ y, bottom, fmi, needWidth, measureLimit);
}
mMetricAffectingSpanSpanSet.init(mSpanned, mStart + start, mStart + limit);
@@ -953,10 +965,8 @@ class TextLine {
span.updateDrawState(wp);
}
- // Only draw hyphen on last run in line
- if (jnext < mLen) {
- wp.setHyphenEdit(0);
- }
+ wp.setHyphenEdit(adjustHyphenEdit(j, jnext, wp.getHyphenEdit()));
+
x += handleText(wp, j, jnext, i, inext, runIsRtl, c, x,
top, y, bottom, fmi, needWidth || jnext < measureLimit, offset);
}