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

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

Explorer ,
Sep 09, 2014 Sep 09, 2014

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

TOPICS
ActionScript
1.2K
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
LEGEND ,
Sep 11, 2014 Sep 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:

fontfine.png

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.

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
Explorer ,
Sep 11, 2014 Sep 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:

Embedded_Font_Dialog---CS6.jpgEnumerated_Fonts_Output---AS3.jpg

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

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
LEGEND ,
Sep 11, 2014 Sep 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:

emfonts.png

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!

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
Explorer ,
Sep 11, 2014 Sep 11, 2014

Hey, thanks again for the reply.

Ok, I added the fontStyle property to the output and I see this now:

     Liquid Crystal - regular

     Liquid Crystal - bold

     Liquid Crystal - italic

     Liquid Crystal - boldItalic

     Liquid Crystal - regular

     Liquid Crystal - boldItalic

     Liquid Crystal - italic

     Liquid Crystal - bold

But, it's not exactly the same as in my Embedded Fonts Dialog. In the Dialog you can see ExtraBold, but I don't see it in the output above... But, I'll read through the link you posted and I'll try the [Embed] tag method. Thanks for the info, much appreciated!

Thanks Again,

Matt

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
LEGEND ,
Sep 12, 2014 Sep 12, 2014
LATEST

My situation was the same. You can see in my pic I embedded semibold but it reports it as Myraid Pro Light - bold instead. Flash and fonts, always was a great feature and a nightmare to implement.

I think [Embed] is the best way to go and think about the ability to name the font something generic like "sans" and then you can just change the .ttf/.otf and compile for a whole different sans font. Remember to register the font you embed.

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