4 Replies Latest reply on May 27, 2006 7:07 AM by kglad

    my_text_format.font ? is this correct ?

    adrianTNT Level 1
      Hello, can someone please tell me how to set the font ?
      This doesn't seem to work:

      myformat = new TextFormat();
      myformat.font = "adri";
      myformat.color = 0xff0000;
      myformat.size = 8;

      The font is not set when I publish the file, the font is different from what I wanted to embed.
      The font is a special font not like Arial, Sans or Verdana, I need to embed it, can I do that also by code?

      Thank you.
        • 1. Re: my_text_format.font ? is this correct ?
          kglad Adobe Community Professional & MVP
          you must have a font linked for export to set the font property of your textformat object, myformat. you can do that by embedding that font in a textfield in the authoring environment that's instantiated in frame that plays no later than you code executes or you can link a font for export by adding one to your library (click on the upper right corner of you library panel, click new font, select the font you want to use and click ok), right clicking on it in your library, click linkage, tick export for actionscript, give it a linkage id or adri and click ok. retest your code.
          • 2. Re: my_text_format.font ? is this correct ?
            You have to embed the font in the library to use a non-system font. Here's how:
            1. Right click on the library background (or click the drop down panel menu) and select New Font.

            2. Select your font, style, etc and click ok.

            3. Once it is in the library, right click the font and goto linkage - give it the desired name, and click export on first frame.

            4. Now use the name you gave it in linkage for the textformat font property.

            One last thing to get it to work:
            text_box.embedFonts = true;

            If you don't do this the font won't show up, so make sure you set it before applying the format.
            • 3. Re: my_text_format.font ? is this correct ?
              adrianTNT Level 1
              So there is no way to do it by code only.
              I made flash menu with action script only without any clip in the library, it would have been nice to do it without the font field in the library. However, I was able to so it using your instructions; both instructions

              • 4. Re: my_text_format.font ? is this correct ?
                kglad Adobe Community Professional & MVP
                that's correct. something must be in your swf's library: either a font or a textfield that has that font embedded.