30.11.2012 Views

Using Adobe® Flex® 4 - Adobe Blogs

Using Adobe® Flex® 4 - Adobe Blogs

Using Adobe® Flex® 4 - Adobe Blogs

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.

USING FLEX 4<br />

Fonts<br />

You can also embed fonts in ActionScript by using the [Embed] metadata tag. As with the @font-face declaration,<br />

you must specify a separate [Embed] tag for each font face.<br />

Note: Check your font licenses before embedding any font files in your Flex applications. Fonts might have licensing<br />

restrictions that preclude them from being stored as vector information.<br />

If you attempt to embed a font that the Flex compiler cannot find, Flex throws an error and your application does not<br />

compile.<br />

Embedded font syntax<br />

[Chunk: No] [Output: IPH, Print, Web] [EditorialStatus: Preliminary Review]<br />

To embed TrueType or OpenType fonts, you use the following syntax in your style sheet or tag:<br />

@font-face {<br />

src: url("location");<br />

fontFamily: alias;<br />

[fontStyle: normal | italic | oblique] ;<br />

[fontWeight: normal | bold | heavy] ;<br />

[advancedAntiAliasing: true | false];<br />

[embedAsCFF:true|false] ;<br />

}<br />

The src property specifies the location and filename of the font.<br />

The fontFamily property sets the alias for the font that you use to apply the font in style sheets. This property is<br />

required. If you embed a font with a family name that matches the family name of a system font, the Flex compiler<br />

gives you a warning. You can disable this warning by setting the show-shadows-system-font-warnings compiler<br />

option to false.<br />

The fontStyle and fontWeight properties set the type face values for the font. These properties are optional, unless<br />

you are embedding a face that requires them. The default values are normal.<br />

The advancedAntiAliasing property determines whether to include the advanced anti-aliasing information when<br />

embedding the font. This property is optional. This property is ignored if you embed a font with the embedAsCFF<br />

property set to true. You cannot use this option when embedding fonts from a SWF file (see Embedding fonts from<br />

SWF files). For more information on using advanced anti-aliasing, see “<strong>Using</strong> advanced anti-aliasing with non-CFF<br />

based fonts” on page 9.<br />

The embedAsCFF (Compact Font Format) property indicates whether to embed an FTE-enabled font for components.<br />

Flash Text Engine (FTE) is a library that provides text controls with a rich set of formatting options.<br />

If you set the embedAsCFF property to true, then the embedded font will let you use the advanced formatting features<br />

of FTE such as bidirectional text, kerning, and ligatures. If you set the value of embedAsCFF to false, then the<br />

embedded font will not support FTE, and will work only with the Halo text components. If you use Halo text<br />

components in Flex 4 application, you might need to embed the same font multiple times (once with embedAsCFF set<br />

to true and once with embedAsCFF set to false). The default value is true. Alternatively, you can use FTE-based<br />

classes for text rendering in your Halo text controls. For more information, see “Embedding fonts with Halo<br />

components” on page 24.<br />

The following example embeds the MyriadWebPro.ttf font file:<br />

@font-face {<br />

src: url("../assets/MyriadWebPro.ttf");<br />

fontFamily: myFontFamily;<br />

embedAsCFF: true;<br />

}<br />

5

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

Saved successfully!

Ooh no, something went wrong!