OSDN Git Service

Make ellipsize retry if text doesn't fit
authorRoozbeh Pournader <roozbeh@google.com>
Tue, 25 Jul 2017 20:52:57 +0000 (13:52 -0700)
committerRoozbeh Pournader <roozbeh@google.com>
Wed, 2 Aug 2017 00:58:30 +0000 (17:58 -0700)
commit1051bbe325a2fac9d5b074367d878318e2326485
treeaef55a8c581465fb44dcfdd1f038cf88f75394b3
parent8b7053dd455958761e03082ead98b22c52020a98
Make ellipsize retry if text doesn't fit

This fixes the cases where the replacement of parts of text with
ellipsis may result in more-than-expected width of text due to
contextual width changes in the font, such as kerning or Arabic
shaping.

The calculations in TextUtils.ellipsize() and StaticLayout are fixed
to recalculate the new width and reduce it further until the text
actuall fits. BoringLayout and DynamicLayout get fixed too since
they use the other two implementations indirectly.

Also reverse a recently-introduced incorrect check for
multi-character ellipsis in Layout.java.

Fixes: 31537595
Fixes: 64156587
Test: Manual (Arabic edge cases ellipsize correctly)
Test: bit CtsTextTestCases:*
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit CtsWidgetTestCases:android.widget.cts.EditTextTest
Test: bit CtsWidgetTestCases:android.widget.cts.CheckedTextViewTest
Test: bit CtsWidgetTestCases:android.widget.cts.AutoCompleteTextViewTest
Test: bit CtsWidgetTestCases:android.widget.cts.MultiAutoCompleteTextViewTest
Test: bit FrameworksCoreTests:android.text.
Test: adb shell am instrument -w com.android.documentsui.tests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I74fdaa9bf32dc2064eeb702f7f9b78b2bb856c26
core/java/android/text/Layout.java
core/java/android/text/StaticLayout.java
core/java/android/text/TextUtils.java
graphics/java/android/graphics/Paint.java