For our current project we need to have ALL fonts externalized and loaded dynamically so our client is able to replace them when localizing text.
Our designers have already designed everything in several FLA files, using the original fonts for English text. If we are going to load these fonts dynamically, it is no good to have them embedded in every FLA file, right? So what I did is to set all text fields as dynamic and also to "use device fonts", so the font does not get embedded in the swf.
But once I load the font in AS3 and attempt to apply it to each text field, I get a blank textfield (all characters gone)! Just to be clear, I'm doing something like this:
But the strange thing is: If I create a new TextField() and assign the exact same set of properties (new TextFormat() with the same font name "MyFont" and everything else)... the text shows up fine!
Is this expected behavior? Am I doing anything wrong?
Thanks in advance!
This is my simplified project setup:
screens.fla (contains user interface, artwork, textfields, etc) -> screens.swf
MyFont1.ttf -> embedded in MyFont1.as -> MyFont1.swf
MyFont2.ttf -> embedded in MyFont2.as -> MyFont2.swf
Bunch of .as files -> main.swf which loads all other swfs.
What I'm trying to do is to have screens.swf compiled without MyFont embedded into it. But I don't want to have all text fields with "_sans" font because I have several textfields using 3 or 4 different fonts and I want to maintain that information.
As for step 2, I thought that setting the textfields to "use device fonts" would do just that: not embed the font but maintain the reference of the font name.
ok, so you don't want screens.swf to be compiled with MyFont. that's all you've clearly explained, so far.
let me guess. you want to load a swf that has MyFont embedded in it so you apply the embedded font to a textfield in screens. is that correct?
in MyFont1.fla, click the upper right of the library panel > click new font > select your font family and style > tick the needed character range(s) > click the actionscript tab > tick export for actionscript > type a class name (eg, VerdanaReg) > tick tlf or classic > click ok > file > publish.
in screens.fla, add:
var loader:Loader=new Loader();
var loadedAppDomain:ApplicationDomain = e.target.content.loaderInfo.applicationDomain;
var C:Class = loadedAppDomain.getDefinition("VerdanaReg") as Class;
verdanaReg= Font(new C());
var tfor:TextFormat=new NextFormat();
tfor.text = font.fontName;
tf.defaultTextFormat = tfor;
// if there's already text in tf, also use:
Thanks for your help kglad, but that doesn't solve my issue. Please read the first post: that is exactly what I am doing in my code, and the end result is a blank text field.
Note that the textfield already has the same font assigned in screens.fla, but with "use device fonts".
Europe, Middle East and Africa