Skip to main content
Known Participant
September 9, 2014
Question

How to use the Extra-Bold like weights of Embedded Fonts?

  • September 9, 2014
  • 1 reply
  • 1316 views

Hello All,

So I embedded a font I just recently downloaded and the font came with a bunch of different weights/styles, each in their own .otf file, like these:

  • Regular
  • Light
  • Bold
  • Italic
  • Bold-Italic
  • Extra-Bold
  • Extra-Bold-Italic

So what I did was I embedded the font into my library and also embedded each of the above styles of that font as well, and exported them for Actionscript. I am using each font I embed by implementing StyleSheet objects, like so:

var textStyle:StyleSheet = new StyleSheet();

    textStyle.setStyle("myStyle1", {

textAlign: "left",
fontFamily: "Name of Font"

    });

my_textField.embedFonts = true;

my_textField.styleSheet = textStyle;

my_textField.htmlText = "<myStyle1>Blah blah blah, some test text.....</myStyle1>";

And after reading about StyleSheets for AS3 here http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/StyleSheet.html I can see that font-style supports "normal" or "italic" and font-weight supports "normal" or "bold". So how can I use the styles of the font I embedded like "Extra Bold", "Extra Bold Italic", etc...

Any thoughts or suggestions would be much appreciated!

EDIT:

I also forgot to mention that I used the code below to print out all the available embedded font names using the trace command, and even though I embedded 5 or 6 different styles/versions of the same font, it only printed that font name once. I was thinking that maybe it used an entirely different font name but it didn't. And from what I had read recently to use the font I embedded you would use the name that prints out from the loop below, and not the name I created that was exported for Actionscript.... Is that right?

var fonts:Array = Font.enumerateFonts();

for (var i:int = 0; i < fonts.length; i++)

   trace(fonts.fontName);

Thanks in Advance,

Matt

This topic has been closed for replies.

1 reply

sinious
Legend
September 11, 2014

I don't recall reading it, which version of Flash are you using?

In a simple library embed I find my weights are reported accurately. Myraid condensed for example will print from enumerated fonts:

Most fonts that actually gave me any trouble worked a bunch better when I used [Embed] and specified the style and weight for each version of the font I needed. You may want to try that. Here's an older but relevant article on it.

mrm5102Author
Known Participant
September 11, 2014

Hey sinious, thanks for the reply!

Adobe Flash Professional CS6 and the output is set for Flash Player 11 and Actionscript 3

Where I got some of my info on Embedding Fonts --> https://www.capstrat.com/posts/having-trouble-embedded-fonts-and-html-text-flash-cs5/

If you scroll down to the heading The New Way, you'll see in his screenshot he has the Arial font embedded, and under that font there is Bold, Italic and Regular. The the output from the loop simply prints "Arial" 3 times....

Hummm... That's strange, so that loop actually printed Myraid Pro Cond... When I run it, it only prints the "base" font name however many times as there are Styles for that font. So if you look at the screenshots below, the font I'm using, Liquid Crystal, prints out 6 or 7 times. See below...

*Here is the Embedded Fonts Dialog and the Output from the Enumerated Fonts loop:

FYI, I won't have this many fonts embedded on my final program, I'm just testing to see which one(s) I'll be using.

Thanks Again for the reply, much appreciated!

Thanks,

Matt

sinious
Legend
September 11, 2014

Be sure to note the fontStyle portion of his later script. That's an important ingredient. It was:

var fonts:Array = Font.enumerateFonts();

for (var i:int = 0; i < fonts.length; i++)

   trace(fonts.fontName + " - " + fonts.fontStyle);

The important portion bolded there. Here's Myraid embedded in CS6 in various styles and my output. Embed panel:

My trace output:

Myriad Pro Light - bold

Myriad Pro - regular

Myriad Pro - boldItalic

Myriad Pro Cond - regular

Myriad Pro Cond - boldItalic

Myriad Pro Cond - italic

Matches the embed perfectly. That doesn't mean it works correctly however, my embed is flaking out (Times New Roman).

It's worth noting that I never have these issues when I simply use the [Embed] tag. You should try it!