Table of Contents

TextFormat.size Property Flash 6

specifies character font size, in points read/write
theFormat.size

Description

The integer size property specifies character font size, in points (1/72 inch). By increasing the size property, we increase the size of on-screen text. Text in a font size that exceeds the dimensions of a text field's bounding box will appear cut off. To size a text field's bounding box, use the TextField._height, TextField._width, or TextField.autoSize properties.

To set the font size for an entire text field, invoke TextField.setTextFormat( ) without specifying any index arguments:

this.createTextField("theField_txt", 1, 0, 0, 250, 40);
theField_txt.border = true;
theField_txt.text = "This text is quite large.";
// Create a TextFormat object
format = new TextFormat();
format.size = 26;
// Set the whole field to 26 pt
theField_txt.setTextFormat(format);

To set the font size for a single character, apply the format with a single index argument:

theField_txt.setTextFormat(5, format); // Set the sixth character ("t") to 26 pt

To set the font size for a range of characters, apply the format with start and end index arguments:

theField_txt.setTextFormat(19, 24, format);  // Set size for
                                             // characters 19-23 ("large")

The default size value (as contained in the TextFormat object returned by TextField.getTextFormat( )) for a text field that contains text is 12. For a text field without any text, the size value is null. For a completely new TextFormat object, it is also null, indicating that size will not be set when the format is applied to a text field:

trace(anyUnformattedField_txt.getTextFormat().size);  // Displays: 12
var format = new TextFormat();
trace(format.size);                                   // Displays: "null"

Note that when font embedding is enabled for a text field, that field's text is always antialiased. Therefore, using embedded fonts with sizes smaller than 10-point is not recommended because antialiased text becomes unreadable below 10-point in most fonts. To prevent a font from antialiasing, use device fonts (i.e., system fonts) by setting TextField.embedFonts to false. Device fonts are never antialiased. Pixel fonts that display clearly at small font sizes are available commercially from sites such as http://www.miniml.com and http://www.fontsforflash.com.

Usage

Technically, a font's size is measured in pixels, not points. However, because most desktop displays render at 72 pixels per inch, we normally can use the terms "pixel" and "point" interchangeably. But on devices with non-72 ppi display, Flash does not automatically perform any coordinate space conversions�a size of 10 always means the font is 10 pixels high, even if the screen renders, say, 200 pixels per inch.

See Also

TextField.embedFonts, TextField._yscale, TextFormat.font, TextFormat.getTextExtent( )


Table of Contents