Skip to main content

UI.Font

Class representing font used in the UI.

Index

Constructors

constructor

  • Constructs new instance of the font with specified parameters.


    Parameters

    • color: FontColor

      font color, android integer color value (produced by android.graphics.Color)

    • size: number

      font size

    • shadow: number

      shadow offset

    Returns Font

Properties

alignment

alignment: number

color

color: FontColor

isBold

isBold: boolean

isCursive

isCursive: boolean

isUnderlined

isUnderlined: boolean

shadow

shadow: number

size

size: number

staticreadonlyALIGN_CENTER

ALIGN_CENTER: number

Aligns text to the start of the element (left for English locale).

staticreadonlyALIGN_CENTER_HORIZONTAL
since: 2.2.1b96

ALIGN_CENTER_HORIZONTAL: number

Aligns text to the center of the element horizontally.

staticreadonlyALIGN_DEFAULT

ALIGN_DEFAULT: number

Aligns text to the center of the element.

staticreadonlyALIGN_END

ALIGN_END: number

Aligns text to the end of the element (right for English locale).

Methods

asScriptable

drawText

  • drawText(canvas: Canvas, x: number, y: number, text: string, scale: number): void
  • Draws text on the canvas using created font.


    Parameters

    • canvas: Canvas

      android.graphics.Canvas instance to draw the text on

    • x: number

      x coordinate of the text in pixels

    • y: number

      x coordinate of the text in pixels

    • text: string

      text string to draw

    • scale: number

      additional scale to apply to the text

    Returns void

getBounds

  • getBounds(text: string, x: number, y: number, scale: number): Rect
  • Calculates bounds of the text given text position, text string and additional scale.


    Parameters

    • text: string
    • x: number
    • y: number
    • scale: number

    Returns Rect

    rect object containing calculated bounds of the text

getTextHeight

  • getTextHeight(text: string, x: number, y: number, scale: number): number
  • Calculates text height given text string and additional scale.


    Parameters

    • text: string
    • x: number
    • y: number
    • scale: number

    Returns number

    height of the specified string when painted with specified scale

getTextWidth

  • getTextWidth(text: string, scale: number): number
  • Calculates text width given text string and additional scale.


    Parameters

    • text: string
    • scale: number

    Returns number

    width of the specified string when painted with specified scale