flash.text.engine

# FontMetrics - AS3

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

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The FontMetrics class contains measurement and offset information about a font. The `ElementFormat.getFontMetrics()` method returns objects of this class.

Related API Elements

ElementFormat.getFontMetrics()

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | emBox : Rectangle The emBox value represents the design space of the font and is used to place Chinese, Korean, or Japanese glyphs relative to the Roman baseline. | FontMetrics
|  | lineGap : Number The lineGap value is the suggested gap between lines. | FontMetrics
|  | strikethroughOffset : Number The strikethroughOffset value is the suggested vertical offset from the Roman baseline for a strikethrough. | FontMetrics
|  | strikethroughThickness : Number The strikethroughThickness value is the suggested thickness for a strikethrough. | FontMetrics
|  | subscriptOffset : Number The subscriptOffset value is the suggested vertical offset from the Roman baseline for a subscript. | FontMetrics
|  | subscriptScale : Number The subscriptScale value is the suggested scale factor to apply to the point size for a subscript. | FontMetrics
|  | superscriptOffset : Number The superscriptOffset value is the suggested vertical offset from the Roman baseline for a superscript. | FontMetrics
|  | superscriptScale : Number The superscriptScale value is the suggested scale factor to apply to the point size for a superscript. | FontMetrics
|  | underlineOffset : Number The underlineOffset value is the suggested vertical offset from the Roman baseline for an underline. | FontMetrics
|  | underlineThickness : Number The underlineThickness value is the suggested thickness for an underline. | FontMetrics

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | FontMetrics(emBox:Rectangle, strikethroughOffset:Number, strikethroughThickness:Number, underlineOffset:Number, underlineThickness:Number, subscriptOffset:Number, subscriptScale:Number, superscriptOffset:Number, superscriptScale:Number, lineGap:Number = 0.0)
Creates a FontMetrics object.
FontMetrics
|  | 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
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | 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

### emBox

property

`public var emBox:Rectangle`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The emBox value represents the design space of the font and is used to place Chinese, Korean, or Japanese glyphs relative to the Roman baseline. Typically a square, sized to the point size of the font. The origin (coordinate 0,0) of the emBox is set to the left edge and Roman baseline of the rect. For example, for a 10-point font, the emBox can be a rect [L,T,R,B] of [0, -8.8, 10, 1.2].

### lineGap

property

`public var lineGap:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10.3, AIR 2.6

The lineGap value is the suggested gap between lines.

This value is set by the font designer, and can vary widely from font to font. In a multi-script font, different line gaps may be suitable for different scripts; no single value may suffice. Furthermore, different kinds of text usage for a particular script (for example, whether Japanese text is annotated with ruby or not) may require different line gaps.

### strikethroughOffset

property

`public var strikethroughOffset:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The strikethroughOffset value is the suggested vertical offset from the Roman baseline for a strikethrough.

Note that depending on the rotation of the line, this value is either added or subtracted from the position of the line to find the position for the strikethrough. In a line with `TextRotation.ROTATE_0`, `strikethrough.y = line.y + strikethroughOffset`. In a line with `TextRotation.ROTATE_90`, `strikethrough.x = line.x - strikethroughOffset`.

When applying decorations such as strikethroughs to a `TextLine`, the recommended procedure is to specify an `eventMirror` on the `ContentElement` which is to receive the decoration. In response to the `Event.ADDED` event, the `bounds` of the `TextLineMirrorRegion` can be used in conjunction with the `strikethroughOffset` to place the strikethrough.

Related API Elements

ContentElement.eventMirror
TextLineMirrorRegion

### strikethroughThickness

property

`public var strikethroughThickness:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The strikethroughThickness value is the suggested thickness for a strikethrough.

### subscriptOffset

property

`public var subscriptOffset:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The subscriptOffset value is the suggested vertical offset from the Roman baseline for a subscript.

The subscriptOffset value is used with `ElementFormat.baselineShift` to position the subscript.

Related API Elements

ElementFormat.baselineShift

### subscriptScale

property

`public var subscriptScale:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The subscriptScale value is the suggested scale factor to apply to the point size for a subscript. A scale factor of 1.0 means no scaling.

### superscriptOffset

property

`public var superscriptOffset:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The superscriptOffset value is the suggested vertical offset from the Roman baseline for a superscript.

The superscriptOffset value is used with `ElementFormat.baselineShift` to position the superscript.

Related API Elements

ElementFormat.baselineShift

### superscriptScale

property

`public var superscriptScale:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The superscriptScale value is the suggested scale factor to apply to the point size for a superscript. A scale factor of 1.0 means no scaling.

### underlineOffset

property

`public var underlineOffset:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The underlineOffset value is the suggested vertical offset from the Roman baseline for an underline.

Note that depending on the rotation of the line, this value is either added or subtracted from the position of the line to find the position for the underline. In a line with `TextRotation.ROTATE_0`, `underline.y = line.y + underlineOffset`. In a line with `TextRotation.ROTATE_90`, `underline.x = line.x - underlineOffset`.

When applying decorations such as underlines to a `TextLine`, the recommended procedure is to specify an `eventMirror` on the `ContentElement` which is to receive the decoration. In response to the `Event.ADDED` event, the `bounds` of the `TextLineMirrorRegion` can be used in conjunction with the `underlineOffset` to place the underline.

Related API Elements

ContentElement.eventMirror
Event
TextLineMirrorRegion
TextRotation

### underlineThickness

property

`public var underlineThickness:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The underlineThickness value is the suggested thickness for an underline.

Constructor Detail

### FontMetrics

()
Constructor

`public function FontMetrics(emBox:Rectangle, strikethroughOffset:Number, strikethroughThickness:Number, underlineOffset:Number, underlineThickness:Number, subscriptOffset:Number, subscriptScale:Number, superscriptOffset:Number, superscriptScale:Number, lineGap:Number = 0.0)`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

Creates a FontMetrics object. The FontMetrics object contains information about the metrics of a font in an element format. The `flash.text.engine.ElementFormat.getFontMetrics()` method returns objects of this class.

Parameters

| `emBox:Rectangle` — The emBox of the font in pixels.
| `strikethroughOffset:Number` — The offset for a strikethrough in pixels.
| `strikethroughThickness:Number` — The thickness for a strikethrough in pixels.
| `underlineOffset:Number` — The offset for an underline in pixels.
| `underlineThickness:Number` — The thickness for an underline in pixels.
| `subscriptOffset:Number` — The offset for a subscript in pixels.
| `subscriptScale:Number` — The scale to apply to the point size of a subscript.
| `superscriptOffset:Number` — The offset for a superscript in pixels.
| `superscriptScale:Number` — The scale to apply to the point size of a superscript.
| `lineGap:Number` (default = `0.0`)``

Related API Elements

ElementFormat.getFontMetrics()

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00