Skip to main content
Known Participant
October 13, 2009
Question

bold italic font face doesn't show up

Dear List

I am putting the finishing touches on an as3 project (developped in flex for code and flash cs4 to create the UI) and I am running into a mysterious font issue.

1) I am loading in a swf file with the font outlines (empty dynamic textfields with embedded characters on the stage.  One text field for each regular / bold / italic / bold italic font styles).

2) I then load the swf and then in order to make sure that all font faces are properly available I list them in the output window with the following function:

-----------------------------------------------------------------------------   

private function fontsLoaded(e:Event):void {
            // loop through each loaded font and
            // output its fontstyle/fontweight and
            // font-name
            var _arrFonts:Array = fontLoader.fonts;
            for each (var _font:Font in _arrFonts) {
                var _isBold:Boolean        = false;
                var _isItalic:Boolean    = false;
                switch (_font.fontStyle) {
                    case FontStyle.BOLD:
                        _isBold = true;
                    break;
                    case FontStyle.BOLD_ITALIC:
                        _isBold        = true;
                        _isItalic    = true;
                    break;
                    case FontStyle.ITALIC:
                        _isItalic = true;
                    break;
                }
                trace("************ Loaded Font ***************");
                trace("  Font Name:   " + _font.fontName);
                trace("  Font Bold:   " + _isBold);
                trace("  Font Italic: " + _isItalic);
                trace("****************************************");
            }
           
            //Dispatch Success
            dispatchEvent(new Event(SKFontLoader.LOADING_COMPLETE));
        }

-----------------------------------------------------------------------------

3) I get the following output, telling me that everything should be fine:

-----------------------------------------------------------------------------

*********** Loaded Font ***************
  Font Name:   Verdana
  Font Bold:   false
  Font Italic: false
****************************************
************ Loaded Font ***************
  Font Name:   Verdana Bold
  Font Bold:   false
  Font Italic: false
****************************************
************ Loaded Font ***************
  Font Name:   Verdana Italic
  Font Bold:   false
  Font Italic: false
****************************************
************ Loaded Font ***************
  Font Name:   Verdana Bold Italic
  Font Bold:   false
  Font Italic: false
****************************************
************ Loaded Font ***************
  Font Name:   Century Gothic
  Font Bold:   false
  Font Italic: true
****************************************
************ Loaded Font ***************
  Font Name:   Century Gothic
  Font Bold:   true
  Font Italic: true
****************************************
************ Loaded Font ***************
  Font Name:   Century Gothic
  Font Bold:   true
  Font Italic: false
****************************************
************ Loaded Font ***************
  Font Name:   Century Gothic
  Font Bold:   false
  Font Italic: false
****************************************

-----------------------------------------------------------------------------

4) Everything is working properly except the Century Gothic Bold Italic and the Century Gothic Italic font faces.  I am using an external stylesheets And I have tried the following span tag variations:

-----------------------------------------------------------------------------

.s1_italic{                                             //works!
     font-family:"Verdana Bold Italic";   
}

.s1_italic{                                               //works!
font-family:"Century Gothic";
font-weight:normal;
font-style:italic;
}

.s1_italic{                                             //doesn't work
    font-family:"Century Gothic Bold Italic";    
}

.s1_italic{                                            //doesn't work...          
     font-family:"Century Gothic";

    font-style:italic;

    font-weight:bold;

}

-----------------------------------------------------------------------------

What am I missing?  I'm trying to get bold italic for Century Gothic to work... normal italic Century Gothic works and so does bold italic Verdana... just not bold italic Century Gothic...  this is so frustrating...

Any insight or advice is much appreciated.

Thank you

sk

Ce sujet a été fermé aux réponses.

1 commentaire

stephan_kAuteur
Known Participant
October 13, 2009

it's me again...

I found another function in my library to list:

--------------------------------------------------------

        public static function listAll():void
        {
            trace("List all available fonts:");
            var fonts:Array = Font.enumerateFonts();
            fonts.sortOn("fontName", Array.CASEINSENSITIVE);
           
            for(var ii:int = 0;ii<fonts.length;ii++){
                trace(fonts[ii].fontName + "," + fonts[ii].fontStyle);
            }
        }

------------------------------------------------------

Which gives me the following output:

****************************************
List all available fonts:
Century Gothic,bold
Century Gothic,bold
Century Gothic,italic
Century Gothic,regular
Century Gothic,boldItalic
Century Gothic,italic
Century Gothic,regular
Verdana,regular
Verdana Bold,regular
Verdana Bold Italic,regular
Verdana Italic,regular

------------------------------------------------------

I notice that the bold is listed twice...  might that be a lead to the root of the problem?

Also the boldItalic style is listed as boldItalic... strange?

Does that ring a bell with someone?

Fonts can be beautiful but they are driving me nuts right now.

sk

stephan_kAuteur
Known Participant
October 14, 2009

Hello again...

I've scrambled around and noticed that there are many other unanswered threads with the same issue.

I found two ways to make it work.  I'm sure there are better ways and more correct ways of doing this. Feel free to jump in and let me know:

-------------------------------------------------------------------------------------------------------------------------------------------------------

First Version:  'New Font' Option in Flash Library

-------------------------------------------------------------------------------------------------------------------------------------------------------

1) Create a new Century Gothic Font in the flash library with style: Bold Italic.  (Bitmap Text Disabled).

2) Chose to Export for Actionscript / Export in Frame 1.

3) Chose a class name. ie: CenturyGothicBoldItalic

4) Export the flash file as a swc.

5) Switch to Flex.  Point flex to the swc.

6) Add the following line somewhere in the beginning of your code:

      Font.registerFont(CenturyGothicBoldItalic);

7) The Font CenturyGothicBoldItalic is now available everywhere else in your movie.

-------------------------------------------------------------------------------------------------------------------------------------------------------

Second Version: New MovieClip containing TextField in Library:

-------------------------------------------------------------------------------------------------------------------------------------------------------

1) Create a movieClip with a dynamic textfield in it (all characters embedded).

2) Chose export for Actionscript / Export in Frame 1

3) Add the following line somewhere in the beginning of your code:

    var font_centuryGothicBI:CenturGothicBoldItalic_TextField = new CenturGothicBoldItalic_TextField();

4) The Font CenturyGothicBoldItalic is now available everywhere else in your movie.

-------------------------------------------------------------------------------------------------------------------------------------------------------

What confused me I guess is that you used to be able to just drop an empty dynamic textfield onto the stage of each desired font / style  with all characters embedded and then magically flash would make it all available throughout your movie / classes.  It seems this is not the case anymore.  Even though the fonts are listed when enumerate them through Font.enumerateFonts(), you still need to actually instantiate them in one way or another before textfields can properly display them.

Thank you

sk

Lazlo_Hollyfeld
Inspiring
January 18, 2011

For the second version you've stated here, do you need to create a class name for the font when you check 'Export for ActionScript'?  I think you may have left that out, but am not entirely certain.  If so, in your example, would the class name be " CenturGothicBoldItalic_TextField"?

Thanks!