4 Replies Latest reply on Aug 18, 2008 5:56 PM by Newsgroup_User

    Embed Fonts in Library for use with AS2.0 (k)

    Level 7
      I'm working on a project that will never run on the web. It's a souped
      up PowerPoint presentation basically. Entirely in flash.

      I have a lot of ActionScript in there for animating text. The
      ActionScript reads what's housed in the text="MY MESSAGE HERE" and then
      chops the phrase up into individual dynamic text fields containing each
      letter in the message that I then animate to get them on the screen.

      It works great and I have chosen the font via a _global variable:
      _global.FontFace = "ElanBook";

      This calls the font from my computers font library, not the Flash's.

      I would like to change this so that this font is truly embedded and
      called in via ActionScript so that font looks the same on all computers
      whether they have this font or not.

      I have tried going to the Library > New Font...

      I put the font in there I turned on Exporting for ActionScript in
      Linkage. No dice.

      How do I apply a font that is sitting in my library to a dynamic text
      field through ActionScript. I has to be through ActionScript because the
      dynamic text field does not exist until ActionScript creates it.

      -Kirk
        • 1. Re: Embed Fonts in Library for use with AS2.0 (k)
          kglad Adobe Community Professional & MVP
          you need to embed the fonts of your textfields and you need to use a textformat instance that's applied to each of your textfields and has a font property = linkage id of your embedded font.
          • 2. Re: Embed Fonts in Library for use with AS2.0 (k)
            robdillon Most Valuable Participant
            Once you've embedded the font. Use the Indentifier name from the Linkage window to specify the font in a TextFormat object. Then be sure to specify embedFonts = true for the textField itself. To borrow from the online help:

            this.createTextField("mytext",1,100,100,100,100);
            mytext.multiline = true;
            mytext.wordWrap = true;
            mytext.border = true;
            mytext.embedFonts = true;

            var myformat:TextFormat = new TextFormat();
            myformat.font = "embeddedFontName";

            mytext.text = "this is my first test field object text";
            mytext.setTextFormat(myformat);
            • 3. Re: Embed Fonts in Library for use with AS2.0 (k)
              Level 7
              I swear I did exactly that, and it didn't work.

              Now the font is in there, but the kerning is shot to hell.

              Very weird. Has to do with embedFonts=true

              If I comment that out the kerning goes back to normal, but the font is
              back to the default, Times.


              -Kirk



              Rob Dillon wrote:
              > Once you've embedded the font. Use the Indentifier name from the Linkage window
              > to specify the font in a TextFormat object. Then be sure to specify embedFonts
              > = true for the textField itself. To borrow from the online help:
              >
              > this.createTextField("mytext",1,100,100,100,100);
              > mytext.multiline = true;
              > mytext.wordWrap = true;
              > mytext.border = true;
              > mytext.embedFonts = true;
              >
              > var myformat:TextFormat = new TextFormat();
              > myformat.font = "embeddedFontName";
              >
              > mytext.text = "this is my first test field object text";
              > mytext.setTextFormat(myformat);
              >
              • 4. Re: Embed Fonts in Library for use with AS2.0 (k)
                Level 7
                Just had to move it down below where the calculations for width were
                made. It works!

                _kirk


                W. Kirk Lutz wrote:
                > I swear I did exactly that, and it didn't work.
                >
                > Now the font is in there, but the kerning is shot to hell.
                >
                > Very weird. Has to do with embedFonts=true
                >
                > If I comment that out the kerning goes back to normal, but the font is
                > back to the default, Times.
                >
                >
                > -Kirk
                >
                >
                >
                > Rob Dillon wrote:
                >> Once you've embedded the font. Use the Indentifier name from the
                >> Linkage window to specify the font in a TextFormat object. Then be
                >> sure to specify embedFonts = true for the textField itself. To borrow
                >> from the online help:
                >>
                >> this.createTextField("mytext",1,100,100,100,100);
                >> mytext.multiline = true;
                >> mytext.wordWrap = true;
                >> mytext.border = true;
                >> mytext.embedFonts = true;
                >>
                >> var myformat:TextFormat = new TextFormat();
                >> myformat.font = "embeddedFontName";
                >>
                >> mytext.text = "this is my first test field object text";
                >> mytext.setTextFormat(myformat);
                >>