Represents a system or web font in Excalibur

If no options specified, the system sans-serif 10 pixel is used

If loading a custom web font be sure to have the font loaded before you use it https://erikonarheim.com/posts/dont-test-fonts/

Hierarchy

Implements

Constructors

Properties

baseAlign: BaseAlign = BaseAlign.Alphabetic
bold: boolean = false
color: Color = Color.Black
direction: Direction = Direction.LeftToRight
family: string = 'sans-serif'
filtering: ImageFiltering = ImageFiltering.Blended

Set the font filtering mode, by default set to ImageFiltering.Blended regardless of the engine default smoothing

If you have a pixel style font that may be a reason to switch this to ImageFiltering.Pixel

id: number = ...
lineDash: number[] = []
lineWidth: number = 1
opacity: number = 1

Gets or sets the opacity of the graphic, 0 is transparent, 1 is solid (opaque).

padding: number = 2
quality: number = 2

Font quality determines the size of the underlying raster text, higher quality means less jagged edges. If quality is set to 1, then just enough raster bitmap is generated to render the text.

You can think of quality as how zoomed in to the text you can get before seeing jagged edges.

(Default 2)

shadow: {
    blur?: number;
    color?: Color;
    offset?: Vector;
} = null

Type declaration

  • Optional blur?: number
  • Optional color?: Color
  • Optional offset?: Vector
showDebug: boolean = false

Gets or sets wether to show debug information about the graphic

size: number = 10
smoothing: boolean = false
strokeColor: Color
style: FontStyle = FontStyle.Normal
textAlign: TextAlign = TextAlign.Left
tint: Color = null
transform: AffineMatrix = ...
unit: FontUnit = FontUnit.Px

Accessors

  • get flipHorizontal(): boolean
  • Gets or sets the flipHorizontal, which will flip the graphic horizontally (across the y axis)

    Returns boolean

  • set flipHorizontal(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get flipVertical(): boolean
  • Gets or sets the flipVertical, which will flip the graphic vertically (across the x axis)

    Returns boolean

  • set flipVertical(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get height(): number
  • Gets or sets the height of the graphic (always positive)

    Returns number

  • set height(value: number): void
  • Parameters

    • value: number

    Returns void

  • get localBounds(): BoundingBox
  • Gets a copy of the bounds in pixels occupied by the graphic on the the screen. This includes scale.

    Returns BoundingBox

  • get rotation(): number
  • Gets or sets the rotation of the graphic

    Returns number

  • set rotation(value: number): void
  • Parameters

    • value: number

    Returns void

  • get width(): number
  • Gets or sets the width of the graphic (always positive)

    Returns number

  • set width(value: number): void
  • Parameters

    • value: number

    Returns void

Methods

  • Returns a BoundingBox that is the total size of the text including multiple lines

    Does not include any padding or adjustment

    Returns

    BoundingBox

    Parameters

    • text: string
    • Optional maxWidth: number

    Returns BoundingBox