Class FontPaint

java.lang.Object
icyllis.modernui.graphics.text.FontPaint

public class FontPaint extends Object
The base paint used with layout engine at lower levels.
  • Field Details

    • NORMAL

      public static final int NORMAL
      Bit flag used with fontStyle to request the normal/regular style
      See Also:
    • BOLD

      public static final int BOLD
      Bit flag used with fontStyle to request the bold style
      See Also:
    • ITALIC

      public static final int ITALIC
      Bit flag used with fontStyle to request the italic style
      See Also:
    • BOLD_ITALIC

      public static final int BOLD_ITALIC
      Font 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

      @Internal public FontPaint(@Nonnull FontPaint paint)
  • Method Details

    • set

      public void set(@Nonnull FontPaint paint)
      Copy the data from paint into this TextPaint
    • setFont

      public void setFont(@Nonnull FontCollection font)
    • getFont

      public FontCollection getFont()
    • setLocale

      public void setLocale(@Nonnull Locale locale)
    • getLocale

      public Locale 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

      public boolean isMetricAffecting(@Nonnull FontPaint paint)
      Returns true of the passed FontPaint 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

      public int getFontMetricsInt(@Nullable FontMetricsInt fm)
      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()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object