Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Loading external swf fonts created with fontswf, loaded with a Loader, compatible with iOS

Engaged ,
Sep 26, 2012 Sep 26, 2012

Let me immediately start out by saying that I do in fact have a current working solution for using embedded fonts, generated by fontswf and working in an AIR ActionScript mobile application, and also currently working fine with iOS.

My current app needs CFF fonts, so I currently use the fontswf tool to pre-generate the .swfs using:

fontswf -4 -a [SomeAlias] -o [SomeFont.swf] [SomeFont.ttf]

and then I am currently embedding them in my app source code .as for compilation using:

[Embed(source="/swf/SomeFont.swf", symbol="SomeAlias")]

public static var SomeFontClass:Class;

I then have no problem registering them using Font.registerFont(SomeFontClass) and everything works fine.

However, I would prefer to take the use of these swf fonts one step further and load them dynamically using a Loader so that I do not have to take the hit of having multiple CFF font swfs embedded in the main compiled SWF and so that I could even load an unknown future set of fonts without having to supply them as part of the app build.

Now I have seen and read many blogs and tutorials where people have exported font swf from Flash Builder where you add an explicit 'Class' name or even made standalone .as static files compiled into standalone swfs only including the two lines:

[Embed(source="/swf/SomeFont.swf", symbol="SomeAlias")]

public static var SomeFontClass:Class;

so that you also have a 'Class' involved. Then people use some form of appropriate applicationDomain.getDefinition("className") as Class

to pull out the class for the font registration.

My question is, how does one perform the same font loading and registration of fonts using a Loader only loading the .swfs produced directly from fontswf?

It seems only a DefineFont4 is tagged in the swf, there doesn't seem to be a 'Class' per se to call on.

More importantly, iOS apps cannot load external swfs with code in them, so my understanding is any extra wrapped swf that would contain a custom Class technique would fail the iOS requirement of only having one main SWF with any ActionScript compiled code.

Is there an alternative to the 'Class' technique by grabbing the DefineFont4 tagged resource from the swf and instantiating a proper working Font class from that? One that would still be compatible with the restrictions placed on AIR mobile apps running on iOS?

TOPICS
ActionScript
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 27, 2012 Sep 27, 2012
LATEST

Ironically, just after posting this, Adobe released AIR 3.5 beta onto labs, and added multiple SWF support for iOS.

While this new support makes it easier to manage your content across multiple SWFs and technically allows you to use the class based separate .swfs for each font if desired, the system still requires that all these SWFs be present at compile time when making the final app .ipa for iOS.

So this still doesn't solve trying to load fonts after the app is already built. For example, as part of a downloaded in-app purchase mechanism.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines