Table of Contents

uiFonts

Required: Aspire UI Components Standard Edition

The uiFonts manager implements the use of embedded fonts loaded into the application via external SWF files during run-time.

The use of this manager makes it possible to use embedded fonts without compiling/embedding them into the application SWF. Instead, each individual font exists in its own external SWF file which can be loaded into the application during run-time.


Using uiFonts

uiFonts is a singleton class. To access the singleton instance, use uiFonts.manager.

Loading Font SWFs Automatically

Your application can be set up to load external Font SWFs automatically by calling the following line of code:

uiFonts.manager.load(); // ** call load() method without passing any parameter **

The list of Font SWFs to load is specified in “text.css” (this is the same CSS file containing text styles used in your application, stored in the theme folder which by default is “assets/skins/default/”). The loading directive is declared in the CSS as follows:

@load
{
    fonts:Tahoma;
}

The above would tell the uiFonts manager to load “Tahoma.swf” into your application when the CSS is parsed.

@load
{
    fonts:Arial,Comic Sans MS,Verdana;
}

The above would load “Arial.swf”, “Comic_Sans_MS.swf” and “Verdana.swf”.

The Font SWFs must be stored in the “assets/fonts/” folder. This path can be changed via the uiFonts.manager.path property:

uiFonts.manager.path = "someotherpath/"; // ** must end with trailing slash **

NOTE: The automatic loading of the Font SWFs is initiated after the uiTextStyles manager is initialized (completes loading and parsing “text.css”).

Loading Font SWFs Manually

A Font SWF can also be loaded in an ad-hoc basis by calling the load() method at the desired time in your application, passing in the name of the font as the parameter.

uiFonts.manager.load("Tahoma"); // ** load "Tahoma.swf" **

To load multiple fonts, you can either call the load() method multiple times, or simply specify a comma-delimited list of the fonts to load:

uiFonts.manager.load("Tahoma,Comic Sans MS,Verdana"); // ** load "Tahoma.swf", "Comic_Sans_MS.swf" and "Verdana.swf" **

NOTE: The uiFonts manager will load each font only once.

Automatic Invalidation

Once a Font SWF is loaded, the uiTextStyles manager is notified and any affected text style(s) will be invalidated, and existing uiText instances on the display list that are affected will be redrawn.


Assets

Font SWFs should be stored in the folder “assets/fonts/”. Each Font SWF contains one font and should be named after that font.

IMPORTANT NOTE: Before compiling fonts into SWF files, read the font EULA to see if permission to do so has been granted. If in doubt, contact the font vendor for advice before proceeding.

Creating a Font SWF

To create a Font SWF, follow the steps below:

Library -> New Font...


Font Symbol Properties


Bold, Bold Italic and Italic versions


Right Click symbol and select Linkage...


Right Click symbol and select Linkage...


Right Click symbol and select Linkage...



API Reference

For more information on the members of the com.ghostwire.ui.managers.uiFonts class, please refer to the API Reference.


1) , 2) If the font name has spaces in it, convert those spaces to underscores.