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

- EventDispatcher
  - TextFormat

## Index

### Constructors

- constructor

### Properties

- bold
- color
- font
- horizontalAlign
- italic
- kerning
- leading
- letterSpacing
- size
- underline
- verticalAlign

### Methods

- addEventListener
- clone
- copyFrom
- dispatchEvent
- dispatchEventWith
- get_bold
- get_color
- get_font
- get_horizontalAlign
- get_italic
- get_kerning
- get_leading
- get_letterSpacing
- get_size
- get_underline
- get_verticalAlign
- hasEventListener
- removeEventListener
- removeEventListeners
- setTo
- set_bold
- set_color
- set_font
- set_horizontalAlign
- set_italic
- set_kerning
- set_leading
- set_letterSpacing
- set_size
- set_underline
- set_verticalAlign
- toNativeFormat

## Constructors

### constructor

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

- Overrides EventDispatcher.constructor

  - Defined in lib/starling/text/TextFormat.d.ts:18

  Creates a new TextFormat instance with the given properties.

  #### Parameters

  - ##### Optional font: string

  - ##### Optional size: number

  - ##### Optional color: number

  - ##### Optional horizontalAlign: string

  - ##### Optional verticalAlign: string

  #### Returns TextFormat

## Properties

### bold

bold: boolean

- Defined in lib/starling/text/TextFormat.d.ts:59

Indicates whether the text is bold. @default false

### color

color: number

- Defined in lib/starling/text/TextFormat.d.ts:54

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

- Defined in lib/starling/text/TextFormat.d.ts:41

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

- Defined in lib/starling/text/TextFormat.d.ts:75

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

### italic

italic: boolean

- Defined in lib/starling/text/TextFormat.d.ts:64

Indicates whether the text is italicized. @default false

### kerning

kerning: boolean

- Defined in lib/starling/text/TextFormat.d.ts:87

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

### leading

leading: number

- Defined in lib/starling/text/TextFormat.d.ts:92

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

### letterSpacing

letterSpacing: number

- Defined in lib/starling/text/TextFormat.d.ts:97

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

### size

size: number

- Defined in lib/starling/text/TextFormat.d.ts:47

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

### underline

underline: boolean

- Defined in lib/starling/text/TextFormat.d.ts:69

Indicates whether the text is underlined. @default false

### verticalAlign

verticalAlign: string

- Defined in lib/starling/text/TextFormat.d.ts:81

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

## Methods

### addEventListener

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

- Inherited from EventDispatcher.addEventListener

  - Defined in lib/starling/events/EventDispatcher.d.ts:32

  Registers an event listener at a certain object.

  #### Parameters

  - ##### type: string

  - ##### listener: Function

  #### Returns void

### clone

- clone(): TextFormat

- - Defined in lib/starling/text/TextFormat.d.ts:27

  Creates a clone of this instance.

  #### Returns TextFormat

### copyFrom

- copyFrom(format: TextFormat): void

- - Defined in lib/starling/text/TextFormat.d.ts:24

  Copies all properties from another TextFormat instance.

  #### Parameters

  - ##### format: TextFormat

  #### Returns void

### dispatchEvent

- dispatchEvent(event: Event): void

- Inherited from EventDispatcher.dispatchEvent

  - Defined in lib/starling/events/EventDispatcher.d.ts:45

  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

  - ##### event: Event

  #### Returns void

### dispatchEventWith

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

- Inherited from EventDispatcher.dispatchEventWith

  - Defined in lib/starling/events/EventDispatcher.d.ts:50

  Dispatches an event with the given parameters to all objects that have registered listeners for the given type. The method uses an internal pool of event objects to avoid allocations.

  #### Parameters

  - ##### type: string

  - ##### Optional bubbles: boolean

  - ##### Optional data: any

  #### Returns void

### Protected get_bold

- get_bold(): boolean

- - Defined in lib/starling/text/TextFormat.d.ts:60

  #### Returns boolean

### Protected get_color

- get_color(): number

- - Defined in lib/starling/text/TextFormat.d.ts:55

  #### Returns number

### Protected get_font

- get_font(): string

- - Defined in lib/starling/text/TextFormat.d.ts:42

  #### Returns string

### Protected get_horizontalAlign

- get_horizontalAlign(): string

- - Defined in lib/starling/text/TextFormat.d.ts:76

  #### Returns string

### Protected get_italic

- get_italic(): boolean

- - Defined in lib/starling/text/TextFormat.d.ts:65

  #### Returns boolean

### Protected get_kerning

- get_kerning(): boolean

- - Defined in lib/starling/text/TextFormat.d.ts:88

  #### Returns boolean

### Protected get_leading

- get_leading(): number

- - Defined in lib/starling/text/TextFormat.d.ts:93

  #### Returns number

### Protected get_letterSpacing

- get_letterSpacing(): number

- - Defined in lib/starling/text/TextFormat.d.ts:98

  #### Returns number

### Protected get_size

- get_size(): number

- - Defined in lib/starling/text/TextFormat.d.ts:48

  #### Returns number

### Protected get_underline

- get_underline(): boolean

- - Defined in lib/starling/text/TextFormat.d.ts:70

  #### Returns boolean

### Protected get_verticalAlign

- get_verticalAlign(): string

- - Defined in lib/starling/text/TextFormat.d.ts:82

  #### Returns string

### hasEventListener

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

- Inherited from EventDispatcher.hasEventListener

  - Defined in lib/starling/events/EventDispatcher.d.ts:55

  If called with one argument, figures out if there are any listeners registered for the given event type. If called with two arguments, also determines if a specific listener is registered.

  #### Parameters

  - ##### type: string

  - ##### Optional listener: any

  #### Returns boolean

### removeEventListener

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

- Inherited from EventDispatcher.removeEventListener

  - Defined in lib/starling/events/EventDispatcher.d.ts:35

  Removes an event listener from the object.

  #### Parameters

  - ##### type: string

  - ##### listener: Function

  #### Returns void

### removeEventListeners

- removeEventListeners(type?: string): void

- Inherited from EventDispatcher.removeEventListeners

  - Defined in lib/starling/events/EventDispatcher.d.ts:39

  Removes all event listeners with a certain type, or all of them if type is null. Be careful when removing all event listeners: you never know who else was listening.

  #### Parameters

  - ##### Optional type: string

  #### Returns void

### setTo

- setTo(font?: string, size?: number, color?: number, horizontalAlign?: string, verticalAlign?: string): void

- - Defined in lib/starling/text/TextFormat.d.ts:30

  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

- - Defined in lib/starling/text/TextFormat.d.ts:61

  #### Parameters

  - ##### value: boolean

  #### Returns boolean

### Protected set_color

- set_color(value: number): number

- - Defined in lib/starling/text/TextFormat.d.ts:56

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_font

- set_font(value: string): string

- - Defined in lib/starling/text/TextFormat.d.ts:43

  #### Parameters

  - ##### value: string

  #### Returns string

### Protected set_horizontalAlign

- set_horizontalAlign(value: string): string

- - Defined in lib/starling/text/TextFormat.d.ts:77

  #### Parameters

  - ##### value: string

  #### Returns string

### Protected set_italic

- set_italic(value: boolean): boolean

- - Defined in lib/starling/text/TextFormat.d.ts:66

  #### Parameters

  - ##### value: boolean

  #### Returns boolean

### Protected set_kerning

- set_kerning(value: boolean): boolean

- - Defined in lib/starling/text/TextFormat.d.ts:89

  #### Parameters

  - ##### value: boolean

  #### Returns boolean

### Protected set_leading

- set_leading(value: number): number

- - Defined in lib/starling/text/TextFormat.d.ts:94

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_letterSpacing

- set_letterSpacing(value: number): number

- - Defined in lib/starling/text/TextFormat.d.ts:99

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_size

- set_size(value: number): number

- - Defined in lib/starling/text/TextFormat.d.ts:49

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_underline

- set_underline(value: boolean): boolean

- - Defined in lib/starling/text/TextFormat.d.ts:71

  #### Parameters

  - ##### value: boolean

  #### Returns boolean

### Protected set_verticalAlign

- set_verticalAlign(value: string): string

- - Defined in lib/starling/text/TextFormat.d.ts:83

  #### Parameters

  - ##### value: string

  #### Returns string

### toNativeFormat

- toNativeFormat(out?: OpenFLTextFormat): OpenFLTextFormat

- - Defined in lib/starling/text/TextFormat.d.ts:34

  Converts the Starling TextFormat instance to a Flash TextFormat.

  #### Parameters

  - ##### Optional out: OpenFLTextFormat

  #### Returns OpenFLTextFormat

Generated using TypeDoc