dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: embeding fonts for dynamically created textFields

  1. #1
    Senior Member
    Join Date
    Jun 2001
    Location
    in the back room of a dark pub
    Posts
    454

    embeding fonts for dynamically created textFields

    I've tried to search for an answer but i've come up empty handed. I know the embedFont for the text format embeds the font, but i can't get it to work. What is that syntax actually doing...? Is it embedding the font from my harddrive when i publish the movie or is it looking for the font from the users hard drive and embedding it from there?

    I'm using pixel font's so this is particularly cruciual.

    Thanks
    ~bugged

    imageWeaver gallery
    microsite direct download

    "Have you ever noticed? Anybody going slower than you is an idiot, and anyone going faster than you is a maniac."

  2. #2
    Senior Member
    Join Date
    Sep 2000
    Location
    Pittsburgh
    Posts
    252
    hi,

    not sure how much of this you already know but you should be able to import the font into your library from the drop down by selecting 'new font', right click and give it a linkage id just like you do for mc's you want to attach dynamically, so when you publish it the outlines of that font will be included in your swf, then you will want to set it up:

    Code:
    // Creating textfield text format
    fieldTextFormat = new TextFormat();
    fieldTextFormat.font = "kroeger"; //linkage id 'kroeger' in library
    fieldTextFormat.size = 8;
    
    // Creating the base textfield
    createTextField("mytext", 1, Stage.width/2, Stage.height/2, 300, 500);  //name, depth, x, y, width, height
    mytext.multiline = true;
    mytext.wordWrap = true;
    mytext.selectable = false;	
    mytext.autoSize = true;
    mytext.embedFonts=true;
    mytext.text = "Test the format object";
    mytext.setTextFormat(fieldTextFormat);
    theoretically that should work, i tested it with and w/o the kroeger font in my fonts folder.

    hope this helps some,
    Dunc

  3. #3
    Senior Member
    Join Date
    Jun 2001
    Location
    in the back room of a dark pub
    Posts
    454
    thanks for that... I was wondering also though if i had already got the font embedded somewhere in the timeline in a normal dynamic text box would i have to use the new font / attach font system or would the font already be in the swf?

    Also a potential problem with that solution, because the font is already on your system, would flash not just be reading the font named kroeger off you hard drive rather thatn the one in the library?
    ~bugged

    imageWeaver gallery
    microsite direct download

    "Have you ever noticed? Anybody going slower than you is an idiot, and anyone going faster than you is a maniac."

  4. #4
    Senior Member
    Join Date
    Sep 2000
    Location
    Pittsburgh
    Posts
    252
    if you already have it embedded in a dynamic textbox then you won't need to use the FStyleFormat object unless you want to change the way the text in the field looks. Doing it the way you have it now is fine, i have done that before myself, just creating an MC with a textfield in it and embed the font through the character options and attach it to the stage as needed. But only that textfield has the ability to use that font unless you make more in the library. I guess it just depends on what you need or how many fields you'll be generating or using. You can make things more modular by creating some sort of function so any tField can use the font and you can manipulate it any way you see fit:

    // Creating textfield text format
    fieldTextFormat = new TextFormat();
    fieldTextFormat.font = "kroeger"; //linkage id 'kroeger' in library
    fieldTextFormat.size = 8;

    // Creating the base textfield
    function setFormat(tField,textInField){
    tField.multiline = true;
    tField.wordWrap = true;
    tField.selectable = false;
    tField.autoSize = true;
    tField.embedFonts=true;
    tField.text = textInField;
    tField.setTextFormat(fieldTextFormat);
    }

    to test and make sure it's working just rip out the fonts from your fonts folder, it seemed to work for me.

    good luck,
    Dunc

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