AS3 Unicode Font Inclusion
During the final throws of a recent project, it occured to me that usual method of including various language specific unicode glyphs, had changed significantly in Flex / non-flash IDE developement.
Gone are the old days of simply selecting the character sets required, using the good old ‘Embed’ dropdown, in the property inspector for the textfield in use.
The purpose of this post was basically to get down in black and white, the process of achieving this by directly embedding the font using the Embed matadata tag — as I know it’s something people regularly have problems with. (including myself!)
The process can be seen as beneficial in opposing ways, as it can be both used to reduce the size of the resulting swf by excluding unwanted glyphs, and also to extend the character sets available by including addition glyphs for other languages.
To specify a certain range of glyphs, we first need to know our range, and it’s corresponding set of unicode values. Hit the following link to gather what you need:
Alternatively, Adobe provides a good reference, flash-unicode-table.xml, which you can find inside the Flex SDK 2/frameworks folder. You can then modify the flex-config.xml file, also found in the same folder, and use the “shortcuts” found in the flash-unicode-table.xml. With this you can set the Unicode range for your embedded fonts easily, let’s say we have set “English” as a shortcut in the flex-config.xml file:
[Embed(source='assets/ttf/gothic.ttf', fontName='CenturyGothic',
mimeType='application/x-font', unicodeRange="English")]
You can also bypass these flex-config “shortcuts” and just layout your unicode range in place of the “English” shortcut in the above example.
Unfortunately in the Flash IDE, creating a Font instance in the library provides no real workaround to specify a unicode range, and only provides access to Basic Latin characters.
Further reading:
Latin characters in Unicode — Wikipedia
Setting character ranges — Adobe
Specifying custom named unicode ranges in flex
A to Z Index of Unicode Characters