| Package | flash.text |
| Class | public final class TextRenderer |
| Inheritance | TextRenderer Object |
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.
See also
| Property | Defined by | ||
|---|---|---|---|
![]() | constructor : 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-aliasing text.
| TextRenderer | ||
| maxLevel : int
[static]
The adaptively sampled distance fields (ADFs) quality level for advanced anti-aliasing.
| TextRenderer | ||
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
| Method | Defined by | ||
|---|---|---|---|
|
setAdvancedAntiAliasingTable(fontName:String, fontStyle:String, colorType:String, advancedAntiAliasingTable:Array):void
[static]
Sets a custom continuous stroke modulation (CSM) lookup table for a font.
| TextRenderer | ||
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
![]() |
Returns the string representation of the specified object.
| Object | |
![]() |
Returns the primitive value of the specified object.
| Object | |
| displayMode | property |
displayMode:String [read-write]
Controls the rendering of advanced anti-aliasing 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".
public static function get displayMode():String
public function set displayMode(value:String):void
See also
| maxLevel | property |
maxLevel:int [read-write]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.
public static function get maxLevel():int
public function set maxLevel(value:int):void
| setAdvancedAntiAliasingTable | () | method |
public static function setAdvancedAntiAliasingTable(fontName:String, fontStyle:String, colorType:String, advancedAntiAliasingTable:Array):void
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.
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:
The The Advanced anti-aliasing uses adaptively sampled distance fields (ADFs) to
represent the outlines that determine a glyph. Flash Player uses an outside cutoff value
( 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
createLabel()
and passing it font sizes of 24 and 48.clickHandler() event listener is attached to both of the TextField objects
that listen for click events. If either of the TextField objects is clicked,
clickHandler() displays information about the event and an antiAliasEntry variable
is set and later passed to a new Array named veradanaTable. The
setAdvancedAntiAliasingTable() method of TextRenderer is called and passed the
verdanaTable Array instance.Notes:
package {
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.*;
import flash.text.*;
public class TextRendererExample extends Sprite {
[Embed(source="verdana.ttf", fontFamily="Verdana")]
private var verdana:String;
private var fontFamily:String = "Verdana";
private var gutter:int = 10;
public function TextRendererExample() {
var label1:TextField = createLabel(24);
label1.name = "label-24";
var label2:TextField = createLabel(48);
label2.name = "label-48";
label1.addEventListener(MouseEvent.CLICK, clickHandler);
label2.addEventListener(MouseEvent.CLICK, clickHandler);
}
public function clickHandler(event:Event):void {
trace("clickHandler target: " + event.target.name);
var antiAliasEntry:CSMSettings;
if(event.target.name == "label-24") {
antiAliasEntry = new CSMSettings(24, 1.61, -3.43);
} else if(event.target.name == "label-48") {
antiAliasEntry = new CSMSettings(48, 0.8, -0.8);
}
var verdanaTable:Array = new Array(antiAliasEntry);
TextRenderer.setAdvancedAntiAliasingTable(fontFamily, FontStyle.REGULAR, TextColorType.DARK_COLOR, verdanaTable);
}
private function createLabel(fontSize:Number):TextField {
var label:TextField = new TextField();
label.embedFonts = true;
label.border = true;
label.autoSize = TextFieldAutoSize.LEFT;
label.antiAliasType = AntiAliasType.ADVANCED;
label.defaultTextFormat = getTextFormat(fontSize);
label.selectable = false;
label.mouseEnabled = true;
label.text = "Hello World";
if(numChildren > 0) {
var sibling:DisplayObject = getChildAt(numChildren - 1);
label.y = sibling.y + sibling.height + gutter;
}
addChild(label);
return label;
}
private function getTextFormat(fontSize:Number):TextFormat {
var format:TextFormat = new TextFormat();
format.color = 0xFFFFFF;
format.align = TextFormatAlign.CENTER;
format.size = fontSize;
format.font = fontFamily;
return format;
}
}
}