Package icyllis.modernui.graphics.text
Class FontPaint
java.lang.Object
icyllis.modernui.graphics.text.FontPaint
The base paint used with layout engine at lower levels.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Bit flag used with fontStyle to request the bold stylestatic final int
Font style constant to request the bold and italic stylestatic final int
static final float
static final int
Bit flag used with fontStyle to request the italic stylestatic final int
Bit flag used with fontStyle to request the normal/regular style -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static float
getCanonicalFontSize
(float fontSize) getFont()
int
Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc.float
Return the paint's text size, in points.int
Get the font's style.int
hashCode()
boolean
boolean
boolean
isMetricAffecting
(FontPaint paint) Returns true of the passedFontPaint
will have the different effect on text measurementvoid
Copy the data from paint into this TextPaintvoid
setAntiAlias
(boolean aa) void
setFont
(FontCollection font) void
setFontSize
(float fontSize) Set the paint's text size in pixel units.void
setFontStyle
(int fontStyle) Set font's style.void
setLinearMetrics
(boolean linearMetrics) void
toString()
-
Field Details
-
NORMAL
public static final int NORMALBit flag used with fontStyle to request the normal/regular style- See Also:
-
BOLD
public static final int BOLDBit flag used with fontStyle to request the bold style- See Also:
-
ITALIC
public static final int ITALICBit flag used with fontStyle to request the italic style- See Also:
-
BOLD_ITALIC
public static final int BOLD_ITALICFont style constant to request the bold and italic style- See Also:
-
FONT_STYLE_MASK
public static final int FONT_STYLE_MASK- See Also:
-
INV_FONT_SIZE_GRANULARITY
public static final float INV_FONT_SIZE_GRANULARITY- See Also:
-
-
Constructor Details
-
FontPaint
@Internal public FontPaint() -
FontPaint
-
-
Method Details
-
set
Copy the data from paint into this TextPaint -
setFont
-
getFont
-
setLocale
-
getLocale
-
setFontStyle
public void setFontStyle(int fontStyle) Set font's style. Combination of REGULAR, BOLD and ITALIC.- Parameters:
fontStyle
- the style of the font
-
getFontStyle
public int getFontStyle()Get the font's style.- Returns:
- the style of the font
-
setFontSize
public void setFontSize(float fontSize) Set the paint's text size in pixel units. For example, a text size of 16 (1em) means the letter 'M' is 16 pixels high in device space. Very large or small sizes will impact rendering performance, and the rendering system might not render text at these sizes. For now, text sizes will clamp to 1 and 2184.Note: the point size is measured at 72 dpi, while Windows has 96 dpi. This indicates that the font size 12 in MS Word is equal to the font size 16 here.
- Parameters:
fontSize
- set the paint's text size in pixel units.
-
getFontSize
public float getFontSize()Return the paint's text size, in points.- Returns:
- the paint's text size in pixel units.
-
setAntiAlias
public void setAntiAlias(boolean aa) -
isAntiAlias
public boolean isAntiAlias() -
setLinearMetrics
public void setLinearMetrics(boolean linearMetrics) -
isLinearMetrics
public boolean isLinearMetrics() -
isMetricAffecting
Returns true of the passedFontPaint
will have the different effect on text measurement- Parameters:
paint
- the paint to compare with- Returns:
- true if given
FontPaint
has the different effect on text measurement.
-
getFontMetricsInt
Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc. If metrics is not null, return the fontmetric values in it. Note: all values have been converted to integers from floats, in such a way has to make the answers useful for both spacing and clipping. If you want more control over the rounding, call getFontMetrics().Note that these are the values for the main typeface, and actual text rendered may need a larger set of values because fallback fonts may get used in rendering the text.
- Returns:
- the font's interline spacing.
-
getCanonicalFontSize
public static float getCanonicalFontSize(float fontSize) -
hashCode
public int hashCode() -
equals
-
toString
-