qnx.fuse.ui.text.TextFormat

TextFormat

Properties | Methods | Examples


Packageqnx.fuse.ui.text
Classpublic final class TextFormat
InheritanceTextFormat Inheritance Object

The TextFormat object applies text formatting to the TextField of a control.

Class information:
BlackBerry 10 Version:   10.0.0

View the examples

See also

Label
TextArea
TextInput



Public Properties

 PropertyDefined By
  align : String = start
Specifies the alignment of the text.
TextFormat
  bold : Boolean = false
Specifies bolded font.
TextFormat
  breakOpportunity : String
The line break opportunity applied to this text.
TextFormat
  color : uint = 0x000000
Specifies the color of the text.
TextFormat
  font : String
Specifies the font of the text.
TextFormat
  fontLookup : String = device
Specifies how to look up the font.
TextFormat
  italic : Boolean = false
Specifies italicized font.
TextFormat
  leading : Object
An integer representing the amount of vertical space between lines.
TextFormat
  maxSize : int = 2.147483647E9
Gets or sets the maximum size of the text.
TextFormat
  minSize : int = 1
Gets or sets the minimum size of the text.
TextFormat
  scale : Number
Gets or sets the scale of the font size in relation to the FontSettings.contentSize property.
TextFormat
  size : int
Specifies the size of the text.
TextFormat
  strikethrough : Boolean
Will place a striketrough the text.
TextFormat
  style : String
Sets the style for the text format.
TextFormat
  underline : Boolean
Will underline the text.
TextFormat

Public Methods

 MethodDefined By
  
Creates a TextFormat instance.
TextFormat
  
Creates a clone of the current TextFormat instance.
TextFormat
  
isEqual(format:TextFormat):Boolean
Determines if the specified format is the same as the current instance.
TextFormat
  
sizeChanged(format:TextFormat):Boolean
Compares the specified TextFormat object to see if any properties have changed that affect text measurement.
TextFormat

Property Detail

align


public var align:String = start

Specifies the alignment of the text.

The default value is start.

See also

TextAlign

bold


public var bold:Boolean = false

Specifies bolded font.

The default value is false.

breakOpportunity


public var breakOpportunity:String

The line break opportunity applied to this text.

This property determines which characters can be used for breaking when wrapping text is broken into multiple lines. Use flash.text.engine.BreakOpportunity constants for this property.

When set to null, BreakOpportunity.ANY is used when maxLines is equal to 1. In all other cases BreakOpportunity.AUTO is used.

The default value is null.

color


public var color:uint = 0x000000

Specifies the color of the text.

The default value is 0x000000.

font


public var font:String

Specifies the font of the text. If no font is specified the FontSettings.fontFamily will be used.

fontLookup


public var fontLookup:String = device

Specifies how to look up the font.

The default value is FontLookup.DEVICE.

To set values for this property, use the following string values:

  • FontLookup.DEVICE - The runtime looks up a device font with the specified name on the local system with which to render the text.
  • FontLookup.EMBEDDED_CFF - The runtime looks up an embedded CFF font with the specified name with which to render the text. Only fonts of type flash.text.Font.fontType.EMBEDDED_CFF are considered. If the specified CFF font is not embedded in the application, the runtime attempts to use a fallback device font for each glyph. This method is less efficient than selecting a device font in the first place.

NOTE: Embedded fonts may not produce correct font metrics, which may cause labels to appear cropped.

The default value is FontLookup.DEVICE.

italic


public var italic:Boolean = false

Specifies italicized font.

The default value is false.

leading


public var leading:Object

An integer representing the amount of vertical space between lines. When set to null, text components will use 20% of the font size as the leading.

The default value is null.

maxSize


public var maxSize:int = 2.147483647E9

Gets or sets the maximum size of the text. This is useful for setting a maximum size when size is set in relation to the scale property. If set the size property will be constrained to this value.

The default value is int.MAX_VALUE.

minSize


public var minSize:int = 1

Gets or sets the minimum size of the text. This is useful for setting a minium size when size is set in relation to the scale property. If set the size property will be constrained to this value.

The default value is 1.

scale


public var scale:Number

Gets or sets the scale of the font size in relation to the FontSettings.contentSize property. If set, the size property will be adjusted, and any value set by the developer will be overwritten.

The default value is NaN.

See also

qnx.system.FontSettings.contentSize

size


size:int

Specifies the size of the text. The size property can also be adjusted by setting the style, scale, minSize, and maxSize. To determine the size that should be used, the size property checks the following properties in this order: size, style and scale If style or scale are set, the size will be set based off these values, unless the size property was explicitly set. The size is always constrained between the minSize and maxSize. If none of these values are set, the size used for TextFormatStyle.CONTENT is chosen.


Implementation

public function get size():int
public function set size(value:int):void

See also

scale
style
minSize
maxSize

strikethrough


public var strikethrough:Boolean

Will place a striketrough the text.

style


public var style:String

Sets the style for the text format. Valid values can be found in the TextFormatStyle class. If set, the size property will be adjusted to the size for that style of text.

See also

size
TextFormatStyle

underline


public var underline:Boolean

Will underline the text.

Constructor Detail

TextFormat()


public function TextFormat()

Creates a TextFormat instance.

Method Detail

clone()


public function clone():TextFormat

Creates a clone of the current TextFormat instance.

Returns

TextFormat — A new, identical TextFormat.

isEqual()


public function isEqual(format:TextFormat):Boolean

Determines if the specified format is the same as the current instance.

Parameters

format:TextFormat — The format instance to check against.

Returns

Boolean — If the supplied TextFormat contains all equal values to this one.

sizeChanged()


public function sizeChanged(format:TextFormat):Boolean

Compares the specified TextFormat object to see if any properties have changed that affect text measurement.

Parameters

format:TextFormat — The format to compare against.

Returns

Boolean — Returns true if a property that affects text measurements are different.

Examples

The following example creates a Label instance and a TextFormat instance. The TextFormat instance is applied to the Label object.

var myLabel:Label = new Label();
myLabel.x = 150;
myLabel.y = 200;
myLabel.setActualSize(400, 200);
myLabel.text = "Lorem ipsum dolor sit amet, consectetur " +
    "adipiscing elit. In blandit, erat euismod sagittis semper," +
    " libero mi semper orci, vel suscipit purus lectus nec velit.";
 
var myFormat:TextFormat = new TextFormat();        
myFormat.bold = true;
myFormat.size = 42;
myLabel.format = myFormat;            
this.addChild(myLabel);
     




comments powered by Disqus