[swfmill] Dynamic font sharing, some TTFs don't work
mawe
mawe at typeofundefined.com
Tue Oct 2 19:55:20 PDT 2007
Hello there list,
in the last few days I've been in the search for dynamic font sharing
methods, and most involved the well-known ugly workaround by creating
two SWFs for one font and some crazy complicated export/import shared
asset stuff. I thought there must be an easier way and eventually
discovered that swfmill seems to be capable of just what I (and many
others) want. Oh, and first off, I'm using the latest available windows
build of swfmill (0.2.12.5).
See
http://www.deja-vue.net/blog/2006/05/26/as2-sharedfonts-datagrid-example-the-last-stand/
for examples (might be still down, try
http://web.archive.org/web/20070621074407/http://www.deja-vue.net/blog/2006/05/26/as2-sharedfonts-datagrid-example-the-last-stand/
instead).
OSFlash also points to this resource. Unfortunately, as the above site
is down, I can't grab the examples Mike provided. So I'm not sure how to
really integrate it. Anywaaaaaaaay, I somehow got it working now. The
problem is that it only works with some fonts, but not all. For example
it works with a font called "Dynamic BRK" (urbanfonts.com), but not with
any of the "Frutiger" styles.
The swfmill XML looks exactly the same as in the examples (except for
the font name attribute), my ActionScript goes here:
stop();
var assetContainer:MovieClip = _root.createEmptyMovieClip("container",
_root.getNextHighestDepth());
var assetLoader:MovieClipLoader = new MovieClipLoader();
var assetListener:Object = new Object();
assetListener.onLoadInit = function(mc)
{
trace(mc + " loaded");
setTimeout(_root, "bla", 1000);
//bla();
}
assetLoader.addListener(assetListener);
assetLoader.loadClip("frutiger.swf", assetContainer);
function bla(mc)
{
trace("bla called over");
var tfmt:TextFormat = new TextFormat();
tfmt.font = "dafont";
tfmt.size = 30;
tfmt.color = 0x333333;
var tf:TextField = _root.createTextField("test_txt",
_root.getNextHighestDepth(), 20, 20, 200, 200);
tf.border = true;
tf.embedFonts = true;
tf.antiAliasType = "advanced";
tf.text = "huhu";
tf.setTextFormat(tfmt);
}
The setTimeout call seems to be necessary to properly load the font SWF.
I already tried to set it to a longer wait time as the "Frutiger" font
swf is slightly larger than the "Dynamic BRK" on, but it does not help.
Thanks in advance for any input on this.
Regards
Matthias
More information about the swfmill
mailing list