Packageflash.text.engine
Classpublic final class FontDescription
InheritanceFontDescription Inheritance Object

Language Version : ActionScript 3.0
Player Version : Flash Player 10

The FontDescription class represents properties necessary to describe a font. The properties of the FontDescription class apply to device and embedded fonts.

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

View the examples

See also

flash.text.engine.ElementFormat.fontDescription


Public Properties
 PropertyDefined By
  antiAliasType : String
The type of anti-aliasing used for this text.
FontDescription
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  fontLookup : String
Specifies how the font should be looked up.
FontDescription
  fontName : String
The name of the font to be used, or a comma-separated list of font names.
FontDescription
  fontPosture : String
Specifies the font posture to be used.
FontDescription
  fontWeight : String
Specifies the font weight to be used.
FontDescription
  gridFitType : String
The type of grid fitting used for this text.
FontDescription
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  sharpness : Number
The sharpness of the glyph edges in this text.
FontDescription
  thickness : Number
The thickness of the glyph edges in this text.
FontDescription
Public Methods
 MethodDefined By
  
FontDescription(fontName:String = "_serif", fontWeight:String = "normal", fontPosture:String = "normal", fontLookup:String = "device", antiAliasType:String = "advanced", gridFitType:String = "pixel", sharpness:Number = 0.0, thickness:Number = 0.0)
Creates a FontDescription object.
FontDescription
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail
antiAliasTypeproperty
antiAliasType:String  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 10

The type of anti-aliasing used for this text. Use flash.text.AntiAliasType constants for this property.

Applies only to embedded fonts.

The default value is flash.text.AntiAliasType.ADVANCED.

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

String valueDescription
AntiAliasType.NORMALApplies the regular text anti-aliasing. This matches the type of anti-aliasing that Flash Player 7 and earlier versions used.
AntiAliasType.ADVANCEDApplies advanced anti-aliasing, which makes text more legible. (This feature became available in Flash Player 8.) Advanced anti-aliasing allows for high-quality rendering of font faces at small sizes. It is best used with applications that have a lot of small text. Advanced anti-aliasing is not recommended for fonts that are larger than 48 points.


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

Throws
ArgumentError — If set to any value which is not a member of flash.text.AntiAliasType.

See also

fontLookupproperty 
fontLookup:String  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 10

Specifies how the font should be looked up.

Applies only to device fonts.

The default value is flash.text.engine.FontLookup.DEVICE.

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

String valueDescription
FontLookup.DEVICEFlash Player looks up a device font with the specified name on the user's system with which to render the text.
FontLookup.EMBEDDEDFlash Player looks up an embedded font with the specified name with which to render the text. If the specified font is not embedded in the SWF file, Flash Player attempts to use a device fallback font for each glyph. This is less efficient than selecting a device font in the first place.


Implementation
    public function get fontLookup():String
    public function set fontLookup(value:String):void
fontNameproperty 
fontName:String  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 10

The name of the font to be used, or a comma-separated list of font names. Flash Player renders the element with the first available font in the list. For example "Arial, Helvetica, _sans" causes the player to search for "Arial", then "Helvetica" if Arial is not found, then _sans if neither is found.

Flash supports three generic device font names: _sans (similar to Helvetica and Arial), _serif (similar to Times Roman), and _typewriter (similar to Courier). These are mapped to specific device fonts depending on the platform.

The default value is "_serif".

Flash Player provides font fallback for glyphs which are not found in the selected font. Whether the font in use is embedded or device, if the glyph to be rendered is not found in the font, Flash Player attempts to render the glyph using another device font likely to contain the glyph.


Implementation
    public function get fontName():String
    public function set fontName(value:String):void
fontPostureproperty 
fontPosture:String  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 10

Specifies the font posture to be used.

Applies only to device fonts.

The default value is flash.text.engine.FontPosture.NORMAL.

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

String valueDescription
FontPosture.NORMALNormal font posture.
FontPosture.ITALICItalic font posture.


Implementation
    public function get fontPosture():String
    public function set fontPosture(value:String):void
fontWeightproperty 
fontWeight:String  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 10

Specifies the font weight to be used.

Applies only to device fonts.

The default value is flash.text.engine.FontWeight.NORMAL.

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

String valueDescription
FontWeight.NORMALNormal font weight.
FontWeight.BOLDBold font weight.


Implementation
    public function get fontWeight():String
    public function set fontWeight(value:String):void
gridFitTypeproperty 
gridFitType:String  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 10

The type of grid fitting used for this text. Use flash.text.GridFitType constants for this property. This property applies only if the flash.text.AntiAliasType property of the text is set to flash.text.AntiAliasType.ADVANCED.

The type of grid fitting used determines whether Flash Player forces strong horizontal and vertical lines to fit to a pixel or subpixel grid, or not at all.

Applies only to embedded fonts.

The default value is flash.text.GridFitType.PIXEL.

For the flash.text.GridFitType property, you can use the following string values:

String valueDescription
GridFitType.NONESpecifies no grid fitting. Horizontal and vertical lines in the glyphs are not forced to the pixel grid. This setting is appropriate for animation or for large font sizes.
GridFitType.PIXELSpecifies that strong horizontal and vertical lines are fit to the pixel grid. This setting works only for left-aligned text fields. To use this setting, the AntiAliasType property of the text field must be set to AntiAliasType.ADVANCED. This setting generally provides the best legibility for left-aligned text.
GridFitType.SUBPIXELSpecifies that strong horizontal and vertical lines are fit to the subpixel grid on an LCD monitor. To use this setting, the AntiAliasType property of the text field must be set to AntiAliasType.ADVANCED. The GridFitType.SUBPIXEL setting is often good for right-aligned or centered dynamic text, and it is sometimes a useful trade-off for animation versus text quality.


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

Throws
ArgumentError — If set to any value which is not a member of flash.text.GridFitType.

See also

flash.text.GridFitType
flash.text.EmbeddedFontProperties.antiAliasType
flash.text.AntiAliasType
sharpnessproperty 
sharpness:Number  [read-write]

The sharpness of the glyph edges in this text. This property applies only if the flash.text.AntiAliasType property is set to flash.text.AntiAliasType.ADVANCED. The range for sharpness is a number from -400 to 400. If you attempt to set sharpness to a value outside that range, Flash sets the property to the nearest value in the range (either -400 or 400).

Applies only to embedded fonts.

The default value is 0.0.


Implementation
    public function get sharpness():Number
    public function set sharpness(value:Number):void
thicknessproperty 
thickness:Number  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 10

The thickness of the glyph edges in this text. This property applies only when flash.text.AntiAliasType is set to flash.text.AntiAliasType.ADVANCED.

The range for thickness is a number from -200 to 200. If you attempt to set thickness to a value outside that range, the property is set to the nearest value in the range (either -200 or 200).

Applies only to embedded fonts.

The default value is 0.0.


Implementation
    public function get thickness():Number
    public function set thickness(value:Number):void

See also

Constructor Detail
FontDescription()Constructor
public function FontDescription(fontName:String = "_serif", fontWeight:String = "normal", fontPosture:String = "normal", fontLookup:String = "device", antiAliasType:String = "advanced", gridFitType:String = "pixel", sharpness:Number = 0.0, thickness:Number = 0.0)

Language Version : ActionScript 3.0
Player Version : Flash Player 10

Creates a FontDescription object.

Parameters
fontName:String (default = "_serif") — The name of the font to use, or a comma-separated list of font names.
 
fontWeight:String (default = "normal") — Specifies the font weight to use.
 
fontPosture:String (default = "normal") — Specifies the font posture to use.
 
fontLookup:String (default = "device") — indicates how the font should be looked up.
 
antiAliasType:String (default = "advanced") — The type of anti-aliasing used for this text. Use flash.text.AntiAliasType constants for this property.
 
gridFitType:String (default = "pixel") — The type of grid fitting used for this text. Use flash.text.GridFitType constants for this property.
 
sharpness:Number (default = 0.0) — The sharpness of the glyph edges in this text.
 
thickness:Number (default = 0.0) — The thickness of the glyph edges in this text.

Throws
ArgumentError — The fontWeight specified is not a member of flash.text.engine.FontWeight.
 
ArgumentError — The fontPosture specified is not a member of flash.text.engine.FontPosture.
 
ArgumentError — The fontLookup specified is not a member of flash.text.engine.FontLookup.
 
ArgumentError — The antiAliasType specified is not a member of flash.text.AntiAliasType.
 
ArgumentError — The gridFitType specified is not a member of flash.text.GridFitType.
Examples How to use examples
FontDescriptionExample.as

This example creates a FontDescription object, assigns an embedded font to it, sets various font properties, and assigns the new object to an ElementFormat object. Additional font formatting is done within ElementFormat. A new TextElement is created, using the ElementFormat, and the TextElement is used as content for a TextBlock. A line of text is created from the TextBlock.

To change the font settings for the TextBlock, alter the FontDescription object properties and reassign it to the ElementFormat. and re-link the ElementFormat to the TextBlock. This will invalidate all the text lines in the TextBlock without changing their appearance. When the lines are re-broken, the new lines will have the new font settings.


package {

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

    
    public class FontDescriptionExample extends Sprite {
        
        public function FontDescriptionExample():void {
            var fd:FontDescription = new FontDescription();
            fd.fontLookup = flash.text.engine.FontLookup.EMBEDDED;
            fd.fontName = "Palatino";
            fd.fontWeight = flash.text.engine.FontWeight.BOLD;
            fd.fontPosture = flash.text.engine.FontPosture.ITALIC;

            var ef1:ElementFormat = new ElementFormat(fd);
            ef1.fontSize = 30;
            ef1.color = 0xFF0000;
            ef1.alpha = 100;
            ef1.kerning = flash.text.engine.Kerning.ON;
            ef1.tracking = 1;
            ef1.typographicCase = flash.text.engine.TypographicCase.UPPERCASE;
            
            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;

            fd.fontWeight = flash.text.engine.FontWeight.NORMAL;
            fd.fontPosture = flash.text.engine.FontPosture.NORMAL;
            ef1.fontDescription=fd;
            tb.content.elementFormat=ef1;
            var line2:TextLine = tb.createTextLine(null, 600);
            addChild(line2);
            line2.x = 15;
            line2.y = 60;
            
        }
    }    
}