Introduction to Localization and Fonts

Font Overview and Capabilities

Scaleform provides an efficient and flexible font and localization system. Multiple fonts, point sizes, and styles can be simultaneously rendered efficiently and with a low memory footprint. Font data can be obtained from embedded Flash fonts, shared font libraries, the operating system, and directly from TTF font libraries. Vector-based font compression reduces the memory footprint of large Asian fonts. Font support is fully cross platform and works equally well on console systems, Windows, and Linux. Full documentation on Scaleform’s font and internationalization capabilities can be found in Font and Text Configuration Overview.

Typical font solutions involve rendering each character of an entire font to a texture and then characters would be texture mapped from the font texture to the screen as needed. Additional textures would be required for different font sizes and styles. For Latin characters the memory usage is acceptable, but rendering an Asian font with 5000 glyphs to a texture is impractical. A large amount of valuable texture memory is required as well as processing time to render each glyph. Simultaneously rendering different font sizes and styles is out of the question.

Scaleform solves this problem with a dynamic font cache. Characters are rendered on demand to the cache, and slots in the cache are replaced when necessary. Different font sizes and styles can share a single public cache using Scaleform’s intelligent glyph-packing algorithm. Scaleform works with vector fonts, meaning only a single TTF font needs to be stored in memory to render crisp and clear characters of any size. Finally, Scaleform supports “fake italic” and “fake bold” functionality, enabling a single regular font’s vector representation to be transformed to italic or bold on demand, saving additional memory.

Very large text can be rendered directly as tessellated triangles. This is useful for small quantities of large text, as might be found in a game’s title screen. Find the font configuration example in Bin\Data\AS2\Samples\FontConfig and drag the sample.swf file onto an open Scaleform Player D3D9 window.

Figure 4a: Small Chinese characters

Figure 4b: Wireframe representation

Pressing CTRL+W to view the wireframe representation of these characters shows that each character is represented as two texture mapped triangles. Since these are smaller characters it is more efficient to render them as bitmaps through the dynamic font cache.

Increase the size of the window while staying in wireframe mode. The characters will switch from rendering with texture maps to rendering as solid color triangles:

Figure 4c: Large Chinese character

Figure 4d: Wireframe representation

For large characters, it is more efficient to render as solid color triangles. Operating on large bitmaps is costly due to excessive memory bandwidth usage. Only pixels that require color are set, avoiding wasting processing power on the empty areas of the character. In figures 4c and 4d, Scaleform detected the size of the character passed a certain threshold and tessellated it into triangles, rendering the character as geometry instead of as a bitmap.

Font soft shadow, blur, and other effects are supported. Simply set the appropriate filters on the text field in Flash to generate the desired effect. Additional details are in the Font and Text Configuration Overview linked to above.

Figure 5: Text effects