Search code examples
actionscript-3flashfontstextfieldjsfl

What methods are there for creating FLAs with dynamically created text, that outputs swfs with only the font glyphs included that are required?


When I create an FLA with static text fields it only includes the glyphs that are in the text fields. This is the behaviour required, but I want to create those text fields from XML.

I want to be able to create an FLA with dynamic text fields so that I can populate them using a config ( XML ) file, and then the output is like an FLA with static text fields - so that I use as few glyphs as possible.

Is this possible?

I suppose I could write a .jsfl script to read an XML file to make this work on a template FLA file?

Any other methods?


Solution

  • You could embed the font using the embed statement in which you can define a unicode range.

    For example:

    [Embed(source="../someFont.ttf", 
        fontName = "myFont", 
        fontWeight="normal", 
        fontStyle="normal", 
        unicodeRange="U+0030-0039,U+002E", 
        embedAsCFF="false")]
    private var myEmbeddedFont:Class;
    

    (Note that you can embed multiple Unicode ranges / single characters by separating them with a comma.)

    (source)

    You could also use the fontswf utility which is a command-line utility which generates an swf with an embedded font. You can define character ranges here as well.