setAdvancedAntialiasingTable (TextRenderer.setAdvancedAntialiasingTable method)

public static 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.

Availability: ActionScript 1.0; Flash Player 8

Parameters

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 advancedAntialiasingTable array can contain multiple entries that specify CSM settings for different font sizes. (See example.)

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. Adobe 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.

Example

The following example creates two anti-alias entries and two text fields to illustrate them. For this example to work, the SWF file must have a shared font embedded with a linkage identifier of "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;
}