Fonts

Flash supports both system fonts and embedded fonts. If you use one of the three default fonts?"_sans", "_serif", or "_typewriter"?the Flash Player finds the closest font on the user's system at runtime. The "_sans" font (equivalent to sans-serif in HTML/CSS) typically corresponds to Arial on Windows and Helvetica on the Mac. For the "_serif" and "_typewriter" default fonts (equivalent to serif and mono in HTML/CSS), Flash uses Times and Courier or other closely matched fonts.

Font outline information can be embedded in the SWF to allow you to perform text effects [Hack #48], such as rotating text. You don't have to embed default fonts in the SWF, but system fonts don't include vector information, so Flash cannot treat text formatted with a system font as graphics. Thus, text that uses system fonts typically disappears from the Stage if you rotate or scale the clip containing the text. If you try to embed one of the default fonts ("_sans", "_serif", or "_typewriter"), Flash embeds the closest font it finds on your development system at compile time. At runtime, the text can be rotated, scaled, and animated because Flash uses the embedded font information, not the system font from the end user's computer.

This chapter presents hacks for keeping text legible, implementing autocomplete text fields, importing text with complicated formatting, using CSS text, and using accessibility text as tool tips. Other text-related hacks, which discuss techniques such as transition effects created with text and masks [Hack #2], are sprinkled throughout the book.