A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: textField.embedFonts = true; Not Working, Got No Idea Why!

  1. #1
    (sic) Covenent's Avatar
    Join Date
    Dec 2000
    Location
    Ireland
    Posts
    709

    Smile

    I have successfully created dynamic text fields through actionscript, and changed their color, boldness, margins, size etc. but when I try to embed the font it isnt working, any idea why?

    All I am using is the following code, which according to its refence should work.

    myTextField.embedFonts = true;

    I have also tried it as part of a text format object but it hasnt worked; like so:

    myFormat = new TextFormat();
    myFormat.embedFonts = true;
    myTextField.setTextFormat(myFormat);

    Has anyone got suggestions, or have they been having a simialr problem?

    Cheers,

  2. #2
    embedFonts is a preoperty of the textField object not the textFormat object.
    so your code should read:

    myTextField.embedFonts = true;

  3. #3
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397

  4. #4
    (sic) Covenent's Avatar
    Join Date
    Dec 2000
    Location
    Ireland
    Posts
    709
    Actually if you looked at the third line of my post you would see I had the exact same script as you enamics!

    Anyway cheers oldnewbie Im downloading the file, and see where I went wrong.

  5. #5
    (sic) Covenent's Avatar
    Join Date
    Dec 2000
    Location
    Ireland
    Posts
    709
    I just looked at your file oldnewbie (not for very long though, so I may be wrong ) and you are saying to embed the font for a text field that is already on stage. However I wanto embed the font for a text field that isnt on stage.

    Look at the following code:

    text = "Cheese";

    // format the text field
    var tf = new TextFormat();
    tf.color = 0x000000;
    tf.font = "Verdana";
    tf.size = 12;

    // create the field
    createTextField("textbox", 10, 0, 0, 100, 100);
    textbox.autoSize = tipAlign;
    textbox.text = text;
    textbox.setTextFormat(tf);
    // textbox.embedFonts = true;
    textbox.html = false;
    textbox.multiline = true;
    textbox.selectable = false;
    textbox.tabEnabled = false;
    textbox.type = "dynamic";
    textbox.wordWrap = false;

    Place that on the _root timeline on its own, and it works fine. However if you uncomment the line about embedding fonts, the text no longer appears!

    Any suggestions?

    Cheers,

  6. #6
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    been trying since it's release to figure this out,
    I'd love a clue on what to try next???????

    I've moved the embedFont around a lot to see where and what makes a difference, but no dice.
    If I put it before my setTextFormat(), my attached scroller doesn't enable
    If I put it after my setTextFormat(), my scroller enables and scrolls as though the text is there.
    but theres no text.

    nothing.

    commenting embedFonts = true; out works, the text shows, but I have no way of telling whether or not anyone without the font installed will see it.

    perplexing.

  7. #7
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    commenting embedFonts = true; out works, the text shows, but I have no way of telling whether or not anyone without the font installed will see it.
    To check this out, why don't you post a short example with some font you're sure I don't have (I presently have but the standard set!), to see if I'll see it or not?

  8. #8
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    cool, thanks OldNewbie,
    url coming soon.

  9. #9
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    so I should really think in advance here aye?


    do you have a font called "superpoint"?


  10. #10
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Nope!

  11. #11
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    cool.
    sorry for the delay, had to clear something else away first...


    my test is here:
    http://www.vitaminbplus.com/other/mxtest/test.html

    as you can see in the actions,
    embedFonts = true;

    is commented out.
    if you can see the text in the typeface "superpoint"
    the I guess it's embedded by default in the setTextFormat() call.

  12. #12
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Hard to say if I'm really seeing superpoint...

    Don't you have a more unusual font, script or outlined, something really different?

  13. #13
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    What about this:

    http://odin.prohosting.com/~oldnew/test_loadtext02.swf

    Can you see both texts?

  14. #14
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Ok! Found something!

    Don't ask me why... But this does work: (<b>see note</b>)

    myFormat = new TextFormat ();
    with (myFormat) {
    font = "Niagara Engraved"; // font you want to embed
    size = 40;
    };

    _root.createEmptyMovieClip("container", ++highestLevel);
    _root.container.createTextField("textField", ++highestLevel, 50, 50, 200, 200);
    _root.container.textfield.embedFonts = true;
    with (_root.container.textField) {
    var theText= "NIAGARA ENGRAVED";
    selectable = false;
    multiline = true;
    wordWrap = true;
    border = true;
    html = true;
    htmltext = _root.theText;
    setTextFormat(myFormat);
    }
    stop();

    <b>IMPORTANT NOTE</b>: You must also create a new font symbol in the library (Library > New Font.) Give it a name for export... ie. "myFont", and must then select or type in the name of the font to be embedded in the font box, which is actually the same used in myFormat - in this case Niagara Engraved. Also set linkage to Export for ActionScript.

    Checks accepted in Canadian funds!

  15. #15
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    I've tried the shared library font trick, I haven't been able to get that to work either.


    I saw niagara ingraved in your file, but I have it installed.


    superpoint is a Flash pixel font - meaning it renders aliased (unsmoothed)
    it has a dotted appearance, characters are comprised of dots. Quite unusual, you would know if you saw it, I am thinking you didn't.
    it is at 10 pt, but is a rather large 10 pt, possibly 12 - 14 pixels high.

    If your still unsure whether or not your seeing superpoint, I'll include a static text field of it in the file too.
    check it for an update.
    thanks for all your efforts man.

  16. #16
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397

  17. #17
    (sic) Covenent's Avatar
    Join Date
    Dec 2000
    Location
    Ireland
    Posts
    709
    I dont have Niagra engraved installed, but I could still see it. So thats obviously working. I couldnt see superpoint however, it looked like times new roman. And I could see Architext, but I have that installed on my machine anyway...

    I will try oldnewbies method of embedding the font like he did later. Is it really necessary to create an empty movieclip for the dynamically created text field, or can you just skip out that part of the coding?

    Anyway cheers for the help guys, Ill post my results here later.

    Cheers

  18. #18
    Member
    Join Date
    Feb 2002
    Posts
    45
    I could see architext and I don't have it installed. Can someone gimme a link or something where I can download some nice fonts? I have only default ones so far and kinda getting tired of them, need something new for the clan webpage.

  19. #19
    (sic) Covenent's Avatar
    Join Date
    Dec 2000
    Location
    Ireland
    Posts
    709
    Ok after some fiddling about I think I figured it out.

    You need to create a new font in the library (click the top right corner of the library window, the option is there). In the first field give the font you are too embed a name, something obvious and not the fonts name. I called my "Main Font" as that was the font I was using most through my file. Then choose the font you want from the drop down menu, I chose Verdana.

    Finally set the linkage for the font so you can embed its characters. Do this by right clicking over the font you just created in the library, and going to linkage. Now check 'Export for actionscript' and give the font a linkage ID. I chose the ID as the same name I gave the font (Main Font).

    Now you should be able to dynamically create a text field like we did before, and where you are saying what font to use, you should enter the name of the linkage ID for the font.

    Example:

    myField.text = "Main Font";
    myField.embedFonts = true;

    Also if you want to use this font with its embedded outlines on normal text you have typed on the stage. Simply select that text, and for the name type in the linkage ID for your font, Flash might then add some funny brackets around the fonts name but ignore, that you can embed the characters for this font that you want without increasing file size.

    Note:

    Although the name of the font you created in the library, will be in your font list when you select a text field, dont choose the fonts name from here as it has a * with itand when using some code I had problems with it. So some components mightnt work with the text field.

    And this brings me to my final note!

    I am using a tool tip component that uses the value of variable that is set in the components panel, to give a dynamically created text field its font. Now the problem here is that when the users goes to the components panel, and enters in the name of the font that they have in their library, Flash automatically adds the * to the end of the fonts name (which is to indicate that the font is from the library), but unfortunately this screws up your code as your component then reads the * as a part of the fonts name, and so when it goes to use this font it cany find it, because it is adding in the * that isnt meant to be there!

    So what I did was in the code for my component, was a just added a short test, that would see if the * exsisted at the end of the fonts name, and if so to remove it. And the component worked fine. The code I used for this was:

    if (tipFont.substr(tipFont.length-1) == "*") {
    tipFont = tipFont.substr(0, tipFont.length-1);
    }

    tf.font = tipFont;

    Where 'tf' was a nex text format.

    I thinks thats all I figured out.
    If anyone finds out anything more, post it here.

    Cheers




  20. #20
    (sic) Covenent's Avatar
    Join Date
    Dec 2000
    Location
    Ireland
    Posts
    709
    Oh and monster3 if you want fonts check out http://www.1001fonts.com or one of the best sites I have seen http://www.larabiefonts.com

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