Adobe® Flex® 4 Language Reference
Hide Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
flash.text 
TextRenderer 
Packageflash.text
Classpublic final class TextRenderer
InheritanceTextRenderer Inheritance Object

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0 Flash Player 9

The TextRenderer class provides functionality for the advanced anti-aliasing capability of embedded fonts. Advanced anti-aliasing allows font faces to render at very high quality at small sizes. Use advanced anti-aliasing with applications that have a lot of small text. Adobe does not recommend using advanced anti-aliasing for very large fonts (larger than 48 points). Advanced anti-aliasing is available in Flash Player 8 and later only.

To set advanced anti-aliasing on a text field, set the antiAliasType property of the TextField instance.

Advanced anti-aliasing provides continuous stroke modulation (CSM), which is continuous modulation of both stroke weight and edge sharpness. As an advanced feature, you can use the setAdvancedAntiAliasingTable() method to define settings for specific typefaces and font sizes.

View the examples

See also



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  displayMode : String
[static] Controls the rendering of advanced anti-aliased text.
TextRenderer
  maxLevel : int
[static] The adaptively sampled distance fields (ADFs) quality level for advanced anti-aliasing.
TextRenderer
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Public Methods
 MethodDefined By
 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
  
setAdvancedAntiAliasingTable(fontName:String, fontStyle:String, colorType:String, advancedAntiAliasingTable:Array):void
[static] Sets a custom continuous stroke modulation (CSM) lookup table for a font.
TextRenderer
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail

displayMode

property
displayMode:String

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0 Flash Player 9

Controls the rendering of advanced anti-aliased text. The visual quality of text is very subjective, and while Flash Player tries to use the best settings for various conditions, designers may choose a different look or feel for their text. Also, using displayMode allows a designer to override Flash Player's subpixel choice and create visual consistency independent of the user's hardware. Use the values in the TextDisplayMode class to set this property.

The default value is "default".



Implementation
    public static function get displayMode():String
    public static function set displayMode(value:String):void

See also

maxLevel

property 
maxLevel:int

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0 Flash Player 9

The adaptively sampled distance fields (ADFs) quality level for advanced anti-aliasing. The only acceptable values are 3, 4, and 7.

Advanced anti-aliasing uses ADFs to represent the outlines that determine a glyph. The higher the quality, the more cache space is required for ADF structures. A value of 3 takes the least amount of memory and provides the lowest quality. Larger fonts require more cache space; at a font size of 64 pixels, the quality level increases from 3 to 4 or from 4 to 7 unless, the level is already set to 7.

The default value is 4.



Implementation
    public static function get maxLevel():int
    public static function set maxLevel(value:int):void
Method Detail

setAdvancedAntiAliasingTable

()method
public static function setAdvancedAntiAliasingTable(fontName:String, fontStyle:String, colorType:String, advancedAntiAliasingTable:Array):void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0 Flash Player 9

Sets a custom continuous stroke modulation (CSM) lookup table for a font. Flash Player attempts to detect the best CSM for your font. If you are not satisfied with the CSM that the Flash Player provides, you can customize your own CSM by using the setAdvancedAntiAliasingTable() method.

Parameters

fontName:String — The name of the font for which you are applying settings.
 
fontStyle:String — The font style indicated by using one of the values from the flash.text.FontStyle class.
 
colorType:String — This value determines whether the stroke is dark or whether it is light. Use one of the values from the flash.text.TextColorType class.
 
advancedAntiAliasingTable:Array — An array of one or more CSMSettings objects for the specified font. Each object contains the following properties:
  • fontSize
  • insideCutOff
  • outsideCutOff

The advancedAntiAliasingTable array can contain multiple entries that specify CSM settings for different font sizes.

The fontSize is the size, in pixels, for which the settings apply.

Advanced anti-aliasing uses adaptively sampled distance fields (ADFs) to represent the outlines that determine a glyph. Flash Player uses an outside cutoff value (outsideCutOff), below which densities are set to zero, and an inside cutoff value (insideCutOff), above which densities are set to a maximum density value (such as 255). Between these two cutoff values, the mapping function is a linear curve ranging from zero at the outside cutoff to the maximum density at the inside cutoff.

Adjusting the outside and inside cutoff values affects stroke weight and edge sharpness. The spacing between these two parameters is comparable to twice the filter radius of classic anti-aliasing methods; a narrow spacing provides a sharper edge, while a wider spacing provides a softer, more filtered edge. When the spacing is zero, the resulting density image is a bi-level bitmap. When the spacing is very wide, the resulting density image has a watercolor-like edge.

Typically, users prefer sharp, high-contrast edges at small point sizes, and softer edges for animated text and larger point sizes.

The outside cutoff typically has a negative value, and the inside cutoff typically has a positive value, and their midpoint typically lies near zero. Adjusting these parameters to shift the midpoint toward negative infinity increases the stroke weight; shifting the midpoint toward positive infinity decreases the stroke weight. Make sure that the outside cutoff value is always less than or equal to the inside cutoff value.

See also

TextRendererExample2.as

The following example creates the TextRendererExample class to demonstrate visual examples of advanced anti-aliasing settings with small and large font sizes. Before testing this example, you will need to embed a font. If you are using Flex, embed a font in the following manner:
  1. Place the Georgia font, named georgia.ttf in the same directory as this AS file.
  2. Add the following lines directly underneath the class definition:
  3. [Embed(source="georgia.ttf", fontFamily="Georgia")]
  4. private var embeddedFont:String;
If you are using Flash, embed a font in the following manner:
  1. Place a text field on the stage and select it.
  2. In the Property Inspector, set that text field's font to Georgia
  3. In the Property Inspector, press "Embed..." and select "All"

Notes:

  • You will need to compile the SWF file with "Local playback security" set to "Access local files only".

package {
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.text.*;
    
    public class TextRendererExample2 extends Sprite {

        private var gutter:int = 10;

        public function TextRendererExample2() {
            createTextField(8,AntiAliasType.NORMAL);
            createTextField(8,AntiAliasType.ADVANCED);
            createTextField(24,AntiAliasType.NORMAL);
            createTextField(24,AntiAliasType.ADVANCED);
        }
            
        private function createTextField(fontSize:Number,antiAliasType:String):TextField {
            var tf:TextField = new TextField();
            tf.embedFonts = true;
            tf.autoSize = TextFieldAutoSize.LEFT;
            tf.antiAliasType = antiAliasType;
            tf.defaultTextFormat = getTextFormat(fontSize);
            tf.selectable = false;
            tf.mouseEnabled = true;
            tf.text = "The quick brown fox jumped over the lazy dog.";
            if(numChildren > 0) {
                var sibling:DisplayObject = getChildAt(numChildren - 1);
                tf.y = sibling.y + sibling.height + gutter;
            }
            addChild(tf);
            return tf;
        }
        
        private function getTextFormat(fontSize:Number):TextFormat {
            var format:TextFormat = new TextFormat();
            format.size = fontSize;
            format.font = "Georgia";
            return format;
        }
    }
}