Recipe 7.9. Optimizing Static Text for Minimum File Size


Problem

You want to optimize the Flash movie's file size by using fonts on the client computer rather than embedding the fonts in the SWF.

Solution

Select the static text, and check the Use Device Fonts checkbox in the Property inspector.

Discussion

When you use static text in your movies, Flash embeds the font outline in the Flash movie by default. This result has several benefits:

  • Embedded fonts are anti-aliased, resulting in smoother-looking text at larger point sizes.

  • Embedded fonts can be scaled, rotated, and alpha tweened.

  • The text will always appear in the correct font regardless of what client is playing the movie.

Although it may sound like embedded fonts are the optimal solution in every scenario, they have at least one major drawback: embedded fonts increase file size. If you embed the font outlines for every character in a font, it can add 10KB or more for a standard Latin character font. It can add even more when you embed nonstandard Latin characters. Double-byte fonts, such as those used for Chinese and Japanese, can require significantly more file size.

Static text fields embed fonts by default. However, they embed the outlines only for the characters they use. Therefore, a short text field with only a few characters isn't likely to add much in terms of file size to a SWF. However, if you need to embed the outlines for a font in order to display paragraphs of text, it's likely that it will add significantly more to the file size of the SWF.

If you must embed the font, or if you want to embed the font, and the added file size is not an issue for the project, there is no need to use any custom settings. However, if you find that you need to optimize the SWF in terms of file size, Flash lets you specify whether a static text field should use device fonts rather than embedded fonts delivered with the movie. To specify that a static text field should use device fonts, select the text field with the Selection tool, and then select the Use Device Fonts option from the Font rendering method menu in the Property inspector.

In the event that you want to use device fonts in order to reduce file size, plan carefully. For example, if you have two static text fields using Arial as the font, and both text fields contain significant text, it will have little effect on file size if you select Use Device Fonts for just one of the text fields.

Another important thing to keep in mind is what Flash does if it cannot find the device font on the client computer. Flash is designed so that if it cannot find the requested device font, it simply substitutes a default, available font (usually something like Times New Roman). In some situations, you may not care about this kind of substitution. But other times you may want to ensure that the font style at least remains similar by substituting serif fonts for serif fonts, sans serif fonts for sans serif fonts, and so on. Flash provides you with a solution to this problem as well. In the Font selection menu (in the Property inspector), you have three options for what are called device font types. The _sans option will always use the default available sans serif device font, such as Arial or Helvetica. The _serif option tells Flash to use the default available serif device font, such as Times New Roman. And the _typewriter option tells Flash to use the default available monospace font, such as Courier or Courier New.




Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net