Skip to main content
June 29, 2009
Question

Embedding Bold Italic Fonts?

  • June 29, 2009
  • 1 reply
  • 2479 views

Ok first of all, sorry if this has been coverd but the "search forums" field apprently searchs all adobe forums and not just this one.

I have been using TextLayout Framework for some time now and I have been embedding open type fonts with jsfl, and this works wonderfully with fonts such as the Champion family that have fonts such as "Champion Bantamweigh" or "Champion Featherweight". But font families like ITC Avant Garde Std is where I get completely lost.

Here is how I am embedding my fonts ():

embedFont("ITC Avant Garde Std Bold", "ITC_Avant_Garde_Std_Bold");
embedFont("ITC Avant Garde Std Demi", "ITC_Avant_Garde_Std_Demi");
embedFont("ITC Avant Garde Std Md", "ITC_Avant_Garde_Std_Md");
embedFont("ITC Avant Garde Std Bold Obl", "ITC_Avant_Garde_Std_Bold_Obl");
embedFont("Champion Bantamweight", "Champion_Bantamweight");
embedFont("Champion Featherweight", "Champion_Featherweight");

function embedFont(fontName, className){
     var symbolName = fontName + "_DF4";
     var doc = fl.getDocumentDOM();
     if (doc) {
          var index = doc.library.findItemIndex(symbolName);
          if (index > -1)     doc.library.deleteItem(symbolName);
          doc.library.addNewItem('font', symbolName);
          var index = doc.library.findItemIndex(symbolName);
          if (index > -1) {
               var fontObj = doc.library.items[index];
               fontObj.isDefineFont4Symbol = true;
               fontObj.bitmap = false;
               fontObj.font = fontName;
               fontObj.bold = false;
               fontObj.italic = false;
               fontObj.embedVariantGlyphs = true;
               fontObj.linkageExportForAS = true;
               fontObj.linkageExportInFirstFrame = true;
               fontObj.linkageClassName = className + "_DF4";
          }
     }
}

Now, when i use these fonts I do so such as these two examples:

SpanElement.fontFamily = "Champion Heviweight"
SpanElement.fontFamily = "ITC Avant Garde Std Md"

These both work, but with the other Avant Garde family the font does not render with the embed glyphs if the font uses styles such as Bold, Italic, Bold Italic .. something like:

SpanElement.fontFamily = "ITC Avant Garde Std BoldObl"

It doesn't work, I got the bold version to work by using

SpanElement.weight = "bold"

The above code works on along with SpanElement.fontFamily = "ITC Avant Garde Std Bk", which i find very odd because I don't want to put a faux style on someting, I want to use the actual font with the embeded fonts, though it doesn't seem to be using faux anthing. So why is this required for fonts that have "Bold" or "Black" in their name?? it makes zero sense to me especially when latest API refrence say:

"TextLayoutFormat: Weight of text (adopts parent's value if undefined during cascade). May be normal, for use in plain text, or bold. Applies only to device fonts (fontLookup property is set to flash.text.engine.FontLookup.DEVICE). "

But for the life of me I can not get ITC Avant Garde Std Bold Obl to work and I am not sure why, there seems to be a big gap between what fonts are named and what name I have to use in AS 3 in order for SpanElement.fontFamily can take them and display them correctly, if anyone has any detailed documentation about how this process works, or insight it would be greatly appreciated because I am baffled. I will keep you updated if i figure it out, I will be working on it till i figure it out hopefully.


Thanks in advance,

Troy

This topic has been closed for replies.

1 reply

June 29, 2009

OK, so i got Bold Italic working using weight and style properties for SpanElement, I thought i tried this before but had a typo in my code, anyway the question still remains why flash treats Bold and Italic fonts so special.

the font I embed is considered "ITC Avant Garde Std Bold Obl" a seperate font that has bold and oblique glyphs in it, but when i have it in flash it is read as ITC Avant Garde Std Md with a fontStyle of  boldItalic, it is my understanding that ITC Avant Garde Std Md is a completely seperate font, and ITC Avant Garde Std Bold Obl is also it's own seperate font.

I have tested only embedding the Bold Oblique version and It still shows up after i give it style and weight, but I still access it by having to declare the font family as ITC Avant Garde Std Md. But it still works aslo letting me know it's not using ITC Avant Garde Std Md as a base font and then applying styling to it when it's rendering, it's only for name association.

Maybe there is a reson for this, but i find it really weird and unituative because I can not treat all of my open type embeds the same, i have to be looking for special cases of words in font names like oblique or italic or bold or demi. Does anyone else find this odd?

July 6, 2009

It's me again

Ok i am gaining further knowledge of how to deal with this font naming convention weirdness I like to call "flash font frustration"...

So I added ITC Avant Garde Demi to my open type embeds, so currently I am supporting and can use ITC Avant Garde Book, ITC Avant Garde Medium, ITC Avant Garde Demi, ITC Avant Garde Bold, ITC Avant Garde Bold Oblique, all from the Adobe font Library (so i know they are good fonts).

by using the menu option "Copy Font Name for ActionScript" under the command context menu in the Flash CS4 UI I made a discovery, when copying the name for Demi I got "ITC Avant Garde Bk" and when copying the name from Bold and Bold Oblique i got "ITC Avant Garde Md".... so that means the convention I need to use to get these embedded fonts to work with the TextLayout Framework is this (in pseudo code):

ITC Avant Garde Book = SpanElement.FontFamily = "ITC Avant Garde Bk"

ITC Avant Garde Medium = SpanElement.FontFamily = "ITC Avant Garde Md"

ITC Avant Garde Demi = SpanElement.FontFamily = "ITC Avant Garde Bk" SpanElement.fontWeight = FontWeight.BOLD

ITC Avant Garde Bold = SpanElement.FontFamily = "ITC Avant Garde Md" SpanElement.fontWeight = FontWeight.BOLD

ITC Avant Garde Bold Oblique = SpanElement.FontFamily = "ITC Avant Garde Md" SpanElement.fontWeight = FontWeight.BOLD SpanElement.fontStyle =FontPosture.ITALIC

Again I would like to reiterate that I am not using device fonts here, so API refrence is wrong when it tells you the fontWeight and fontStyle properties are only for device fonts, they are NECESARY for the framework to grab the correct embedded Open Type font, in the future i hope this changes, but knowing this and hopefully helping others know this helps be fish for font names when embedding new open type fonts.

I am leaving this unanswered because I crossing my fingers that Adobe will give me a little inkling of why this is the way it is, or at least tell me I am crazy and show me how I was supposed to be embedding fonts all along.