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: 12;
fontWeight: bold;
}
Panel {
paddingLeft: 10;
paddingTop: 10;
paddingBottom: 10;
paddingRight: 10;
}
</mx:Style>
<mx:Panel title="myClass Class Selector with Device Font">
<mx:VBox styleName="myClass">
<mx:Button label="Click Me"/>
<mx:Label text="This is a label."/>
<mx:TextArea width="200">
<mx:text>
The text in the TextArea control uses the myClass class selector.
</mx:text>
</mx:TextArea>
</mx:VBox>
</mx:Panel>
</mx:Application>
The executing SWF file for the previous example is shown below:
Flash Player supports three device fonts. The following table describes these fonts:
|
Font name |
Description |
|---|---|
| _sans |
The _sans device font is a sans-serif typeface; for example, Helvetica or Arial. |
| _serif |
The _serif device font is a serif typeface; for example, Times Roman. |
| _typewriter |
The _typewriter device font is a monospace font; for example, Courier. |
Using device fonts does not affect the size of the SWF file because the fonts reside on the client. However, using device fonts can affect 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.