Properties | Methods |
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.
TextField.antiAliasType |
Property Summary | |
static | maxLevel : Number
The adaptively sampled distance fields (ADFs) quality level for advanced anti-aliasing. |
Properties inherited from class Object |
__proto__, __resolve, constructor, prototype |
Method Summary | |
static | setAdvancedAntialiasingTable(fontName:String, fontStyle:String, colorType:String, advancedAntialiasingTable:Array) : Void
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 |
Property Detail |
public static maxLevel : Number
Player version: | Flash Player 8 |
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);
Method Detail |
public static setAdvancedAntialiasingTable(fontName:String, fontStyle:String, colorType:String, advancedAntialiasingTable:Array) : Void
Player version: | Flash Player 8 |
Flash Player only includes advanced anti-aliasing settings for 10 basic fonts; and for these fonts, advanced anti-aliasing settings are only provided for the font sizes from 6 to 20. For these fonts, all sizes below 6 use the settings for 6; all sizes above 20 use the settings for 20. Other fonts map to the supplied font data. The setAdvancedAntialiasingTable()
method lets you set custom anti-aliasing data for other fonts and font sizes, or override the default settings for the provided fonts.
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. Macromedia Flash 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 bilevel 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. Under most circumstances, a gamma exponent equal to 1 is adequate. However, when subpixel rendering [Liquid Crystal Display mode (LCD)], you use the gamma exponent to mitigate color fringing artifacts that occur when rendering typefaces with thin strokes (for example, Times Roman) and small point sizes. You can also use the gamma exponent to enhance contrast in both Cathode Ray Tube (CRT) and LCD modes. |
"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; }
Properties | Methods |