diff options
| author | 2018-09-04 17:41:43 -0700 | |
|---|---|---|
| committer | 2018-09-05 10:31:22 -0700 | |
| commit | 3ffe6176b62cfaecb4743c89ff405b73245ae9ae (patch) | |
| tree | 1c0048456af94d854d30201fdc49f1e1322f0724 | |
| parent | e33adca15efee39a41d378ffda4815ea768f1376 (diff) | |
Make text related Paint API public
Following APIs are used by the text stack, and there is no reason for
them to be hidden. Make them public.
- getStrikeThruPosition
- getStrikeThruThickness
- getUnderlinePosition
- getUnderlineThickness
- getWordSpacing
- setWordSpacing
Bug: 112327179
Test: m docs
Test: atest android.graphics.cts.PaintTest
Change-Id: I651a5d620968fedcff2059e0e0694aa4ee770014
| -rwxr-xr-x | api/current.txt | 6 | ||||
| -rw-r--r-- | graphics/java/android/graphics/Paint.java | 84 |
2 files changed, 67 insertions, 23 deletions
diff --git a/api/current.txt b/api/current.txt index f750e33a9610..257291487268 100755 --- a/api/current.txt +++ b/api/current.txt @@ -13984,6 +13984,8 @@ package android.graphics { method public float getRunAdvance(char[], int, int, int, int, boolean, int); method public float getRunAdvance(java.lang.CharSequence, int, int, int, int, boolean, int); method public android.graphics.Shader getShader(); + method public float getStrikeThruPosition(); + method public float getStrikeThruThickness(); method public android.graphics.Paint.Cap getStrokeCap(); method public android.graphics.Paint.Join getStrokeJoin(); method public float getStrokeMiter(); @@ -14004,6 +14006,9 @@ package android.graphics { method public int getTextWidths(java.lang.String, int, int, float[]); method public int getTextWidths(java.lang.String, float[]); method public android.graphics.Typeface getTypeface(); + method public float getUnderlinePosition(); + method public float getUnderlineThickness(); + method public float getWordSpacing(); method public android.graphics.Xfermode getXfermode(); method public boolean hasGlyph(java.lang.String); method public final boolean isAntiAlias(); @@ -14055,6 +14060,7 @@ package android.graphics { method public void setTextSkewX(float); method public android.graphics.Typeface setTypeface(android.graphics.Typeface); method public void setUnderlineText(boolean); + method public void setWordSpacing(float); method public android.graphics.Xfermode setXfermode(android.graphics.Xfermode); field public static final int ANTI_ALIAS_FLAG = 1; // 0x1 field public static final int DEV_KERN_TEXT_FLAG = 256; // 0x100 diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index 9dab53680aa9..7fc178738055 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -18,6 +18,7 @@ package android.graphics; import android.annotation.ColorInt; import android.annotation.NonNull; +import android.annotation.Px; import android.annotation.Size; import android.annotation.UnsupportedAppUsage; import android.graphics.fonts.FontVariationAxis; @@ -805,25 +806,39 @@ public class Paint { * Helper for getFlags(), returning true if UNDERLINE_TEXT_FLAG bit is set * * @return true if the underlineText bit is set in the paint's flags. + * @see #getUnderlinePosition() + * @see #getUnderlineThickness() + * @see #setUnderlineText(boolean) */ public final boolean isUnderlineText() { return (getFlags() & UNDERLINE_TEXT_FLAG) != 0; } /** - * Distance from top of the underline to the baseline. Positive values mean below the baseline. - * This method returns where the underline should be drawn independent of if the underlineText - * bit is set at the moment. - * @hide + * Returns the distance from top of the underline to the baseline in pixels. + * + * The result is positive for positions that are below the baseline. + * This method returns where the underline should be drawn independent of if the {@link + * #UNDERLINE_TEXT_FLAG} bit is set. + * + * @return the position of the underline in pixels + * @see #isUnderlineText() + * @see #getUnderlineThickness() + * @see #setUnderlineText(boolean) */ - public float getUnderlinePosition() { + public @Px float getUnderlinePosition() { return nGetUnderlinePosition(mNativePaint); } /** - * @hide + * Returns the thickness of the underline in pixels. + * + * @return the thickness of the underline in pixels + * @see #isUnderlineText() + * @see #getUnderlinePosition() + * @see #setUnderlineText(boolean) */ - public float getUnderlineThickness() { + public @Px float getUnderlineThickness() { return nGetUnderlineThickness(mNativePaint); } @@ -832,6 +847,9 @@ public class Paint { * * @param underlineText true to set the underlineText bit in the paint's * flags, false to clear it. + * @see #isUnderlineText() + * @see #getUnderlinePosition() + * @see #getUnderlineThickness() */ public void setUnderlineText(boolean underlineText) { nSetUnderlineText(mNativePaint, underlineText); @@ -840,26 +858,40 @@ public class Paint { /** * Helper for getFlags(), returning true if STRIKE_THRU_TEXT_FLAG bit is set * - * @return true if the strikeThruText bit is set in the paint's flags. + * @return true if the {@link #STRIKE_THRU_TEXT_FLAG} bit is set in the paint's flags. + * @see #getStrikeThruPosition() + * @see #getStrikeThruThickness() + * @see #setStrikeThruText(boolean) */ public final boolean isStrikeThruText() { return (getFlags() & STRIKE_THRU_TEXT_FLAG) != 0; } /** - * Distance from top of the strike-through line to the baseline. Negative values mean above the - * baseline. This method returns where the strike-through line should be drawn independent of if - * the strikeThruText bit is set at the moment. - * @hide + * Distance from top of the strike-through line to the baseline in pixels. + * + * The result is negative for positions that are above the baseline. + * This method returns where the strike-through line should be drawn independent of if the + * {@link #STRIKE_THRU_TEXT_FLAG} bit is set. + * + * @return the position of the strike-through line in pixels + * @see #getStrikeThruThickness() + * @see #setStrikeThruText(boolean) + * @see #isStrikeThruText() */ - public float getStrikeThruPosition() { + public @Px float getStrikeThruPosition() { return nGetStrikeThruPosition(mNativePaint); } /** - * @hide + * Returns the thickness of the strike-through line in pixels. + * + * @return the position of the strike-through line in pixels + * @see #getStrikeThruPosition() + * @see #setStrikeThruText(boolean) + * @see #isStrikeThruText() */ - public float getStrikeThruThickness() { + public @Px float getStrikeThruThickness() { return nGetStrikeThruThickness(mNativePaint); } @@ -868,6 +900,9 @@ public class Paint { * * @param strikeThruText true to set the strikeThruText bit in the paint's * flags, false to clear it. + * @see #getStrikeThruPosition() + * @see #getStrikeThruThickness() + * @see #isStrikeThruText() */ public void setStrikeThruText(boolean strikeThruText) { nSetStrikeThruText(mNativePaint, strikeThruText); @@ -1560,22 +1595,25 @@ public class Paint { } /** - * Return the paint's word-spacing for text. The default value is 0. + * Return the paint's extra word-spacing for text. * - * @return the paint's word-spacing for drawing text. - * @hide + * The default value is 0. + * + * @return the paint's extra word-spacing for drawing text in pixels. + * @see #setWordSpacing(float) */ public float getWordSpacing() { return nGetWordSpacing(mNativePaint); } /** - * Set the paint's word-spacing for text. The default value is 0. - * The value is in pixels (note the units are not the same as for - * letter-spacing). + * Set the paint's extra word-spacing for text. * - * @param wordSpacing set the paint's word-spacing for drawing text. - * @hide + * Increases the white space width between words with the given amount of pixels. + * The default value is 0. + * + * @param wordSpacing set the paint's extra word-spacing for drawing text in pixels. + * @see #getWordSpacing() */ public void setWordSpacing(float wordSpacing) { nSetWordSpacing(mNativePaint, wordSpacing); |