Skip to main content

Font

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

  • FontRenderer

Index

Constructors

constructor

Properties

publicbaseAlign

baseAlign: BaseAlign = BaseAlign.Top

publicbold

bold: boolean = false

publiccolor

color: Color = Color.Black

publicdirection

direction: Direction = Direction.LeftToRight

publicfamily

family: string = 'sans-serif'

publicfiltering

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]]

readonlyid

id: number = ...

publiclineDash

lineDash: number[] = []

publiclineHeight

lineHeight: number = undefined

Font line height in pixels, default line height if unset

publiclineWidth

lineWidth: number = 1

publicopacity

opacity: number = 1

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

publicpadding

padding: number = 2

publicquality

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)

publicshadow

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

Type declaration

  • optionalblur?: number
  • optionalcolor?: Color
  • optionaloffset?: Vector

publicshowDebug

showDebug: boolean = false

Gets or sets wether to show debug information about the graphic

publicsize

size: number = 10

publicsmoothing

smoothing: boolean = false

publicstrokeColor

strokeColor: Color

publicstyle

style: FontStyle = FontStyle.Normal

publictextAlign

textAlign: TextAlign = TextAlign.Left

publictint

tint: Color = null

publictransform

transform: AffineMatrix = ...

publicunit

unit: FontUnit = FontUnit.Px

Accessors

publicflipHorizontal

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


    Returns boolean

  • Parameters

    • value: boolean

    Returns void

publicflipVertical

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


    Returns boolean

  • Parameters

    • value: boolean

    Returns void

publicfontString

  • get fontString(): string
  • Returns string

publicheight

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


    Returns number

  • Parameters

    • value: number

    Returns void

publiclocalBounds

  • Gets a copy of the bounds in pixels occupied by the graphic on the the screen. This includes scale.


    Returns BoundingBox

publicorigin

  • Gets or sets the origin of the graphic, if not set the center of the graphic is the origin


    Returns Vector

  • Parameters

    Returns void

publicrotation

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


    Returns number

  • Parameters

    • value: number

    Returns void

publicscale

  • Gets or sets the scale of the graphic, this affects the width and


    Returns Vector

  • Parameters

    Returns void

publicwidth

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


    Returns number

  • Parameters

    • value: number

    Returns void

Methods

publicclone

  • Returns a new instance of the graphic that has the same properties


    Returns Font

publiccloneGraphicOptions

publicdraw

  • Draw the whole graphic to the context including transform


    Parameters

    Returns void

publicisStale

  • isStale(): boolean
  • Returns boolean

publicmeasureText

  • measureText(text: string, maxWidth?: number): BoundingBox
  • Returns a BoundingBox that is the total size of the text including multiple lines

    Does not include any padding or adjustment


    Parameters

    • text: string
    • optionalmaxWidth: number

    Returns BoundingBox

    BoundingBox

publicmeasureTextWithoutCache

  • measureTextWithoutCache(text: string, maxWidth?: number): BoundingBox
  • Parameters

    • text: string
    • optionalmaxWidth: number

    Returns BoundingBox

publicrender

  • Parameters

    Returns void