Package | flash.text |
Class | public final class TextRenderer |
Inheritance | TextRenderer Object |
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
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.
Related API Elements
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-aliased 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 | ||
---|---|---|---|
Indicates whether an object has a specified property defined. | Object | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
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 | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Returns the string representation of the specified object. | Object | ||
Returns the primitive value of the specified object. | Object |
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
Related API Elements
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
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:
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. |
Related API Elements
- Place the Georgia font, named georgia.ttf in the same directory as this AS file.
- Add the following lines directly underneath the class definition:
[Embed(source="georgia.ttf", fontFamily="Georgia")]
private var embeddedFont:String;
- Place a text field on the stage and select it.
- In the Property Inspector, set that text field's font to Georgia
- 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; } } }
Mon Nov 28 2011, 06:48 AM -08:00