Skip to main content
Inspiring
August 18, 2008
Question

Embed Fonts in Library for use with AS2.0 (k)

  • August 18, 2008
  • 4 replies
  • 574 views
I'm working on a project that will never run on the web. It's a souped
up PowerPoint presentation basically. Entirely in flash.

I have a lot of ActionScript in there for animating text. The
ActionScript reads what's housed in the text="MY MESSAGE HERE" and then
chops the phrase up into individual dynamic text fields containing each
letter in the message that I then animate to get them on the screen.

It works great and I have chosen the font via a _global variable:
_global.FontFace = "ElanBook";

This calls the font from my computers font library, not the Flash's.

I would like to change this so that this font is truly embedded and
called in via ActionScript so that font looks the same on all computers
whether they have this font or not.

I have tried going to the Library > New Font...

I put the font in there I turned on Exporting for ActionScript in
Linkage. No dice.

How do I apply a font that is sitting in my library to a dynamic text
field through ActionScript. I has to be through ActionScript because the
dynamic text field does not exist until ActionScript creates it.

-Kirk
This topic has been closed for replies.

4 replies

Inspiring
August 19, 2008
Just had to move it down below where the calculations for width were
made. It works!

_kirk


W. Kirk Lutz wrote:
> I swear I did exactly that, and it didn't work.
>
> Now the font is in there, but the kerning is shot to hell.
>
> Very weird. Has to do with embedFonts=true
>
> If I comment that out the kerning goes back to normal, but the font is
> back to the default, Times.
>
>
> -Kirk
>
>
>
> Rob Dillon wrote:
>> Once you've embedded the font. Use the Indentifier name from the
>> Linkage window to specify the font in a TextFormat object. Then be
>> sure to specify embedFonts = true for the textField itself. To borrow
>> from the online help:
>>
>> this.createTextField("mytext",1,100,100,100,100);
>> mytext.multiline = true;
>> mytext.wordWrap = true;
>> mytext.border = true;
>> mytext.embedFonts = true;
>>
>> var myformat:TextFormat = new TextFormat();
>> myformat.font = "embeddedFontName";
>>
>> mytext.text = "this is my first test field object text";
>> mytext.setTextFormat(myformat);
>>
Inspiring
August 19, 2008
I swear I did exactly that, and it didn't work.

Now the font is in there, but the kerning is shot to hell.

Very weird. Has to do with embedFonts=true

If I comment that out the kerning goes back to normal, but the font is
back to the default, Times.


-Kirk



Rob Dillon wrote:
> Once you've embedded the font. Use the Indentifier name from the Linkage window
> to specify the font in a TextFormat object. Then be sure to specify embedFonts
> = true for the textField itself. To borrow from the online help:
>
> this.createTextField("mytext",1,100,100,100,100);
> mytext.multiline = true;
> mytext.wordWrap = true;
> mytext.border = true;
> mytext.embedFonts = true;
>
> var myformat:TextFormat = new TextFormat();
> myformat.font = "embeddedFontName";
>
> mytext.text = "this is my first test field object text";
> mytext.setTextFormat(myformat);
>
robdillon
Participating Frequently
August 18, 2008
Once you've embedded the font. Use the Indentifier name from the Linkage window to specify the font in a TextFormat object. Then be sure to specify embedFonts = true for the textField itself. To borrow from the online help:

this.createTextField("mytext",1,100,100,100,100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = true;
mytext.embedFonts = true;

var myformat:TextFormat = new TextFormat();
myformat.font = "embeddedFontName";

mytext.text = "this is my first test field object text";
mytext.setTextFormat(myformat);
kglad
Community Expert
Community Expert
August 18, 2008
you need to embed the fonts of your textfields and you need to use a textformat instance that's applied to each of your textfields and has a font property = linkage id of your embedded font.