Modifier and Type | Class and Description |
---|---|
static class |
Paint.Align
Align specifies how drawText aligns its text relative to the
[x,y] coordinates.
|
static class |
Paint.Cap
The Cap specifies the treatment for the beginning and ending of
stroked lines and paths.
|
static class |
Paint.FontMetrics
Class that describes the various metrics for a font at a given text size.
|
static class |
Paint.FontMetricsInt
Convenience method for callers that want to have FontMetrics values as
integers.
|
static class |
Paint.Join
The Join specifies the treatment where lines and curve segments
join on a stroked path.
|
static class |
Paint.Style
The Style specifies if the primitive being drawn is filled, stroked, or
both (in the same color).
|
Modifier and Type | Field and Description |
---|---|
static int |
ANTI_ALIAS_FLAG
bit mask for the flag enabling antialiasing
|
static int |
BIDI_DEFAULT_LTR
Bidi flag to detect paragraph direction via heuristics, defaulting to
LTR.
|
static int |
BIDI_DEFAULT_RTL
Bidi flag to detect paragraph direction via heuristics, defaulting to
RTL.
|
static int |
BIDI_FORCE_LTR
Bidi flag to override direction to all LTR (ignore bidi).
|
static int |
BIDI_FORCE_RTL
Bidi flag to override direction to all RTL (ignore bidi).
|
static int |
BIDI_LTR
Bidi flag to set LTR paragraph direction.
|
static int |
BIDI_RTL
Bidi flag to set RTL paragraph direction.
|
static int |
CURSOR_AFTER
Option for getTextRunCursor to compute the valid cursor after
offset or the limit of the context, whichever is less.
|
static int |
CURSOR_AT
Option for getTextRunCursor to return offset if the cursor at offset
is valid, or -1 if it isn't.
|
static int |
CURSOR_AT_OR_AFTER
Option for getTextRunCursor to compute the valid cursor at or after
the offset or the limit of the context, whichever is less.
|
static int |
CURSOR_AT_OR_BEFORE
Option for getTextRunCursor to compute the valid cursor at or before
offset or the start of the context, whichever is greater.
|
static int |
CURSOR_BEFORE
Option for getTextRunCursor to compute the valid cursor before
offset or the start of the context, whichever is greater.
|
static int |
DEV_KERN_TEXT_FLAG
bit mask for the flag enabling device kerning for text
|
static int |
DIRECTION_LTR
Flag for getTextRunAdvances indicating left-to-right run direction.
|
static int |
DIRECTION_RTL
Flag for getTextRunAdvances indicating right-to-left run direction.
|
static int |
DITHER_FLAG
bit mask for the flag enabling dithering
|
static int |
FAKE_BOLD_TEXT_FLAG
bit mask for the flag enabling fake-bold text
|
static int |
FILTER_BITMAP_FLAG
bit mask for the flag enabling bitmap filtering
|
boolean |
hasShadow |
static int |
HINTING_OFF
Option for
setHinting(int) : disable hinting. |
static int |
HINTING_ON
Option for
setHinting(int) : enable hinting. |
static int |
LINEAR_TEXT_FLAG
bit mask for the flag enabling linear-text (no caching)
|
int |
mBidiFlags |
int |
mNativePaint |
int |
shadowColor |
float |
shadowDx |
float |
shadowDy |
float |
shadowRadius |
static int |
STRIKE_THRU_TEXT_FLAG
bit mask for the flag enabling strike-thru text
|
static int |
SUBPIXEL_TEXT_FLAG
bit mask for the flag enabling subpixel-text
|
static int |
UNDERLINE_TEXT_FLAG
bit mask for the flag enabling underline text
|
Constructor and Description |
---|
Paint()
Create a new paint with default settings.
|
Paint(int flags)
Create a new paint with the specified flags.
|
Paint(Paint paint)
Create a new paint, initialized with the attributes in the specified
paint parameter.
|
Modifier and Type | Method and Description |
---|---|
float |
ascent()
Return the distance above (negative) the baseline (ascent) based on the
current typeface and text size.
|
int |
breakText(char[] text,
int index,
int count,
float maxWidth,
float[] measuredWidth)
Measure the text, stopping early if the measured width exceeds maxWidth.
|
int |
breakText(CharSequence text,
int start,
int end,
boolean measureForwards,
float maxWidth,
float[] measuredWidth)
Measure the text, stopping early if the measured width exceeds maxWidth.
|
int |
breakText(String text,
boolean measureForwards,
float maxWidth,
float[] measuredWidth)
Measure the text, stopping early if the measured width exceeds maxWidth.
|
void |
clearShadowLayer()
Clear the shadow layer.
|
float |
descent()
Return the distance below (positive) the baseline (descent) based on the
current typeface and text size.
|
protected void |
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
int |
getAlpha()
Helper to getColor() that just returns the color's alpha value.
|
int |
getBidiFlags()
Return the bidi flags on the paint.
|
int |
getColor()
Return the paint's color.
|
ColorFilter |
getColorFilter()
Get the paint's colorfilter (maybe be null).
|
boolean |
getFillPath(Path src,
Path dst)
Applies any/all effects (patheffect, stroking) to src, returning the
result in dst.
|
int |
getFlags()
Return the paint's flags.
|
Paint.FontMetrics |
getFontMetrics()
Allocates a new FontMetrics object, and then calls getFontMetrics(fm)
with it, returning the object.
|
float |
getFontMetrics(Paint.FontMetrics metrics)
Return the font's recommended interline spacing, given the Paint's
settings for typeface, textSize, etc.
|
Paint.FontMetricsInt |
getFontMetricsInt() |
int |
getFontMetricsInt(Paint.FontMetricsInt fmi)
Return the font's interline spacing, given the Paint's settings for
typeface, textSize, etc.
|
float |
getFontSpacing()
Return the recommend line spacing based on the current typeface and
text size.
|
int |
getHinting()
Return the paint's hinting mode.
|
MaskFilter |
getMaskFilter()
Get the paint's maskfilter object.
|
PathEffect |
getPathEffect()
Get the paint's patheffect object.
|
Rasterizer |
getRasterizer()
Get the paint's rasterizer (or null).
|
Shader |
getShader()
Get the paint's shader object.
|
Paint.Cap |
getStrokeCap()
Return the paint's Cap, controlling how the start and end of stroked
lines and paths are treated.
|
Paint.Join |
getStrokeJoin()
Return the paint's stroke join type.
|
float |
getStrokeMiter()
Return the paint's stroke miter value.
|
float |
getStrokeWidth()
Return the width for stroking.
|
Paint.Style |
getStyle()
Return the paint's style, used for controlling how primitives'
geometries are interpreted (except for drawBitmap, which always assumes
FILL_STYLE).
|
Paint.Align |
getTextAlign()
Return the paint's Align value for drawing text.
|
void |
getTextBounds(char[] text,
int index,
int count,
Rect bounds)
Return in bounds (allocated by the caller) the smallest rectangle that
encloses all of the characters, with an implied origin at (0,0).
|
void |
getTextBounds(String text,
int start,
int end,
Rect bounds)
Return in bounds (allocated by the caller) the smallest rectangle that
encloses all of the characters, with an implied origin at (0,0).
|
int |
getTextGlyphs(String text,
int start,
int end,
int contextStart,
int contextEnd,
int flags,
char[] glyphs)
Return the glyph Ids for the characters in the string.
|
Locale |
getTextLocale()
Get the text Locale.
|
void |
getTextPath(char[] text,
int index,
int count,
float x,
float y,
Path path)
Return the path (outline) for the specified text.
|
void |
getTextPath(String text,
int start,
int end,
float x,
float y,
Path path)
Return the path (outline) for the specified text.
|
float |
getTextRunAdvances(char[] chars,
int index,
int count,
int contextIndex,
int contextCount,
int flags,
float[] advances,
int advancesIndex)
Convenience overload that takes a char array instead of a
String.
|
float |
getTextRunAdvances(char[] chars,
int index,
int count,
int contextIndex,
int contextCount,
int flags,
float[] advances,
int advancesIndex,
int reserved)
Convenience overload that takes a char array instead of a
String.
|
float |
getTextRunAdvances(CharSequence text,
int start,
int end,
int contextStart,
int contextEnd,
int flags,
float[] advances,
int advancesIndex)
Convenience overload that takes a CharSequence instead of a
String.
|
float |
getTextRunAdvances(CharSequence text,
int start,
int end,
int contextStart,
int contextEnd,
int flags,
float[] advances,
int advancesIndex,
int reserved)
Convenience overload that takes a CharSequence instead of a
String.
|
float |
getTextRunAdvances(String text,
int start,
int end,
int contextStart,
int contextEnd,
int flags,
float[] advances,
int advancesIndex)
Returns the total advance width for the characters in the run
between start and end, and if advances is not null, the advance
assigned to each of these characters (java chars).
|
float |
getTextRunAdvances(String text,
int start,
int end,
int contextStart,
int contextEnd,
int flags,
float[] advances,
int advancesIndex,
int reserved)
Returns the total advance width for the characters in the run
between start and end, and if advances is not null, the advance
assigned to each of these characters (java chars).
|
int |
getTextRunCursor(char[] text,
int contextStart,
int contextLength,
int flags,
int offset,
int cursorOpt)
Returns the next cursor position in the run.
|
int |
getTextRunCursor(CharSequence text,
int contextStart,
int contextEnd,
int flags,
int offset,
int cursorOpt)
Returns the next cursor position in the run.
|
int |
getTextRunCursor(String text,
int contextStart,
int contextEnd,
int flags,
int offset,
int cursorOpt)
Returns the next cursor position in the run.
|
float |
getTextScaleX()
Return the paint's horizontal scale factor for text.
|
float |
getTextSize()
Return the paint's text size.
|
float |
getTextSkewX()
Return the paint's horizontal skew factor for text.
|
int |
getTextWidths(char[] text,
int index,
int count,
float[] widths)
Return the advance widths for the characters in the string.
|
int |
getTextWidths(CharSequence text,
int start,
int end,
float[] widths)
Return the advance widths for the characters in the string.
|
int |
getTextWidths(String text,
float[] widths)
Return the advance widths for the characters in the string.
|
int |
getTextWidths(String text,
int start,
int end,
float[] widths)
Return the advance widths for the characters in the string.
|
Typeface |
getTypeface()
Get the paint's typeface object.
|
Xfermode |
getXfermode()
Get the paint's xfermode object.
|
boolean |
isAntiAlias()
Helper for getFlags(), returning true if ANTI_ALIAS_FLAG bit is set
AntiAliasing smooths out the edges of what is being drawn, but is has
no impact on the interior of the shape.
|
boolean |
isDither()
Helper for getFlags(), returning true if DITHER_FLAG bit is set
Dithering affects how colors that are higher precision than the device
are down-sampled.
|
boolean |
isFakeBoldText()
Helper for getFlags(), returning true if FAKE_BOLD_TEXT_FLAG bit is set
|
boolean |
isFilterBitmap()
Whether or not the bitmap filter is activated.
|
boolean |
isLinearText()
Deprecated.
|
boolean |
isStrikeThruText()
Helper for getFlags(), returning true if STRIKE_THRU_TEXT_FLAG bit is set
|
boolean |
isSubpixelText()
Helper for getFlags(), returning true if SUBPIXEL_TEXT_FLAG bit is set
|
boolean |
isUnderlineText()
Helper for getFlags(), returning true if UNDERLINE_TEXT_FLAG bit is set
|
float |
measureText(char[] text,
int index,
int count)
Return the width of the text.
|
float |
measureText(CharSequence text,
int start,
int end)
Return the width of the text.
|
float |
measureText(String text)
Return the width of the text.
|
float |
measureText(String text,
int start,
int end)
Return the width of the text.
|
void |
reset()
Restores the paint to its default settings.
|
void |
set(Paint src)
Copy the fields from src into this paint.
|
void |
setAlpha(int a)
Helper to setColor(), that only assigns the color's alpha value,
leaving its r,g,b values unchanged.
|
void |
setAntiAlias(boolean aa)
Helper for setFlags(), setting or clearing the ANTI_ALIAS_FLAG bit
AntiAliasing smooths out the edges of what is being drawn, but is has
no impact on the interior of the shape.
|
void |
setARGB(int a,
int r,
int g,
int b)
Helper to setColor(), that takes a,r,g,b and constructs the color int
|
void |
setBidiFlags(int flags)
Set the bidi flags on the paint.
|
void |
setColor(int color)
Set the paint's color.
|
ColorFilter |
setColorFilter(ColorFilter filter)
Set or clear the paint's colorfilter, returning the parameter.
|
void |
setCompatibilityScaling(float factor) |
void |
setDither(boolean dither)
Helper for setFlags(), setting or clearing the DITHER_FLAG bit
Dithering affects how colors that are higher precision than the device
are down-sampled.
|
void |
setFakeBoldText(boolean fakeBoldText)
Helper for setFlags(), setting or clearing the FAKE_BOLD_TEXT_FLAG bit
|
void |
setFilterBitmap(boolean filter)
Helper for setFlags(), setting or clearing the FILTER_BITMAP_FLAG bit.
|
void |
setFlags(int flags)
Set the paint's flags.
|
void |
setHinting(int mode)
Set the paint's hinting mode.
|
void |
setLinearText(boolean linearText)
Deprecated.
|
MaskFilter |
setMaskFilter(MaskFilter maskfilter)
Set or clear the maskfilter object.
|
PathEffect |
setPathEffect(PathEffect effect)
Set or clear the patheffect object.
|
Rasterizer |
setRasterizer(Rasterizer rasterizer)
Set or clear the rasterizer object.
|
Shader |
setShader(Shader shader)
Set or clear the shader object.
|
void |
setShadowLayer(float radius,
float dx,
float dy,
int color)
This draws a shadow layer below the main layer, with the specified
offset and color, and blur radius.
|
void |
setStrikeThruText(boolean strikeThruText)
Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit
|
void |
setStrokeCap(Paint.Cap cap)
Set the paint's Cap.
|
void |
setStrokeJoin(Paint.Join join)
Set the paint's Join.
|
void |
setStrokeMiter(float miter)
Set the paint's stroke miter value.
|
void |
setStrokeWidth(float width)
Set the width for stroking.
|
void |
setStyle(Paint.Style style)
Set the paint's style, used for controlling how primitives'
geometries are interpreted (except for drawBitmap, which always assumes
Fill).
|
void |
setSubpixelText(boolean subpixelText)
Helper for setFlags(), setting or clearing the SUBPIXEL_TEXT_FLAG bit
|
void |
setTextAlign(Paint.Align align)
Set the paint's text alignment.
|
void |
setTextLocale(Locale locale)
Set the text locale.
|
void |
setTextScaleX(float scaleX)
Set the paint's horizontal scale factor for text.
|
void |
setTextSize(float textSize)
Set the paint's text size.
|
void |
setTextSkewX(float skewX)
Set the paint's horizontal skew factor for text.
|
Typeface |
setTypeface(Typeface typeface)
Set or clear the typeface object.
|
void |
setUnderlineText(boolean underlineText)
Helper for setFlags(), setting or clearing the UNDERLINE_TEXT_FLAG bit
|
Xfermode |
setXfermode(Xfermode xfermode)
Set or clear the xfermode object.
|
public int mNativePaint
public boolean hasShadow
public float shadowDx
public float shadowDy
public float shadowRadius
public int shadowColor
public int mBidiFlags
public static final int ANTI_ALIAS_FLAG
public static final int FILTER_BITMAP_FLAG
public static final int DITHER_FLAG
public static final int UNDERLINE_TEXT_FLAG
public static final int STRIKE_THRU_TEXT_FLAG
public static final int FAKE_BOLD_TEXT_FLAG
public static final int LINEAR_TEXT_FLAG
public static final int SUBPIXEL_TEXT_FLAG
public static final int DEV_KERN_TEXT_FLAG
public static final int HINTING_OFF
setHinting(int)
: disable hinting.public static final int HINTING_ON
setHinting(int)
: enable hinting.public static final int BIDI_LTR
public static final int BIDI_RTL
public static final int BIDI_DEFAULT_LTR
public static final int BIDI_DEFAULT_RTL
public static final int BIDI_FORCE_LTR
public static final int BIDI_FORCE_RTL
public static final int DIRECTION_LTR
public static final int DIRECTION_RTL
public static final int CURSOR_AFTER
public static final int CURSOR_AT_OR_AFTER
public static final int CURSOR_BEFORE
public static final int CURSOR_AT_OR_BEFORE
public static final int CURSOR_AT
public Paint()
public Paint(int flags)
flags
- initial flag bits, as if they were passed via setFlags().public Paint(Paint paint)
paint
- Existing paint used to initialized the attributes of the
new paint.public void reset()
public void set(Paint src)
public void setCompatibilityScaling(float factor)
public int getBidiFlags()
public void setBidiFlags(int flags)
public int getFlags()
public void setFlags(int flags)
flags
- The new flag bits for the paintpublic int getHinting()
HINTING_OFF
or HINTING_ON
.public void setHinting(int mode)
HINTING_OFF
or HINTING_ON
.public final boolean isAntiAlias()
public void setAntiAlias(boolean aa)
aa
- true to set the antialias bit in the flags, false to clear itpublic final boolean isDither()
public void setDither(boolean dither)
dither
- true to set the dithering bit in flags, false to clear it@Deprecated public final boolean isLinearText()
@Deprecated public void setLinearText(boolean linearText)
linearText
- true to set the linearText bit in the paint's flags,
false to clear it.public final boolean isSubpixelText()
public void setSubpixelText(boolean subpixelText)
subpixelText
- true to set the subpixelText bit in the paint's
flags, false to clear it.public final boolean isUnderlineText()
public void setUnderlineText(boolean underlineText)
underlineText
- true to set the underlineText bit in the paint's
flags, false to clear it.public final boolean isStrikeThruText()
public void setStrikeThruText(boolean strikeThruText)
strikeThruText
- true to set the strikeThruText bit in the paint's
flags, false to clear it.public final boolean isFakeBoldText()
public void setFakeBoldText(boolean fakeBoldText)
fakeBoldText
- true to set the fakeBoldText bit in the paint's
flags, false to clear it.public final boolean isFilterBitmap()
setFilterBitmap()
public void setFilterBitmap(boolean filter)
filter
- true to set the FILTER_BITMAP_FLAG bit in the paint's
flags, false to clear it.public Paint.Style getStyle()
public void setStyle(Paint.Style style)
style
- The new style to set in the paintpublic int getColor()
public void setColor(int color)
color
- The new color (including alpha) to set in the paint.public int getAlpha()
public void setAlpha(int a)
a
- set the alpha component [0..255] of the paint's color.public void setARGB(int a, int r, int g, int b)
a
- The new alpha component (0..255) of the paint's color.r
- The new red component (0..255) of the paint's color.g
- The new green component (0..255) of the paint's color.b
- The new blue component (0..255) of the paint's color.public float getStrokeWidth()
public void setStrokeWidth(float width)
width
- set the paint's stroke width, used whenever the paint's
style is Stroke or StrokeAndFill.public float getStrokeMiter()
public void setStrokeMiter(float miter)
miter
- set the miter limit on the paint, used whenever the paint's
style is Stroke or StrokeAndFill.public Paint.Cap getStrokeCap()
public void setStrokeCap(Paint.Cap cap)
cap
- set the paint's line cap style, used whenever the paint's
style is Stroke or StrokeAndFill.public Paint.Join getStrokeJoin()
public void setStrokeJoin(Paint.Join join)
join
- set the paint's Join, used whenever the paint's style is
Stroke or StrokeAndFill.public boolean getFillPath(Path src, Path dst)
src
- input pathdst
- output path (may be the same as src)public Shader getShader()
public Shader setShader(Shader shader)
shader
- May be null. the new shader to be installed in the paintpublic ColorFilter getColorFilter()
public ColorFilter setColorFilter(ColorFilter filter)
filter
- May be null. The new filter to be installed in the paintpublic Xfermode getXfermode()
public Xfermode setXfermode(Xfermode xfermode)
xfermode
- May be null. The xfermode to be installed in the paintpublic PathEffect getPathEffect()
public PathEffect setPathEffect(PathEffect effect)
effect
- May be null. The patheffect to be installed in the paintpublic MaskFilter getMaskFilter()
public MaskFilter setMaskFilter(MaskFilter maskfilter)
maskfilter
- May be null. The maskfilter to be installed in the
paintpublic Typeface getTypeface()
public Typeface setTypeface(Typeface typeface)
typeface
- May be null. The typeface to be installed in the paintpublic Rasterizer getRasterizer()
public Rasterizer setRasterizer(Rasterizer rasterizer)
rasterizer
- May be null. The new rasterizer to be installed in
the paint.public void setShadowLayer(float radius, float dx, float dy, int color)
public void clearShadowLayer()
public Paint.Align getTextAlign()
public void setTextAlign(Paint.Align align)
align
- set the paint's Align value for drawing text.public Locale getTextLocale()
public void setTextLocale(Locale locale)
Locale.CHINESE
or Locale.CHINA
,
then the text renderer will prefer to draw text using a Chinese font. Likewise,
if the locale is Locale.JAPANESE
or Locale.JAPAN
, then the text
renderer will prefer to draw text using a Japanese font.
This distinction is important because Chinese and Japanese text both use many
of the same Unicode code points but their appearance is subtly different for
each language.
By default, the text locale is initialized to the system locale (as returned
by Locale.getDefault()
). This assumes that the text to be rendered will
most likely be in the user's preferred language.
If the actual language of the text is known, then it can be provided to the
text renderer using this method. The text renderer may attempt to guess the
language script based on the contents of the text to be drawn independent of
the text locale here. Specifying the text locale just helps it do a better
job in certain ambiguous caseslocale
- the paint's locale value for drawing text, must not be null.public float getTextSize()
public void setTextSize(float textSize)
textSize
- set the paint's text size.public float getTextScaleX()
public void setTextScaleX(float scaleX)
scaleX
- set the paint's scale in X for drawing/measuring text.public float getTextSkewX()
public void setTextSkewX(float skewX)
skewX
- set the paint's skew factor in X for drawing text.public float ascent()
public float descent()
public float getFontMetrics(Paint.FontMetrics metrics)
metrics
- If this object is not null, its fields are filled with
the appropriate values given the paint's text attributes.public Paint.FontMetrics getFontMetrics()
public int getFontMetricsInt(Paint.FontMetricsInt fmi)
public Paint.FontMetricsInt getFontMetricsInt()
public float getFontSpacing()
public float measureText(char[] text, int index, int count)
text
- The text to measure. Cannot be null.index
- The index of the first character to start measuringcount
- THe number of characters to measure, beginning with startpublic float measureText(String text, int start, int end)
text
- The text to measure. Cannot be null.start
- The index of the first character to start measuringend
- 1 beyond the index of the last character to measurepublic float measureText(String text)
text
- The text to measure. Cannot be null.public float measureText(CharSequence text, int start, int end)
text
- The text to measurestart
- The index of the first character to start measuringend
- 1 beyond the index of the last character to measurepublic int breakText(char[] text, int index, int count, float maxWidth, float[] measuredWidth)
text
- The text to measure. Cannot be null.index
- The offset into text to begin measuring atcount
- The number of maximum number of entries to measure. If count
is negative, then the characters are measured in reverse order.maxWidth
- The maximum width to accumulate.measuredWidth
- Optional. If not null, returns the actual width
measured.public int breakText(CharSequence text, int start, int end, boolean measureForwards, float maxWidth, float[] measuredWidth)
text
- The text to measure. Cannot be null.start
- The offset into text to begin measuring atend
- The end of the text slice to measure.measureForwards
- If true, measure forwards, starting at start.
Otherwise, measure backwards, starting with end.maxWidth
- The maximum width to accumulate.measuredWidth
- Optional. If not null, returns the actual width
measured.public int breakText(String text, boolean measureForwards, float maxWidth, float[] measuredWidth)
text
- The text to measure. Cannot be null.measureForwards
- If true, measure forwards, starting with the
first character in the string. Otherwise,
measure backwards, starting with the
last character in the string.maxWidth
- The maximum width to accumulate.measuredWidth
- Optional. If not null, returns the actual width
measured.public int getTextWidths(char[] text, int index, int count, float[] widths)
text
- The text to measure. Cannot be null.index
- The index of the first char to to measurecount
- The number of chars starting with index to measurewidths
- array to receive the advance widths of the characters.
Must be at least a large as count.public int getTextWidths(CharSequence text, int start, int end, float[] widths)
text
- The text to measure. Cannot be null.start
- The index of the first char to to measureend
- The end of the text slice to measurewidths
- array to receive the advance widths of the characters.
Must be at least a large as (end - start).public int getTextWidths(String text, int start, int end, float[] widths)
text
- The text to measure. Cannot be null.start
- The index of the first char to to measureend
- The end of the text slice to measurewidths
- array to receive the advance widths of the characters.
Must be at least a large as the text.public int getTextWidths(String text, float[] widths)
text
- The text to measurewidths
- array to receive the advance widths of the characters.
Must be at least a large as the text.public int getTextGlyphs(String text, int start, int end, int contextStart, int contextEnd, int flags, char[] glyphs)
text
- The text to measurestart
- The index of the first char to to measureend
- The end of the text slice to measurecontextStart
- the index of the first character to use for shaping context,
must be <= startcontextEnd
- the index past the last character to use for shaping context,
must be >= endflags
- the flags to control the advances, either DIRECTION_LTR
or DIRECTION_RTL
glyphs
- array to receive the glyph Ids of the characters.
Must be at least a large as the text.public float getTextRunAdvances(char[] chars, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex)
public float getTextRunAdvances(char[] chars, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex, int reserved)
public float getTextRunAdvances(CharSequence text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex)
public float getTextRunAdvances(CharSequence text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, int reserved)
public float getTextRunAdvances(String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex)
The trailing surrogate in a valid surrogate pair is assigned an advance of 0. Thus the number of returned advances is always equal to count, not to the number of unicode codepoints represented by the run.
In the case of conjuncts or combining marks, the total advance is assigned to the first logical character, and the following characters are assigned an advance of 0.
This generates the sum of the advances of glyphs for characters in a reordered cluster as the width of the first logical character in the cluster, and 0 for the widths of all other characters in the cluster. In effect, such clusters are treated like conjuncts.
The shaping bounds limit the amount of context available outside start and end that can be used for shaping analysis. These bounds typically reflect changes in bidi level or font metrics across which shaping does not occur.
text
- the text to measure. Cannot be null.start
- the index of the first character to measureend
- the index past the last character to measurecontextStart
- the index of the first character to use for shaping context,
must be <= startcontextEnd
- the index past the last character to use for shaping context,
must be >= endflags
- the flags to control the advances, either DIRECTION_LTR
or DIRECTION_RTL
advances
- array to receive the advances, must have room for all advances,
can be null if only total advance is neededadvancesIndex
- the position in advances at which to put the
advance corresponding to the character at startpublic float getTextRunAdvances(String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, int reserved)
The trailing surrogate in a valid surrogate pair is assigned an advance of 0. Thus the number of returned advances is always equal to count, not to the number of unicode codepoints represented by the run.
In the case of conjuncts or combining marks, the total advance is assigned to the first logical character, and the following characters are assigned an advance of 0.
This generates the sum of the advances of glyphs for characters in a reordered cluster as the width of the first logical character in the cluster, and 0 for the widths of all other characters in the cluster. In effect, such clusters are treated like conjuncts.
The shaping bounds limit the amount of context available outside start and end that can be used for shaping analysis. These bounds typically reflect changes in bidi level or font metrics across which shaping does not occur.
text
- the text to measure. Cannot be null.start
- the index of the first character to measureend
- the index past the last character to measurecontextStart
- the index of the first character to use for shaping context,
must be <= startcontextEnd
- the index past the last character to use for shaping context,
must be >= endflags
- the flags to control the advances, either DIRECTION_LTR
or DIRECTION_RTL
advances
- array to receive the advances, must have room for all advances,
can be null if only total advance is neededadvancesIndex
- the position in advances at which to put the
advance corresponding to the character at startreserved
- int reserved valuepublic int getTextRunCursor(char[] text, int contextStart, int contextLength, int flags, int offset, int cursorOpt)
ContextStart and offset are relative to the start of text. The context is the shaping context for cursor movement, generally the bounds of the metric span enclosing the cursor in the direction of movement.
If cursorOpt is CURSOR_AT
and the offset is not a valid
cursor position, this returns -1. Otherwise this will never return a
value before contextStart or after contextStart + contextLength.
text
- the textcontextStart
- the start of the contextcontextLength
- the length of the contextflags
- either DIRECTION_RTL
or DIRECTION_LTR
offset
- the cursor position to move fromcursorOpt
- how to move the cursor, one of CURSOR_AFTER
,
CURSOR_AT_OR_AFTER
, CURSOR_BEFORE
,
CURSOR_AT_OR_BEFORE
, or CURSOR_AT
public int getTextRunCursor(CharSequence text, int contextStart, int contextEnd, int flags, int offset, int cursorOpt)
ContextStart, contextEnd, and offset are relative to the start of text. The context is the shaping context for cursor movement, generally the bounds of the metric span enclosing the cursor in the direction of movement.
If cursorOpt is CURSOR_AT
and the offset is not a valid
cursor position, this returns -1. Otherwise this will never return a
value before contextStart or after contextEnd.
text
- the textcontextStart
- the start of the contextcontextEnd
- the end of the contextflags
- either DIRECTION_RTL
or DIRECTION_LTR
offset
- the cursor position to move fromcursorOpt
- how to move the cursor, one of CURSOR_AFTER
,
CURSOR_AT_OR_AFTER
, CURSOR_BEFORE
,
CURSOR_AT_OR_BEFORE
, or CURSOR_AT
public int getTextRunCursor(String text, int contextStart, int contextEnd, int flags, int offset, int cursorOpt)
ContextStart, contextEnd, and offset are relative to the start of text. The context is the shaping context for cursor movement, generally the bounds of the metric span enclosing the cursor in the direction of movement.
If cursorOpt is CURSOR_AT
and the offset is not a valid
cursor position, this returns -1. Otherwise this will never return a
value before contextStart or after contextEnd.
text
- the textcontextStart
- the start of the contextcontextEnd
- the end of the contextflags
- either DIRECTION_RTL
or DIRECTION_LTR
offset
- the cursor position to move fromcursorOpt
- how to move the cursor, one of CURSOR_AFTER
,
CURSOR_AT_OR_AFTER
, CURSOR_BEFORE
,
CURSOR_AT_OR_BEFORE
, or CURSOR_AT
public void getTextPath(char[] text, int index, int count, float x, float y, Path path)
text
- The text to retrieve the path fromindex
- The index of the first character in textcount
- The number of characterss starting with indexx
- The x coordinate of the text's originy
- The y coordinate of the text's originpath
- The path to receive the data describing the text. Must
be allocated by the caller.public void getTextPath(String text, int start, int end, float x, float y, Path path)
text
- The text to retrieve the path fromstart
- The first character in the textend
- 1 past the last charcter in the textx
- The x coordinate of the text's originy
- The y coordinate of the text's originpath
- The path to receive the data describing the text. Must
be allocated by the caller.public void getTextBounds(String text, int start, int end, Rect bounds)
text
- String to measure and return its boundsstart
- Index of the first char in the string to measureend
- 1 past the last char in the string measurebounds
- Returns the unioned bounds of all the text. Must be
allocated by the caller.public void getTextBounds(char[] text, int index, int count, Rect bounds)
text
- Array of chars to measure and return their unioned boundsindex
- Index of the first char in the array to measurecount
- The number of chars, beginning at index, to measurebounds
- Returns the unioned bounds of all the text. Must be
allocated by the caller.protected void finalize() throws Throwable
Object
Note that objects that override finalize
are significantly more expensive than
objects that don't. Finalizers may be run a long time after the object is no longer
reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup.
Note also that finalizers are run on a single VM-wide finalizer thread,
so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary
for a class that has a native peer and needs to call a native method to destroy that peer.
Even then, it's better to provide an explicit close
method (and implement
Closeable
), and insist that callers manually dispose of instances. This
works well for something like files, but less well for something like a BigInteger
where typical calling code would have to deal with lots of temporaries. Unfortunately,
code that creates lots of temporaries is the worst kind of code from the point of view of
the single finalizer thread.
If you must use finalizers, consider at least providing your own
ReferenceQueue
and having your own thread process that queue.
Unlike constructors, finalizers are not automatically chained. You are responsible for
calling super.finalize()
yourself.
Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.