DekGenius.com
[ Team LiB ] Previous Section Next Section

Recipe 8.20 Embedding Fonts

8.20.1 Problem

You want to ensure that text will display properly even if the intended font is not installed on the user's computer.

8.20.2 Solution

Export the font in the movie's Library, set the text field's embedFonts property to true, and use a TextFormat object, setting its font property to the linkage identifier for the embedded font.

8.20.3 Discussion

You should embed fonts if you want to ensure that text will display using the intended font even if the font is not installed on the user's computer. To embed a font, follow these steps:

  1. Open the Flash document's Library and select New Font from the pop-up Options menu (see Figure 8-4). A Font Symbol Properties dialog box appears.

    Figure 8-4. Selecting New Font from the Library's pop-up Options menu
    figs/ascb_0804.gif
  2. In the Name field, specify the name given to the symbol in the Library. Any name will suffice, so specify a name that makes sense to you.

  3. From the Font drop-down list, select the font that you wish to embed.

  4. If you wish to include the bold and/or italic versions of the font as well, select the appropriate checkboxes. Be aware that including bold and italic font outlines will increase the file size significantly, so do so only if you really need them.

  5. Click OK in the Font Symbol Properties dialog box.

  6. Select the new Font symbol in the Library and choose Linkage from the pop-up Options menu.

  7. In the Linkage Properties dialog box, select the Export for ActionScript and Export in First Frame checkboxes.

  8. Give the symbol a linkage identifier. This is the name that will be used in the ActionScript code. The linkage identifier should be something that corresponds to the font. For example, if the font you are embedding is Garamond, you might give it a linkage identifier of garamondEmbedded.

  9. Click OK in the Linkage Properties dialog box.

  10. Set the embedFonts property of the text field to true. By default, the property is false, which means that Flash uses device fonts. By setting the embedFonts property to true, the text field can use embedded fonts only. If you attempt to assign a device font to a text field with embedFonts set to true, nothing will be displayed.

    myTextField.embedFonts = true;
  11. Set the TextFormat.font property to the linkage identifier of the embedded font. If this value is not found, no text is displayed.

    myTextFormat.font = "garamondEmbedded";
  12. Apply the TextFormat object to the text field using setTextFormat( ):

    myTextField.setTextFormat(myTextFormat);

8.20.4 See Also

Recipe 8.16 and Recipe 8.19

    [ Team LiB ] Previous Section Next Section