Package | flash.text |
Class | public class TextRenderer |
Inheritance | TextRenderer Object |
Player version: | Flash Player 8 |
To set advanced anti-aliasing on a text field, set the antiAliasType
property of the TextField instance. The following example requires a shared font in the library with a linkage identifier named, "CustomFont"
.
var txtFormat:TextFormat = new TextFormat(); txtFormat.font = "CustomFont"; var label:TextField = this.createTextField("label", this.getNextHighestDepth(), 10, 10, 200, 20); label.setNewTextFormat(txtFormat); label.text = "Hello World"; label.embedFonts = true; label.antiAliasType = "advanced";
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 | ||
---|---|---|
displayMode : String
[static]Controls the rendering of advanced anti-aliased text.
|
||
maxLevel : Number
[static]Sets the adaptively sampled distance fields (ADFs) quality level for advanced anti-aliasing.
|
Properties inherited from class Object | |
---|---|
__proto__, __resolve, constructor, prototype |
Method | ||
---|---|---|
setAdvancedAntialiasingTable(fontName:String, fontStyle:String, colorType:String, advancedAntialiasingTable:Array):Void
[static]Sets a custom continuous stroke modulation (CSM) lookup table for a font.
|
Methods inherited from class Object | |
---|---|
addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch |
displayMode | property |
public static var displayMode:String
Language version: | ActionScript 2.0 |
Player version: | 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.
The following values for displayMode
allow the designer to set the global subpixel rendering mode for advanced anti-aliasing:
"default"
allows Flash Player to choose LCD or CRT mode."lcd"
forces Flash Player to use LCD sub-pixel antialiasing. Depending on the font and the hardware, this setting can result in much higher-resolution text or "coloring" of text."crt"
forces Flash Player to display grayscale antialiasing. While this setting avoids the "coloring" of text, some users may think it appears more "fuzzy".Note: While this property is available for ActionScript 2.0, you can use it only when publishing to Flash Player 9 or later.
maxLevel | property |
public static var maxLevel:Number
Player version: | Flash Player 8 |
Sets the adaptively sampled distance fields (ADFs) quality level for advanced anti-aliasing. The only acceptable values are 3, 4, and 7. The default is 4.
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
.
maxLevel
value for the entire SWF file, and then displays a text field with the value set. For the text in this example to display correctly, there must be a font symbol available with a linkage identifier of "CustomFont"
. import flash.text.TextRenderer; TextRenderer.maxLevel = 3; var txtFormat:TextFormat = new TextFormat(); txtFormat.font = "CustomFont"; txtFormat.size = 64; var label:TextField = this.createTextField("label", this.getNextHighestDepth(), 10, 10, 500, 100); label.setNewTextFormat(txtFormat); label.text = "Hello World"; label.embedFonts = true; trace("TextRenderer.maxLevel: " + TextRenderer.maxLevel);
setAdvancedAntialiasingTable | () | method |
public static function setAdvancedAntialiasingTable(fontName:String, fontStyle:String, colorType:String, advancedAntialiasingTable:Array):Void
Player version: | Flash Player 8 |
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 can be "bold" , "bolditalic" , "italic" , and "none" . |
|
colorType:String — This value can be either "dark" or "light" . |
|
advancedAntialiasingTable:Array — An array of CSM settings for the specified font. Each setting is an object with the following properties:
The The Advanced anti-aliasing uses adaptively sampled distance fields (ADFs) to represent the outlines that determine a glyph. Adobe 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. |
"myArial"
. To embed the font, follow these steps: import flash.text.TextRenderer; var antiAliasEntry_1 = {fontSize:24, insideCutoff:1.61, outsideCutoff:-3.43}; var antiAliasEntry_2 = {fontSize:48, insideCutoff:0.8, outsideCutoff:-0.8}; var arialTable:Array = new Array(antiAliasEntry_1, antiAliasEntry_2); var lbl_1:TextField = createLabel(0, 0, 300, 100, 24); var lbl_2:TextField = createLabel(0, 100, 300, 100, 48); TextRenderer.setAdvancedAntialiasingTable("Arial", "none", "dark", arialTable); function createLabel(x:Number, y:Number, width:Number, height:Number, fontSize:Number):TextField { var depth:Number = this.getNextHighestDepth(); var tmpTxt = this.createTextField("txt_" + depth, depth, x, y, width, height); tmpTxt.antiAliasType = "advanced"; tmpTxt.gridFitType = "pixel"; tmpTxt.border = true; tmpTxt.text = "Hello World"; tmpTxt.embedFonts = true; tmpTxt.setTextFormat(getTextFormat(fontSize)); return tmpTxt; } function getTextFormat(fontSize:Number):TextFormat { var tf:TextFormat = new TextFormat(); tf.align = "center"; tf.size = fontSize; tf.font = "myArial"; return tf; }