Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TextFormat

The TextFormat class represents character formatting information. It is used by the TextField and BitmapFont classes to characterize the way the glyphs will be rendered.

Note that not all properties are used by all font renderers: bitmap fonts ignore the "bold", "italic", and "underline" values.

Hierarchy

Index

Constructors

constructor

  • new TextFormat(font?: string, size?: number, color?: number, horizontalAlign?: string, verticalAlign?: string): TextFormat

Properties

bold

bold: boolean

Indicates whether the text is bold. @default false

color

color: number

The color of the text. Note that bitmap fonts should be exported in plain white so that tinting works correctly. If your bitmap font contains colors, set this property to Color.WHITE to get the desired result. @default black

font

font: string

The name of the font. TrueType fonts will be looked up from embedded fonts and system fonts; bitmap fonts must be registered at the TextField class first. Beware: If you loaded an embedded font at runtime, you must call TextField.updateEmbeddedFonts() for Starling to recognize it.

horizontalAlign

horizontalAlign: string

The horizontal alignment of the text. @default center @see starling.utils.Align

italic

italic: boolean

Indicates whether the text is italicized. @default false

kerning

kerning: boolean

Indicates whether kerning is enabled. Kerning adjusts the pixels between certain character pairs to improve readability. @default true

leading

leading: number

The amount of vertical space (called 'leading') between lines. @default 0

letterSpacing

letterSpacing: number

A number representing the amount of space that is uniformly distributed between all characters. @default 0

size

size: number

The size of the font. For bitmap fonts, use BitmapFont.NATIVE_SIZE for the original size.

underline

underline: boolean

Indicates whether the text is underlined. @default false

verticalAlign

verticalAlign: string

The vertical alignment of the text. @default center @see starling.utils.Align

Methods

addEventListener

  • addEventListener(type: string, listener: Function): void

clone

copyFrom

dispatchEvent

  • dispatchEvent(event: Event): void
  • Dispatches an event to all objects that have registered listeners for its type. If an event with enabled 'bubble' property is dispatched to a display object, it will travel up along the line of parents, until it either hits the root object or someone stops its propagation manually.

    Parameters

    Returns void

dispatchEventWith

  • dispatchEventWith(type: string, bubbles?: boolean, data?: any): void

Protected get_bold

  • get_bold(): boolean

Protected get_color

  • get_color(): number

Protected get_font

  • get_font(): string

Protected get_horizontalAlign

  • get_horizontalAlign(): string

Protected get_italic

  • get_italic(): boolean

Protected get_kerning

  • get_kerning(): boolean

Protected get_leading

  • get_leading(): number

Protected get_letterSpacing

  • get_letterSpacing(): number

Protected get_size

  • get_size(): number

Protected get_underline

  • get_underline(): boolean

Protected get_verticalAlign

  • get_verticalAlign(): string

hasEventListener

  • hasEventListener(type: string, listener?: any): boolean

removeEventListener

  • removeEventListener(type: string, listener: Function): void

removeEventListeners

  • removeEventListeners(type?: string): void

setTo

  • setTo(font?: string, size?: number, color?: number, horizontalAlign?: string, verticalAlign?: string): void
  • Sets the most common properties at once.

    Parameters

    • Optional font: string
    • Optional size: number
    • Optional color: number
    • Optional horizontalAlign: string
    • Optional verticalAlign: string

    Returns void

Protected set_bold

  • set_bold(value: boolean): boolean

Protected set_color

  • set_color(value: number): number

Protected set_font

  • set_font(value: string): string

Protected set_horizontalAlign

  • set_horizontalAlign(value: string): string

Protected set_italic

  • set_italic(value: boolean): boolean

Protected set_kerning

  • set_kerning(value: boolean): boolean

Protected set_leading

  • set_leading(value: number): number

Protected set_letterSpacing

  • set_letterSpacing(value: number): number

Protected set_size

  • set_size(value: number): number

Protected set_underline

  • set_underline(value: boolean): boolean

Protected set_verticalAlign

  • set_verticalAlign(value: string): string

toNativeFormat

  • toNativeFormat(out?: OpenFLTextFormat): OpenFLTextFormat
  • Converts the Starling TextFormat instance to a Flash TextFormat.

    Parameters

    • Optional out: OpenFLTextFormat

    Returns OpenFLTextFormat

Generated using TypeDoc