6
votes

I have seen lots of questions related to font embedding in flash and I can't seem to find an answer to my problem.

I load fonts from a font swf and register them at a high level so that they can be used in child swfs. The issue is the child swf might also embed these fonts, but not explicitly so, meaning they are only embedded because there are fields in the child swf that use certain characters of a font. This means the text fields in the child use the incomplete embedded font instead of the embedded complete set that is registered in the parent or any level of grandparent. Also this means the swfs that may become children of this child won't get the complete font.

My question: Is there any way to tell flash at compile to not embed, under any circumstances, fonts into a swf? If not is there a tool that removes embedded fonts from a compiled swf?

Here's a few things I have given thought to/noticed so far:

  • It seems as if each Font class is tied to an ApplicationDomain. ( Confirmation of this would be helpful )
  • Using device fonts on text fields will not cause any fonts to embed. ( Not an option for me however because I need the fields to embed fonts at runtime from a parent swf. )
  • I can't find a way to unregister fonts or simply tell loaded child swfs to use parent fonts, which would be useful to apply to the loaded child swfs.
  • It may be possible to load the child in a different context that would allow parent definitions of a fonts to override the child definitions. ( Or would there be two definitions and if so which one takes priority? )
  • Loading assets from the library of the child and adding them to the stage will get the parent definition of the font. ( this makes sense because the asset is created outside the domain of the child )
  • A possible solution might be to not add any characters to the textfields for compile of the swf, but this isn't really an option either because I need static text using any font.

I've started forming a definition of what the problem is in my mind that may be incorrect, so please if necessary take a few steps back and give me a different perspective on the problem. So far it seems like the question I asked above is the right question to answer and if there is a solution to it, all my problems go away.

Thanks!

3
I'm a little bit of a dunce, I thought I understood your question, and was in the middle of typing up an answer, then I realized I wasn't 100% sure if I fully understood your question. Could you provide some code, it helps paint a clearer picture for me.Taurayi
You want to embed each font into its own swf, then load that swf dynamically when required?Tiberiu-Ionuț Stan
I want to have any number of fonts loaded before any view swfs are loaded. That part isn't an issue. The issue is getting the fonts out of the child swfs so the Fonts loaded before the child swfs can be used in the child swfs and not conflict with the child swfs definition of a font.Jordan
Wouldn't this be perfect for an RSLThe_asMan
I've never been able to get an rsl to work for fonts. The only way I can get it working is loading the swf at runtime and manually getting font references out of it. If you can get a swf to compile without any fonts in it ( to check use the size report or decompile the swf ) please post how you did it. I can't get it to work using the rsl options in flash.Jordan

3 Answers

0
votes

If I am right in understanding, than you want to remove/unregister all fonts that are not that complete as the version of this specific font that was already loaded, but embedded in another swf?

Every Font that is embedded creates a class, every swf you load via the Loader class is by default loaded in its own application domain, to prevent namespace clashes, but you can force the loader to load everything into the current application domain with the »loader context« parameter of the Loader's load() method. So this way you could try to force to override classes in the same namespace with each other, but than you cannot control which class to throw away, means you cannot check which font has more glyphs. (maybe it just throws errors instead of overriding and doesn't run at all, i am not that sure about this).

On the other hand you should question how fonts are actually embedded in the child's swf-files. I know no other way than to embed fonts as:

in *.fla-files as »library symbol«, or in code of flashbuilder or flex like this: [Embed(source="c:/windows/fonts/verdana.ttf", fontFamily="Verdana", embedAsCFF="false")],

or this:

@font-face {
    src: url("../assets/MyriadWebPro.ttf");
    fontFamily: myFontFamily;
    advancedAntiAliasing: true;
}

in mxml files. So the (that is what I guess) the resulting Name of the class that is generated depends on the »font-family« property (or even more settings) given by the developer, means even if the same font is embedded twice the class-name might differ caused through the settings.

Also there is no Font.unregisterFont() method, so how to manage this stays a good question, just in case that you might find the same Font class somehow (perhaps RegExp becomes a friendly helper).

I think to solve this properly you need control at compile time, using xml based *.xfl project files might help but even than the referenced Font-File can have a different Name.

A nice problem, good luck

0
votes

I had a lot of problems using fonts with flash. It is still a problem on html with different browsers rendering in different ways.

Anyways, for flash, I built this toolkit that helps me a lot. Check how to customize your fonts. If you do the steps I am pretty sure the problem will be solved.

https://github.com/tbwa/AS3-Toolkit/tree/master/src/com/utils/text

0
votes

Turns out this is an bug with my version of Flash Professional. I did an update and runtime shared fonts are now possible. I will probably point the shared font at a bad url for the fonts then the fonts will come from the parent application domain because they aren't compiled into the child swfs. I'm using Flash Professional CS5.5 11.5.1 now. I was using CS5.5 11.5.0.

http://forums.adobe.com/message/3926344

Thanks Adobe for wasting my time.