Skip navigation
Vikram_S
Currently Being Moderated

Embedded font and Combobox

Mar 22, 2011 11:08 PM

Hello All,

 

Scenario of my application: Application have combobox filled with fonts list. When user select font from combobox. Application load font swf from server and apply to text.

 

I have embedded fonts in SWF using css.

@font-face {   

    src: url("assets/fonts/arial.ttf");   
    fontFamily: "Arial";   
    fontWeight: "normal";   
    embedAsCFF: true;   
}

 

here is code snippet to load font from server.

 

var eventDesi:IEventDispatcher = styleManager.loadStyleDeclarations2(fontStyleName.@swfURL);
            eventDesi.addEventListener(StyleEvent.ERROR,function(event:StyleEvent ):void{
                Alert.show("error while downloading font " + fontStyleName.@name);
            })
            eventDesi.addEventListener(StyleEvent.COMPLETE,function(event:StyleEv ent):void{
                fontStyleName.@isDownloaded == "true";
               if(functionToCall != null)
                    functionToCall.call();   
            })

 

Problem:

When I select font arial form combobox all list of fonts,tool tips are get disappear. My primary exploration is combobox has arial font and I am loading again arial and registering it. This may be the cause.

 

Is there any way to set embeded font to any control?

 

Thanks,

Vikram

 
Replies
  • Currently Being Moderated
    Mar 23, 2011 12:05 AM   in reply to Vikram_S

    I think ComboBox uses bold text so you have to embed a bold font as well.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 24, 2011 1:39 AM   in reply to Vikram_S

    Hi,
    
    Follow this tutorial and use the code below..
    
    
    http://www.designscripting.com/2011/06/as3-combobox-font-embedding-problem-flash-cs5/
    
    var arial:Font = new ArialFont();
    
    var myFormatBlack:TextFormat = new TextFormat();
    myFormatBlack.font = arial.fontName;
    myFormatBlack.size = 18;
    myFormatBlack.color = 0x000000;
    
    myComboBox.textField.setStyle("embedFonts", true);
    myComboBox.textField.setStyle("textFormat", myFormatBlack);
    myComboBox.dropdown.setRendererStyle("embedFonts", true);
    myComboBox.dropdown.setRendererStyle("textFormat", myFormatBlack);
    myComboBox.setStyle("embedFonts", true);
    myComboBox.setStyle("textFormat", myFormatBlack);
    myComboBox.prompt = "Select State";
    myComboBox.width = 248;
    myComboBox.height = 25;
    myComboBox.x = 100
    myComboBox.y = 100
    myComboBox.setStyle("textPadding", 1);

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points