diff options
Diffstat (limited to 'core/java/android/text')
| -rw-r--r-- | core/java/android/text/TextLine.java | 40 | ||||
| -rw-r--r-- | core/java/android/text/TextPaint.java | 27 |
2 files changed, 42 insertions, 25 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index ad7a851926a1..a182fe80dfbf 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -1231,7 +1231,7 @@ public class TextLine { // with the next chunk. So we just save the TextPaint for future comparisons // and use. activePaint.set(wp); - } else if (!wp.hasEqualAttributes(activePaint)) { + } else if (!equalAttributes(wp, activePaint)) { // The style of the present chunk of text is substantially different from the // style of the previous chunk. We need to handle the active piece of text // and restart with the present chunk. @@ -1336,4 +1336,42 @@ public class TextLine { } private static final int TAB_INCREMENT = 20; + + private static boolean equalAttributes(@NonNull TextPaint lp, @NonNull TextPaint rp) { + return lp.getColorFilter() == rp.getColorFilter() + && lp.getMaskFilter() == rp.getMaskFilter() + && lp.getShader() == rp.getShader() + && lp.getTypeface() == rp.getTypeface() + && lp.getXfermode() == rp.getXfermode() + && lp.getTextLocales().equals(rp.getTextLocales()) + && TextUtils.equals(lp.getFontFeatureSettings(), rp.getFontFeatureSettings()) + && TextUtils.equals(lp.getFontVariationSettings(), rp.getFontVariationSettings()) + && lp.getShadowLayerRadius() == rp.getShadowLayerRadius() + && lp.getShadowLayerDx() == rp.getShadowLayerDx() + && lp.getShadowLayerDy() == rp.getShadowLayerDy() + && lp.getShadowLayerColor() == rp.getShadowLayerColor() + && lp.getFlags() == rp.getFlags() + && lp.getHinting() == rp.getHinting() + && lp.getStyle() == rp.getStyle() + && lp.getColor() == rp.getColor() + && lp.getStrokeWidth() == rp.getStrokeWidth() + && lp.getStrokeMiter() == rp.getStrokeMiter() + && lp.getStrokeCap() == rp.getStrokeCap() + && lp.getStrokeJoin() == rp.getStrokeJoin() + && lp.getTextAlign() == rp.getTextAlign() + && lp.isElegantTextHeight() == rp.isElegantTextHeight() + && lp.getTextSize() == rp.getTextSize() + && lp.getTextScaleX() == rp.getTextScaleX() + && lp.getTextSkewX() == rp.getTextSkewX() + && lp.getLetterSpacing() == rp.getLetterSpacing() + && lp.getWordSpacing() == rp.getWordSpacing() + && lp.getHyphenEdit() == rp.getHyphenEdit() + && lp.bgColor == rp.bgColor + && lp.baselineShift == rp.baselineShift + && lp.linkColor == rp.linkColor + && lp.drawableState == rp.drawableState + && lp.density == rp.density + && lp.underlineColor == rp.underlineColor + && lp.underlineThickness == rp.underlineThickness; + } } diff --git a/core/java/android/text/TextPaint.java b/core/java/android/text/TextPaint.java index 7bcc6859b8fc..d5aad33a85e7 100644 --- a/core/java/android/text/TextPaint.java +++ b/core/java/android/text/TextPaint.java @@ -17,7 +17,7 @@ package android.text; import android.annotation.ColorInt; -import android.annotation.NonNull; +import android.annotation.Px; import android.annotation.UnsupportedAppUsage; import android.graphics.Paint; @@ -37,17 +37,14 @@ public class TextPaint extends Paint { public float density = 1.0f; /** * Special value 0 means no custom underline - * @hide */ @ColorInt - @UnsupportedAppUsage public int underlineColor = 0; + /** * Thickness of the underline, in pixels. - * @hide */ - @UnsupportedAppUsage - public float underlineThickness; + public @Px float underlineThickness; public TextPaint() { super(); @@ -78,24 +75,6 @@ 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 |
