13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Using the Flash Text Engine<br />

Defining font characteristics (FontDescription object)<br />

Flash Player 10 and later, Adobe AIR 1.5 and later<br />

The fontName property of the FontDescription object can be a single name or a comma-separated list of names. For<br />

example, in a list such as “Arial, Helvetica, _sans”, the text <strong>en</strong>gine looks for “Arial” first, th<strong>en</strong> “Helvetica”, and finally<br />

“_sans”, if it can’t find either of the first two fonts. The set of font names include three g<strong>en</strong>eric device font names:<br />

“_sans”, “_serif”, and “_typewriter”. They map to specific device fonts, dep<strong>en</strong>ding on the playback system. It is good<br />

practice to specify default names such as these in all font descriptions that use device fonts. If no fontName is specified,<br />

“_serif” is used as the default.<br />

The fontPosture property can either be set to the default (FontPosture.NORMAL) or to italics<br />

(FontPosture.ITALIC). The fontWeight property can be set to the default (FontWeight.NORMAL) or to bold<br />

(FontWeight.BOLD).<br />

var fd1:FontDescription = new FontDescription();<br />

fd1.fontName = "Arial, Helvetica, _sans";<br />

fd1.fontPosture = FontPosture.NORMAL;<br />

fd1.fontWeight = FontWeight.BOLD;<br />

Embedded versus device fonts<br />

Flash Player 10 and later, Adobe AIR 1.5 and later<br />

The fontLookup property of the FontDescription object specifies whether the text <strong>en</strong>gine looks for a device font or<br />

embedded font to r<strong>en</strong>der text. If a device font (FontLookup.DEVICE) is specified, the runtime looks for the font on the<br />

playback system. Specifying an embedded font (FontLookup.EMBEDDED_CFF) causes the runtime to look for an<br />

embedded font with the specified name in the SWF file. Only embedded CFF (Compact Font Format) fonts work with<br />

this setting. If the specified font is not found, a fallback device font is used.<br />

Device fonts result in a smaller SWF file size. Embedded fonts give you greater fidelity across platforms.<br />

var fd1:FontDescription = new FontDescription();<br />

fd1.fontLookup = FontLookup.EMBEDDED_CFF;<br />

fd1.fontName = "Garamond, _serif";<br />

R<strong>en</strong>dering mode and hinting<br />

Flash Player 10 and later, Adobe AIR 1.5 and later<br />

CFF (Compact Font Format) r<strong>en</strong>dering is available starting with Flash Player 10 and Adobe AIR 1.5. This type of font<br />

r<strong>en</strong>dering makes text more legible, and permits higher-quality display of fonts at small sizes. This setting only applies<br />

to embedded fonts. FontDescription defaults to this setting (R<strong>en</strong>deringMode.CFF) for the r<strong>en</strong>deringMode<br />

property. You can set this property to R<strong>en</strong>deringMode.NORMAL to match the type of r<strong>en</strong>dering used by Flash Player<br />

7 or earlier versions.<br />

Wh<strong>en</strong> CFF r<strong>en</strong>dering is selected, a second property, cffHinting, controls how a font’s horizontal stems are fit to the<br />

subpixel grid. The default value, CFFHinting.HORIZONTAL_STEM, uses CFF hinting. Setting this property to<br />

CFFHinting.NONE removes hinting, which is appropriate for animation or for large font sizes.<br />

var fd1:FontDescription = new FontDescription();<br />

fd1.r<strong>en</strong>deringMode = R<strong>en</strong>deringMode.CFF;<br />

fd1.cffHinting = CFFHinting.HORIZONTAL_STEM;<br />

Last updated 6/6/2012<br />

410

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!