A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: createTextFields & embedfonts Question

  1. #1
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    Any one knows how to embed fonts in conjunction with createTextField

    so ..

    how do I use / get working :

    text = new TextField();
    or
    text2 = createTextField ("t", 1, 10, 100, 100, 200)

    fontArray = text.getFontList();

    trace(fontArray)

    will I use that to find my embedded font and attach it to a textField I create ??

    How do I embed fonts .. through a textfield with embed font on or what ??

    If anyone can shine some light on this that would be really appreciated !

    Nyls

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    Ok found a part of the answer :
    I've been using font symbols for embedding into text fields and it works. Library > New Font > Choose Font (I always name the font symbol the same as the font name) > OK > Right click font symbol > Linkage > Check export for ActionScript > OK (leave linkage ID the name of the font).
    Code:
    txtInput.background = true; 
    txtInput.type = "input"; 
    txtInput.embedFonts = true; 
    fmtFormat = new TextFormat(); 
    fmtFormat.font = "Arial Black"; 
    txtInput.setNewTextFormat(fmtFormat);

  3. #3
    Senior Member
    Join Date
    Jan 2001
    Posts
    472
    In your library, select New Font from the options in the upper right. Select a font in the drop down list and give it a name. For this example, I'll assume you name it "myFont".

    Right click on the new font symbol in your library and select linkage. Check export for actionscript and give it the identifier "myFont".

    Now in your AS window, create a new TextFormat:

    myTF = new TextFormat();
    myTF.font = "myFont";

    You now have a TextFormat and have associated your exported font with it.

    Now create a new textField:

    this.createTextField("myTextField", 0, 50, 50, 0, 0);
    myTextField.setNewTextFormat(myTF);
    myTextField.embedFonts = 1;
    myTextField.autoSize = "left";
    myTextField.text = "This is an example."

    This creates a text field and places it at 50,50 on the stage. The width and height are set to 0, but we have allowed it to autoSize from left so it will automatically expand when text is inserted.

    We have set its text format to be our custom TextFormat above. To use the exported font, though, we need to to set the embedFonts property.

    Finally, we put some text in the field.

    How's that?


  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    Is it also possible to render HTML in an embedded font .>> I can Imagine why not (or do you need to embed also the bold and italic fonts ??)

    Code:
    myTF = new TextFormat(); 
    myTF.font = "Algerian"; 
    
    textField("myTextField", 0, 50, 50, 0, 0); 
    myTextField.setNewTextFormat(myTF); 
    myTextField.embedFonts = 1; 
    myTextField.autoSize = "left"; 
    
    myTextField.html = true;
    myTextField.htmlText = "<b>This is an example.</b>";

  5. #5
    Senior Member
    Join Date
    Jan 2001
    Posts
    472
    You would need to embed the bold and italic outlines as well.

  6. #6
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    Did you get it to work .. I,ve been trying it but I don't get any HTML >>

    for example how do you attach more then one font to a textfield ??
    myTF.font = "CenturyGothic";

    then you just attach one font-outline ..

    - how does Flash know which font to take ..

    Maybe you know were to find some read material about this topic ??

    many thnx already

    Nyls







  7. #7
    Senior Member
    Join Date
    Jan 2001
    Posts
    472
    Well, the font's not associated with a textField, but the textFormat. You can have multiple textFormats for a textField (the AS Dictionary tells how).

    I know in Flash 5, you couldn't have embedded fonts for HTML, so perhaps that hasn't changed.

  8. #8
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    Many thnx for the help .. It's to bad there is such limited info about these things .. but I will search on ..

    nyls

  9. #9
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    Hy tyard

    Just posting another work-a-round I found to have HTML with embedded fonts ..
    If you embed for example : arialbold, arialitalic,arial

    you could fake HTML through....

    <font face="arialbold">this is bold</font>
    <font face="arialitalic">this is italic</font>

    bye

    Nyls



  10. #10
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    sorry

    Code:
    <font face="arialbold">This is bold</font>
    <font face="arialitalic">This is bold</font>

  11. #11
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    my HTML examples get meshed up ..

    so describing instead of the bold-tag you can use the font-tag with face='arialbold' and so on ..

    Nyls

  12. #12

    new textFormat() on an movieClip text field no dynamically created

    Hi,

    can i new textFormat() to bold on a text field already existing and changing it from italic to bold?

    Kendall

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center