Packagestarling.text
Classpublic class TextFormat
InheritanceTextFormat Inheritance EventDispatcher Inheritance Object

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.



Public Properties
 PropertyDefined By
  bold : Boolean
Indicates whether the text is bold.
TextFormat
  color : uint
The color of the text.
TextFormat
  font : String
The name of the font.
TextFormat
  horizontalAlign : String
The horizontal alignment of the text.
TextFormat
  italic : Boolean
Indicates whether the text is italicized.
TextFormat
  kerning : Boolean
Indicates whether kerning is enabled.
TextFormat
  leading : Number
The amount of vertical space (called 'leading') between lines.
TextFormat
  size : Number
The size of the font.
TextFormat
  underline : Boolean
Indicates whether the text is underlined.
TextFormat
  verticalAlign : String
The vertical alignment of the text.
TextFormat
Public Methods
 MethodDefined By
  
TextFormat(font:String = Verdana, size:Number = 12, color:uint = 0x0, horizontalAlign:String = center, verticalAlign:String = center)
Creates a new TextFormat instance with the given properties.
TextFormat
 Inherited
addEventListener(type:String, listener:Function):void
Registers an event listener at a certain object.
EventDispatcher
  
Creates a clone of this instance.
TextFormat
  
copyFrom(format:TextFormat):void
Copies all properties from another TextFormat instance.
TextFormat
 Inherited
dispatchEvent(event:Event):void
Dispatches an event to all objects that have registered listeners for its type.
EventDispatcher
 Inherited
dispatchEventWith(type:String, bubbles:Boolean = false, data:Object = null):void
Dispatches an event with the given parameters to all objects that have registered listeners for the given type.
EventDispatcher
 Inherited
hasEventListener(type:String, listener:Function = null):Boolean
If called with one argument, figures out if there are any listeners registered for the given event type.
EventDispatcher
 Inherited
removeEventListener(type:String, listener:Function):void
Removes an event listener from the object.
EventDispatcher
 Inherited
removeEventListeners(type:String = null):void
Removes all event listeners with a certain type, or all of them if type is null.
EventDispatcher
  
setTo(font:String = Verdana, size:Number = 12, color:uint = 0x0, horizontalAlign:String = center, verticalAlign:String = center):void
Sets the most common properties at once.
TextFormat
  
toNativeFormat(out:TextFormat = null):TextFormat
Converts the Starling TextFormat instance to a Flash TextFormat.
TextFormat
Events
 Event Summary Defined By
  Dispatched when any property of the instance changes.TextFormat
Property Detail
boldproperty
bold:Boolean

Indicates whether the text is bold.

The default value is false.


Implementation
    public function get bold():Boolean
    public function set bold(value:Boolean):void
colorproperty 
color:uint

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.

The default value is black.


Implementation
    public function get color():uint
    public function set color(value:uint):void
fontproperty 
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.


Implementation
    public function get font():String
    public function set font(value:String):void
horizontalAlignproperty 
horizontalAlign:String

The horizontal alignment of the text.

The default value is center.


Implementation
    public function get horizontalAlign():String
    public function set horizontalAlign(value:String):void

See also

italicproperty 
italic:Boolean

Indicates whether the text is italicized.

The default value is false.


Implementation
    public function get italic():Boolean
    public function set italic(value:Boolean):void
kerningproperty 
kerning:Boolean

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

The default value is true.


Implementation
    public function get kerning():Boolean
    public function set kerning(value:Boolean):void
leadingproperty 
leading:Number

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

The default value is 0.


Implementation
    public function get leading():Number
    public function set leading(value:Number):void
sizeproperty 
size:Number

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


Implementation
    public function get size():Number
    public function set size(value:Number):void
underlineproperty 
underline:Boolean

Indicates whether the text is underlined.

The default value is false.


Implementation
    public function get underline():Boolean
    public function set underline(value:Boolean):void
verticalAlignproperty 
verticalAlign:String

The vertical alignment of the text.

The default value is center.


Implementation
    public function get verticalAlign():String
    public function set verticalAlign(value:String):void

See also

Constructor Detail
TextFormat()Constructor
public function TextFormat(font:String = Verdana, size:Number = 12, color:uint = 0x0, horizontalAlign:String = center, verticalAlign:String = center)

Creates a new TextFormat instance with the given properties.

Parameters
font:String (default = Verdana)
 
size:Number (default = 12)
 
color:uint (default = 0x0)
 
horizontalAlign:String (default = center)
 
verticalAlign:String (default = center)
Method Detail
clone()method
public function clone():TextFormat

Creates a clone of this instance.

Returns
TextFormat
copyFrom()method 
public function copyFrom(format:TextFormat):void

Copies all properties from another TextFormat instance.

Parameters

format:TextFormat

setTo()method 
public function setTo(font:String = Verdana, size:Number = 12, color:uint = 0x0, horizontalAlign:String = center, verticalAlign:String = center):void

Sets the most common properties at once.

Parameters

font:String (default = Verdana)
 
size:Number (default = 12)
 
color:uint (default = 0x0)
 
horizontalAlign:String (default = center)
 
verticalAlign:String (default = center)

toNativeFormat()method 
public function toNativeFormat(out:TextFormat = null):TextFormat

Converts the Starling TextFormat instance to a Flash TextFormat.

Parameters

out:TextFormat (default = null)

Returns
TextFormat
Event Detail
change Event
Event Object Type: starling.events.Event

Dispatched when any property of the instance changes.