| Flex 2 Developer's Guide > Customizing the User Interface > Using Fonts > Using device fonts | |||
You can specify any font for the fontFamily property. However, not all systems have all font faces, which can result in an unexpected appearance of your controls. The safest course when specifying font faces is to include a device font as a default at the end of the font list. Device fonts do not export font outline information and are not embedded in the SWF file. Instead, Flash Player uses whatever font on the local computer most closely resembles the device font.
The following example specifies the device font _sans to use if Flash Player cannot find either of the other fonts on the client machine:
<?xml version="1.0"?>
<!-- fonts/DeviceFont.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Style>
.myClass {
fontFamily: Arial, Helvetica, "_sans";
color: Red;
fontSize: 22;
fontWeight: bold;
}
</mx:Style>
<mx:Panel title="myClass Class Selector with Device Font">
<mx:VBox styleName="myClass">
<mx:Button label="Click Me"/>
<mx:Label text="Label"/>
<mx:TextArea width="400" height="75" text="The text
uses the myClass class selector."
/>
</mx:VBox>
</mx:Panel>
</mx:Application>
|
NOTE |
|
You must surround device font names with quotation marks when defining them with style declarations. |
Flash Player supports three device fonts. The following table describes these fonts:
|
Font name |
Description |
|---|---|
_sans
|
The |
_serif
|
The |
_typewriter
|
The |
Using device fonts does not impact the size of the SWF file because the fonts reside on the client. However, using device fonts can impact performance of the application because it requires that Flash Player interact with the local operating system. Also, if you use only device fonts, your selection is limited to three fonts.
Flex 2.01