title: AS3 TextField Fonts
body: <p>I have problems setting a font in AS3. I have tried several different things using ressources from forums and questions but I can't get it to work.</p>
  
  <p>Here's the code I use:</p>
  
  <pre><code>    private function addContentToMovieClips(Text:String, MC:MovieClip):void
      {
          var myFont = new Trebuchet();
  
          var tFormat:TextFormat = new TextFormat();
          tFormat.font = myFont.fontName; 
          tFormat.color = 0x000000;
          trace(tFormat.font);
  
          var tf:TextField = new TextField();
          tf.defaultTextFormat = tFormat;
          tf.embedFonts = true;
          //tf.antiAliasType = AntiAliasType.ADVANCED;
          tf.text = Text;
          MC.addChild(tf);
          tf.width = 300;
      }
  </code></pre>
  
  <p>In the library, I have a Font named "font2" with AS linkage "Trebuchet". I get no compiler errors and text seems to be created on the screen but nothing is displayed.</p>
  
  <p>The following line is for debugging:</p>
  
  <pre><code>trace(tFormat.font);
  </code></pre>
  
  <p>And returns "Trebuchet MS" as expected.</p>
  
  <p>I'd be very grateful if you can help me understand why this does not work!</p>
  
  <p>Cheers,</p>
  
  <p>Patrick</p>
  
  <p>Edit: when removing </p>
  
  <pre><code>tf.embedFonts = true;
  </code></pre>
  
  <p>the text is displayed with the correct font. Not sure why but this does the trick for now.</p>