ActionScript 3.0 Language and Components Reference | All Packages | All Classes | Language Elements | Index | Appendixes | Conventions | Frames No Frames |
ElementFormat

Package | flash.text.engine
Class | public final class ElementFormat
Inheritance | ElementFormat Object

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The ElementFormat class represents formatting information which can be applied to a `ContentElement`. Use the ElementFormat class to create specific text formatting for the various subclasses of ContentElement. The properties of the ElementFormat class apply to device and embedded fonts.

Setting the properties of an ElementFormat object after it has been applied to a ContentElement in a TextBlock does not invalidate the TextBlock.

View the examples

See also

flash.text.engine.ContentElement.elementFormat

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | alignmentBaseline : String Specifies which of the baselines of the line containing the element the dominantBaseline snaps to, thus determining the vertical position of the element in the line. | ElementFormat
|  | alpha : Number Provides a way for the author to automatically set the alpha property of all line atoms based on the element format to the specified Number. | ElementFormat
|  | baselineShift : Number Indicates the baseline shift for the element in pixels. | ElementFormat
|  | breakOpportunity : String The line break opportunity applied to this text. | ElementFormat
|  | color : uint Indicates the color of the text. | ElementFormat
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | digitCase : String The digit case used for this text. | ElementFormat
|  | digitWidth : String The digit width used for this text. | ElementFormat
|  | dominantBaseline : String Specifies which of the baselines of the element snaps to the alignmentBaseline to determine the vertical position of the element on the line. | ElementFormat
|  | fontDescription : FontDescription An object which encapsulates properties necessary to describe a font The default value is a default constructed FontDescription object. Subclass Effect of setting property GraphicElement Has no effect. GroupElement Has no effect. TextElement Determines the font used for the text in the element. | ElementFormat
|  | fontSize : Number The point size of text. | ElementFormat
|  | kerning : String The kerning used for this text. | ElementFormat
|  | ligatureLevel : String The ligature level used for this text. | ElementFormat
|  | locale : String The locale of the text. | ElementFormat
|  | prototype : Object [static] A reference to the prototype object of a class or function object. | Object
|  | textRotation : String Sets the rotation applied to individual glyphs. | ElementFormat
|  | tracking : Number The tracking or manual kerning in pixels. | ElementFormat
|  | typographicCase : String The typographic case used for this text. | ElementFormat

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | ElementFormat(fontDescription:FontDescription = null, fontSize:Number = 12.0, color:uint = 0x000000, alpha:Number = 1.0, textRotation:String = "rotate0", dominantBaseline:String = "roman", alignmentBaseline:String = "useDominantBaseline", baselineShift:Number = 0.0, kerning:String = "on", tracking:Number = 0.0, locale:String = "en", breakOpportunity:String = "auto", digitCase:String = "default", digitWidth:String = "default", ligatureLevel:String = "common", typographicCase:String = "default") Creates a ElementFormat object. | ElementFormat
|  | getFontMetrics():FontMetrics Returns a FontMetrics object with properties which describe the emBox, strikethrough position, strikethrough thickness, underline position, and underline thickness for the font specified by fontDescription and fontSize. | ElementFormat
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

alignmentBaseline | property

`alignmentBaseline:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

Specifies which of the baselines of the line containing the element the `dominantBaseline` snaps to, thus determining the vertical position of the element in the line. Use `flash.text.engine.TextBaseline` constants for this property.

The baselines of the line are determined by the largest element in the line unless `TextBlock.baselineFontDescription` and `TextBlock.baselineFontSize` are set to override that logic.

The default value is `flash.text.engine.TextBaseline.USE_DOMINANT_BASELINE`.

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

String value | Description
--- | ---
`TextBaseline.ROMAN` | The `dominantBaseline` aligns with the roman baseline of the line.
`TextBaseline.SUPERSCRIPT` | The `dominantBaseline` aligns with the superscript baseline of the line.
`TextBaseline.SUBSCRIPT` | The `dominantBaseline` aligns with the subscript baseline of the line.
`TextBaseline.ASCENT` | The `dominantBaseline` aligns with the ascent baseline of the line.
`TextBaseline.DESCENT` | The `dominantBaseline` aligns with the descent baseline of the line.
`TextBaseline.IDEOGRAPHIC_TOP` | The `dominantBaseline` aligns with the ideographic top baseline of the line.
`TextBaseline.IDEOGRAPHIC_CENTER` | The `dominantBaseline` aligns with the ideographic center baseline of the line.
`TextBaseline.IDEOGRAPHIC_BOTTOM` | The `dominantBaseline` aligns with the ideographic bottom baseline of the line.
`TextBaseline.USE_DOMINANT_BASELINE` | The `dominantBaseline` aligns with the same baseline of the line.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Sets the alignment baseline of the line to which the `dominantBaseline` of the graphic element aligns.
`GroupElement` | Has no effect.
`TextElement` | Sets the alignment baseline of the line to which the `dominantBaseline` of the text element aligns.

Implementation
`public function get alignmentBaseline():String`
`public function set alignmentBaseline(value:String):void`
Throws

| `ArgumentError` — If set to any value which is not a member of `flash.text.engine.TextBaseline`.

See also

flash.text.engine.TextBaseline
flash.text.engine.ElementFormat.dominantBaseline

alpha | property |

`alpha:Number` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

Provides a way for the author to automatically set the `alpha` property of all line atoms based on the element format to the specified Number.

Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible.

The default value is `1.0`.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Applies the specified alpha to the graphic element. Combines multiplicatively with any alpha set on the graphic `DisplayObject` itself or on the `TextLine`.
`GroupElement` | Has no effect.
`TextElement` | Applies the specified alpha to the text element. Combines multiplicatively with any alpha set on the `TextLine`.

Implementation
`public function get alpha():Number`
`public function set alpha(value:Number):void`

See also

flash.display.DisplayObject.alpha

baselineShift | property |

`baselineShift:Number` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

Indicates the baseline shift for the element in pixels. The element is shifted away from the `dominantBaseline` by this amount. The offset is added to the y position of the members of the element, so in non-rotated text, a positive baseline shift moves the element down and a negative baseline shift moves the element up.

The default value is `0.0`, indicating no shift.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Shifts the graphic away from the baseline.
`GroupElement` | Has no effect.
`TextElement` | Shifts the text away from the baseline.

Implementation
`public function get baselineShift():Number`
`public function set baselineShift(value:Number):void`

breakOpportunity | property |

`breakOpportunity:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The line break opportunity applied to this text. Use `flash.text.engine.BreakOpportunity` constants for this property.

The default value is `flash.text.engine.BreakOpportunity.AUTO`.

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

String value | Description
--- | ---
`BreakOpportunity.AUTO` | Line breaking opportunities are based on standard Unicode character properties, such as breaking between words and on hyphens.
`BreakOpportunity.ANY` | Any character in the `ContentElement` object is treated as a line break opportunity. This value is typically used when Roman text is embedded in Asian text and it is desirable for breaks to happen in the middle of words.
`BreakOpportunity.NONE` | No characters in the range are treated as line break opportunities.
`BreakOpportunity.ALL` | All characters in the range are treated as line break opportunities. Useful for creating effects like text on a path.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Determines the break opportunity between adjacent text elements in the group. if the elementFormat of the group is `null`, the format of the first of the adjacent elements is used.
`TextElement` | Determines the break opportunity between the characters in the text element.

Implementation
`public function get breakOpportunity():String`
`public function set breakOpportunity(value:String):void`
Throws

| `ArgumentError` — If set to any value which is not a member of `flash.text.engine.BreakOpportunity`.

See also

flash.text.engine.BreakOpportunity

color | property |

`color:uint` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

Indicates the color of the text. An integer containing three 8-bit RGB components; for example, 0xFF0000 is red, and 0x00FF00 is green.

The default value is `0x000000`, which means that Flash Player uses the color black.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Has no effect.
`TextElement` | Sets the color of the text.

Implementation
`public function get color():uint`
`public function set color(value:uint):void`

digitCase | property |

`digitCase:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The digit case used for this text. Use `flash.text.engine.DigitCase` constants for this property.

The default value is `flash.text.engine.DigitCase.DEFAULT`.

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

String value | Description
--- | ---
`DigitCase.DEFAULT` | Applies default digit case to the text.
`DigitCase.LINING` | Applies lining digit case to the text.
`DigitCase.OLD_STYLE` | Applies old style digit case to the text.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Has no effect.
`TextElement` | Determines the digit case used for the text in the element.

Implementation
`public function get digitCase():String`
`public function set digitCase(value:String):void`
Throws

| `ArgumentError` — If set to any value which is not a member of `flash.text.engine.DigitCase`.

See also

flash.text.engine.DigitCase

digitWidth | property |

`digitWidth:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The digit width used for this text. Use `flash.text.engine.DigitWidth` constants for this property.

The default value is `flash.text.engine.DigitWidth.DEFAULT`.

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

String value | Description
--- | ---
`DigitWidth.DEFAULT` | Applies default digit width to the text.
`DigitWidth.PROPORTIONAL` | Applies proportional digit width to the text.
`DigitWidth.TABULAR` | Applies tabular digit width to the text.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Has no effect.
`TextElement` | Determines the digit width used for the text in the element.

Implementation
`public function get digitWidth():String`
`public function set digitWidth(value:String):void`
Throws

| `ArgumentError` — If set to any value which is not a member of `flash.text.engine.DigitWidth`.

See also

flash.text.engine.DigitWidth

dominantBaseline | property |

`dominantBaseline:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

Specifies which of the baselines of the element snaps to the `alignmentBaseline` to determine the vertical position of the element on the line. Use `flash.text.engine.TextBaseline` constants for this property.

The baselines of the element are determined by the content of the element. In the case of a `TextElement`, they are determined by the font and the point size. In the case of a `GraphicElement`, they are determined by the height of the element.

The default value is `flash.text.engine.TextBaseline.ROMAN`.

For example, to create a roman superscript element, set `dominantBaseline` to `TextBaseline.ROMAN` (the default), set `alignmentBaseline` to `TextBaseline.SUPERSCRIPT`, and set `fontSize` to that of the text on the line multiplied by `FontMetrics.superscriptScale`.

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

String value | Description
--- | ---
`TextBaseline.ROMAN` | The roman baseline of the element aligns with the `alignmentBaseline`.
`TextBaseline.SUPERSCRIPT` | The superscript baseline of the element aligns with the `alignmentBaseline`.
`TextBaseline.SUBSCRIPT` | The subscript baseline of the element aligns with the `alignmentBaseline`.
`TextBaseline.ASCENT` | The ascent baseline of the element aligns with the `alignmentBaseline`.
`TextBaseline.DESCENT` | The descent baseline of the element aligns with the `alignmentBaseline`.
`TextBaseline.IDEOGRAPHIC_TOP` | The ideographic top baseline of the element aligns with the `alignmentBaseline`.
`TextBaseline.IDEOGRAPHIC_CENTER` | The ideographic center baseline of the element aligns with the `alignmentBaseline`.
`TextBaseline.IDEOGRAPHIC_BOTTOM` | The ideographic bottom baseline of the element aligns with the `alignmentBaseline`.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Determines which of the baselines of the graphic element aligns with the `alignmentBaseline`.
`GroupElement` | Has no effect.
`TextElement` | Determines which of the baselines of the text element aligns with the `alignmentBaseline`.

Implementation
`public function get dominantBaseline():String`
`public function set dominantBaseline(value:String):void`
Throws

| `ArgumentError` — If set to any value which is not a member of `flash.text.engine.TextBaseline`.

See also

flash.text.engine.TextBaseline
flash.text.engine.ElementFormat.alignmentBaseline

fontDescription | property |

`fontDescription:FontDescription` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

An object which encapsulates properties necessary to describe a font

The default value is a default constructed FontDescription object.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Has no effect.
`TextElement` | Determines the font used for the text in the element.

Implementation
`public function get fontDescription():FontDescription`
`public function set fontDescription(value:FontDescription):void`

See also

flash.text.engine.FontDescription

fontSize | property |

`fontSize:Number` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The point size of text.

The default value is `12.0`.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Has no effect.
`TextElement` | Determines the point size for the text in the element.

Implementation
`public function get fontSize():Number`
`public function set fontSize(value:Number):void`
Throws

| `ArgumentError` — If set to a value less than zero.

kerning | property |

`kerning:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The kerning used for this text. Use `flash.text.engine.Kerning` constants for this property. Kerning adjusts the pixels between certain character pairs to improve readability. Kerning is supported for all fonts which have kerning tables.

The default value is `flash.text.engine.Kerning.ON`.

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

String value | Description
--- | ---
`Kerning.ON` | Kerning is enabled.
`Kerning.OFF` | Kerning is disabled.
`Kerning.AUTO` | Kerning is enabled only for characters appropriate in Asian typography. Kerning is applied between two characters if neither is Kanji, Hiragana or Katakana.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Determines whether kerning is applied between adjacent text elements in the group. if the elementFormat of the group is `null`, the format of the first of the adjacent elements is used.
`TextElement` | Determines whether kerning is applied between the characters in the text element.

Implementation
`public function get kerning():String`
`public function set kerning(value:String):void`

ligatureLevel | property |

`ligatureLevel:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The ligature level used for this text. Use `flash.text.engine.LigatureLevel` constants for this property.

The default value is `flash.text.engine.LigatureLevel.COMMON`.

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

String value | Description
--- | ---
`LigatureLevel.NONE` | No ligatures are created.
`LigatureLevel.MINIMUM` | Minimal ligatures are created.
`LigatureLevel.COMMON` | Common ligatures are created.
`LigatureLevel.UNCOMMON` | Uncommon ligatures are created.
`LigatureLevel.EXOTIC` | Exotic ligatures are created.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Determines the ligature level between adjacent text elements in the group. if the elementFormat of the group is `null`, the format of the first of the adjacent elements is used.
`TextElement` | Determines the ligature level between the characters in the text element.

Implementation
`public function get ligatureLevel():String`
`public function set ligatureLevel(value:String):void`
Throws

| `ArgumentError` — If set to any value which is not a member of `flash.text.engine.LigatureLevel`.

See also

flash.text.engine.LigatureLevel

locale | property |

`locale:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The locale of the text. Controls case transformations and shaping. Standard locale identifiers are used. For example "en", "en_US" and "en-US" are all English, "ja" is Japanese.

The default value is `"en"`.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Has no effect.
`TextElement` | Determines transformations and shaping for the text in the element.

Implementation
`public function get locale():String`
`public function set locale(value:String):void`

textRotation | property |

`textRotation:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

Sets the rotation applied to individual glyphs. Use `flash.text.engine.TextRotation` constants for this property.

The default value is `flash.text.engine.TextRotation.ROTATE_0`.

The final rotation of any glyph is the sum of `TextBlock.glyphRotation`, `ElementFormat.textRotation`, `ContentElement.textRotation`, and `TextBlock.lineRotation`.

`ElementFormat.textRotation` is seldom used. For the typical case of Asian text where characters must be rotated to display properly in vertical layout, setting `TextBlock.glyphRotation=flash.text.engine.GlyphRotation.FULL_AND_WIDE` and `TextBlock.lineRotation = flash.text.ROTATE_90` is the easiest and most reliable method.

Setting this property on fonts which do not contain vertical layout information can give undesirable results. Fonts that contain a vmtx or VORG table such as the Japanese font "MS Mincho" work correctly because those tables supply the data that the layout engine needs to do correct layout. Fonts do not contain the necessary information such as Verdana do not.

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

String value | Description
--- | ---
`TextRotation.ROTATE_0` | Glyphs are not rotated.
`TextRotation.ROTATE_90` | Glyphs are rotated 90 degrees clockwise.
`TextRotation.ROTATE_180` | Glyphs are rotated 180 degrees.
`TextRotation.ROTATE_270` | Glyphs are rotated 270 degrees clockwise.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Has no effect.
`TextElement` | Determines the rotation of the glyphs in the text element.

Implementation
`public function get textRotation():String`
`public function set textRotation(value:String):void`
Throws

| `ArgumentError` — If set to any value which is not a member of `flash.text.engine.TextRotation`.

See also

flash.text.engine.TextRotation
flash.text.engine.ContentElement.textRotation
flash.text.engine.TextBlock.glyphRotation
flash.text.engine.TextBlock.lineRotation

tracking | property |

`tracking:Number` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10.

The tracking or manual kerning in pixels. If `kerning` is enabled, the `tracking` value is added to the values in the kerning table for the font. If `kerning` is disabled, the `tracking` value is used as a manual kerning value. Supports both positive and negative values.

The default value is `0.0`.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Determines the tracking between adjacent text elements in the group. if the elementFormat of the group is `null`, the format of the first of the adjacent elements is used.
`TextElement` | Determines the tracking between the characters in the text element.

Example:

           //positive tracking added to kerning
           var ef1:ElementFormat = new ElementFormat();
           ef1.kerning = flash.text.engine.Kerning.ON;
           ef1.tracking = 0.5;
             //negative manual kerning
           var ef2:ElementFormat = new ElementFormat();
           ef2.kerning = flash.text.engine.Kerning.OFF;
           ef2.tracking = -1.0;

Implementation
`public function get tracking():Number`
`public function set tracking(value:Number):void`

typographicCase | property |

`typographicCase:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The typographic case used for this text. Use `flash.text.engine.TypographicCase` constants for this property.

The default value is `flash.text.engine.TypographicCase.DEFAULT`.

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

String value | Description
--- | ---
`TypographicCase.DEFAULT` | Applies default typographic case to the text.
`TypographicCase.TITLE` | Specifies that uppercase characters use title glyphs on output.
`TypographicCase.CAPS` | Specifies that spacing is adjusted for uppercase characters on output.
`TypographicCase.SMALL_CAPS` | Specifies that uppercase characters use small caps glyphs on output.
`TypographicCase.UPPERCASE` | Specifies that all characters use uppercase glyphs on output.
`TypographicCase.LOWERCASE` | Specifies that all characters use lowercase glyphs on output.
`TypographicCase.CAPS_AND_SMALL_CAPS` | Specifies that all lowercase characters use small caps glyphs on output.

Subclass | Effect of setting property
--- | ---
`GraphicElement` | Has no effect.
`GroupElement` | Has no effect.
`TextElement` | Determines the typographic case used for the text in the element.

Implementation
`public function get typographicCase():String`
`public function set typographicCase(value:String):void`
Throws

| `ArgumentError` — If set to any value which is not a member of `flash.text.engine.TypographicCase`.

See also

flash.text.engine.TypographicCase
Constructor Detail

ElementFormat | () | Constructor

`public function ElementFormat(fontDescription:FontDescription = null, fontSize:Number = 12.0, color:uint = 0x000000, alpha:Number = 1.0, textRotation:String = "rotate0", dominantBaseline:String = "roman", alignmentBaseline:String = "useDominantBaseline", baselineShift:Number = 0.0, kerning:String = "on", tracking:Number = 0.0, locale:String = "en", breakOpportunity:String = "auto", digitCase:String = "default", digitWidth:String = "default", ligatureLevel:String = "common", typographicCase:String = "default")`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

Creates a ElementFormat object.

Parameters

| `fontDescription:FontDescription` (default = `null`)`` — The FontDescription object which identifies the font used with this element format. The default value is `null`. If no font description is provided, a default font description is constructed.
| `fontSize:Number` (default = `12.0`)`` — The point size of text.
| `color:uint` (default = `0x000000`)`` — The color of text. A number containing three 8-bit RGB components; for example, 0xFF0000 is red, and 0x00FF00 is green.
| `alpha:Number` (default = `1.0`)`` — The `alpha` property applied to all line atoms based on the element format.
| `textRotation:String` (default = "`rotate0`")`` — the rotation applied to individual glyphs. Use `flash.text.engine.TextRotation` constants for this property.
| `dominantBaseline:String` (default = "`roman`")`` — The baseline to which the glyphs in the text snap. Use `flash.text.engine.TextBaseline` constants for this property.
| `alignmentBaseline:String` (default = "`useDominantBaseline`")`` — The baseline on the containing line to which the dominant baseline snap. Use `flash.text.engine.TextBaseline` constants for this property.
| `baselineShift:Number` (default = `0.0`)`` — The baseline shift for the text in pixels em.
| `kerning:String` (default = "`on`")`` — The kerning used for this text. Use `flash.text.engine.Kerning`.
| `tracking:Number` (default = `0.0`)`` — The tracking or manual kerning to be applied in pixels.
| `locale:String` (default = "`en`")`` — The locale of the text.
| `breakOpportunity:String` (default = "`auto`")`` — The line break opportunity applied to this text. Use `flash.text.engine.BreakOpportunity` constants for this property.
| `digitCase:String` (default = "`default`")`` — The digit case used for this text. Use `flash.text.engine.DigitCase` constants for this property.
| `digitWidth:String` (default = "`default`")`` — The digit width used for this text. Use `flash.text.engine.DigitWidth` constants for this property.
| `ligatureLevel:String` (default = "`common`")`` — The ligature level used for this text. Use `flash.text.engine.LigatureLevel` constants for this property.
| `typographicCase:String` (default = "`default`")`` — The typographic case used for this text. Use `flash.text.engine.TypographicCase` constants for this property.

Throws

| `ArgumentError` — The `fontSize` specified is less than 0.
| `ArgumentError` — The `textRotation` specified is not a member of `flash.text.engine.TextRotation`.
| `ArgumentError` — The `dominantBaseline` specified is not a member of `flash.text.engine.TextBaseline`.
| `ArgumentError` — The `alignmentBaseline` specified is not a member of `flash.text.engine.TextBaseline`.
| `ArgumentError` — The `kerning` specified is not a member of `flash.text.engine.Kerning`.
| `ArgumentError` — The `breakOpportunity` specified is not a member of `flash.text.engine.BreakOpportunity`.
| `ArgumentError` — The `digitCase` specified is not a member of `flash.text.engine.DigitCase`.
| `ArgumentError` — The `digitWidth` specified is not a member of `flash.text.engine.DigitWidth`.
| `ArgumentError` — The `ligatureLevel` specified is not a member of `flash.text.engine.LigatureLevel`.
| `ArgumentError` — The `typographicCase` specified is not a member of `flash.text.engine.TypographicCase`.

Method Detail

getFontMetrics | () | method

`public function getFontMetrics():FontMetrics`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

Returns a `FontMetrics` object with properties which describe the emBox, strikethrough position, strikethrough thickness, underline position, and underline thickness for the font specified by `fontDescription` and `fontSize`.

Returns

| `FontMetrics` — A `FontMetrics` object describing properties of the font specified by `fontDescription`.

See also

flash.text.engine.FontDescription
flash.text.engine.FontMetrics
Example
This example creates an `ElementFormat` object with an assigned `FontDescription` and uses the `getFontMetrics` method to display metrics for the chosen font.

    package {

        import flash.display.Sprite;
        import flash.text.engine.*;

        public class FontMetricsExample extends Sprite {

            public function FontMetricsExample():void {
                var fd:FontDescription = new FontDescription();
                fd.fontName = "Garamond";
                fd.fontWeight = flash.text.engine.FontWeight.BOLD;

                var ef1:ElementFormat = new ElementFormat(fd);
                var fm1:FontMetrics = ef1.getFontMetrics();
                trace(fm1.emBox);
                trace(fm1.strikethroughPosition);
                trace(fm1.strikethroughThickness);
                trace(fm1.subscriptScale);
                trace(fm1.superscriptScale);
                trace(fm1.underlinePosition);
                trace(fm1.underlineThickness);

            }
        }
    }

Examples How to use examples
ElementFormatExample.as
This example creates two `ElementFormat` objects and sets several of their properties. It then assigns the new ElementFormats to a `TextElement` object, which has been assigned as the content of a `TextBlock`. Note that changing the `ElementFormat` of a `TextElement` does not affect TextLines that have been previously created by the parent TextBlock.

    package {

        import flash.display.Sprite;
        import flash.text.engine.*;

        public class ElementFormatExample extends Sprite {

            public function ElementFormatExample():void {
                var fd:FontDescription = new FontDescription();
                fd.fontName = "Garamond";
                fd.fontWeight = flash.text.engine.FontWeight.BOLD;

                var ef1:ElementFormat = new ElementFormat(fd);
                ef1.fontSize = 30;
                ef1.color = 0xFF0000;
                ef1.alpha = 100;
                ef1.kerning = flash.text.engine.Kerning.ON;
                ef1.tracking = 2;
                ef1.typographicCase = flash.text.engine.TypographicCase.UPPERCASE;
                ef1.alignmentBaseline = flash.text.engine.TextBaseline.DESCENT;
                ef1.ligatureLevel = flash.text.engine.LigatureLevel.EXOTIC;

                var ef2:ElementFormat = new ElementFormat(fd);
                ef2.fontSize = 30;
                ef2.color = 0xFF0000;
                ef2.alpha = 30;
                ef2.kerning = flash.text.engine.Kerning.OFF;
                ef2.typographicCase = flash.text.engine.TypographicCase.LOWERCASE;
                ef2.digitCase = flash.text.engine.DigitCase.OLD_STYLE;
                ef2.textRotation = flash.text.engine.TextRotation.ROTATE_180;

                var str:String = "This is flash text 0123456789";
                var tb:TextBlock = new TextBlock();
                var te1:TextElement = new TextElement(str, ef1);
                tb.content = te1;
                var line1:TextLine = tb.createTextLine(null, 600);
                addChild(line1);
                line1.x = 15;
                line1.y = 30;

                tb.content.elementFormat = ef2;
                var line2:TextLine = tb.createTextLine(null, 600);
                addChild(line2);
                line2.x = 15;
                line2.y = 60;

            }
        }
    }

Submit Feedback on LiveDocs
© 2004-2008 Adobe Systems Incorporated. All rights reserved.
Tue May 20 2008, 04:02 AM -07:00