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

十年热恋 提交于 2019-12-25 17:48:48

问题


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?


回答1:


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.




回答2:


Correct me if I've mis-understood but It sounds like you're assuming just because your text is coming from an XML (or any external source) you will somehow have all glyphs embeded by default to cover the "could be any text/characters" issue..
In reality though, just make your textfields and embed into them only the required font & its glyph elements (i.e tick only the necessary glyphs that you use in your XML text). So if its going to be just A(a) to (z)Z and digits 0 to 9 then you only tick Uppercase, Lowercase, and Numerals as shown below. This way you don't waste space with unused glyphs adding to the SWF size. Unsupported glyphs in XML should show as an empty space (or gibberish, depends how it feels).

Note: After embedding you still have to then set yourFONT as textfield's font in Character options (see left-side of image). Using my example, yourFONT got glyphs selected and was okay'ed but the Family name still remains Arial so we set yourFONT by clicking that arrow and scrolling upwards to the top where yourFONT is there with an Asterix (*****) to show its a customised font. Select it and erm, happy testing...



来源:https://stackoverflow.com/questions/24492207/what-methods-are-there-for-creating-flas-with-dynamically-created-text-that-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!