diff options
| author | Roozbeh Pournader <roozbeh@google.com> | 2017-05-24 09:07:52 -0700 |
|---|---|---|
| committer | Roozbeh Pournader <roozbeh@google.com> | 2017-06-01 16:45:33 -0700 |
| commit | 538de5bb3b3662c51c17cd9dd24e660c85e88b78 (patch) | |
| tree | 7ad94ecd9e84f072e55b2356d6227c38dafe05e0 /core/java/android/text/TextPaint.java | |
| parent | 1cdf223a0e968ead15d37cfb83f9c1ea88a54d6c (diff) | |
Make underlining spans independent of actual class
Previously, we had singled out UnderlineSpan for special treatment
for proper kerning at span boundaries. That had the limitation that
any other span that used underlining, or even subclasses of
UnderlineSpan were not getting the fix.
With this CL, we actually look at all the effects of applying a
span's updateDrawState() and if the changes were only in underlining,
we merge the pieces and call handleText() on the merged chunk of
text.
Change-Id: I829162c758192b80594f164d1105699224b627ba
Bug: 32907446
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: cts-tradefed run cts-dev --module CtsWidgetTestCases
Test: manual
Diffstat (limited to 'core/java/android/text/TextPaint.java')
| -rw-r--r-- | core/java/android/text/TextPaint.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/core/java/android/text/TextPaint.java b/core/java/android/text/TextPaint.java index 4f8cff0fd7c2..1b062cf8adcf 100644 --- a/core/java/android/text/TextPaint.java +++ b/core/java/android/text/TextPaint.java @@ -17,6 +17,7 @@ package android.text; import android.annotation.ColorInt; +import android.annotation.NonNull; import android.graphics.Paint; /** @@ -40,7 +41,7 @@ public class TextPaint extends Paint { @ColorInt public int underlineColor = 0; /** - * Defined as a multiplier of the default underline thickness. Use 1.0f for default thickness. + * Thickness of the underline, in pixels. * @hide */ public float underlineThickness; @@ -74,6 +75,24 @@ public class TextPaint extends Paint { } /** + * Returns true if all attributes, including the attributes inherited from Paint, are equal. + * + * The caller is expected to have checked the trivial cases, like the pointers being equal, + * the objects having different classes, or the parameter being null. + * @hide + */ + public boolean hasEqualAttributes(@NonNull TextPaint other) { + return bgColor == other.bgColor + && baselineShift == other.baselineShift + && linkColor == other.linkColor + && drawableState == other.drawableState + && density == other.density + && underlineColor == other.underlineColor + && underlineThickness == other.underlineThickness + && super.hasEqualAttributes((Paint) other); + } + + /** * Defines a custom underline for this Paint. * @param color underline solid color * @param thickness underline thickness |
