title: Using embedded fonts with TLFTextField
body: <p>I don't know about you but I'm having a really hard time getting my head around TLF.</p>
  
  <p>I'm using Flash CS5. I've got an embedded font loaded from an external SWF. As far as I can tell, it's embedded properly - it used to work before I switched from the classic TextField - but I needed to switch because I need the advanced ligature support. My code is:</p>
  
  <pre><code>//setting up...
  var text:TFLTextField = new TLFTextField();
  text.width = 530;
  text.height = 330;
  text.type = TextFieldType.INPUT;
  text.text = "Enter your own text here";
  text.embedFonts = true;
  addChild(text);
  
  var format:TextLayoutFormat = new TextLayoutFormat();
  format.fontSize = currentSize;
  format.ligatureLevel = LigatureLevel.EXOTIC;
  
  textFlow = text.textFlow;
  textFlow.hostFormat = format;
  textFlow.flowComposer.updateAllControllers();
  
  //... later on, when the font is loaded:
  
  private function fontLoadedHandler(e:Event):void {
  var a:Array = Font.enumerateFonts();
  
  for (var i:Number = 0; i &lt; a.length; i++) {
  trace(a[i]); //font name shows up just fine in the list...
  }
  
  var format:TextLayoutFormat = new TextLayoutFormat();
  format.fontFamily = e.currentTarget.fontName;
  format.fontLookup = FontLookup.EMBEDDED_CFF;
  format.fontSize = currentSize;
  
  textFlow.invalidateAllFormats();
  textFlow.hostFormat = format;           
  
  textFlow.flowComposer.updateAllControllers();
  }
  </code></pre>
  
  <p>When I compile, it defaults to Times New Roman. I've done a reasonable amount of Googling, and discovered this: <a href="http://forums.adobe.com/message/3477909" rel="nofollow">http://forums.adobe.com/message/3477909</a></p>
  
  <p>The guy seems to have a similar problem to mine, but I've tried his solution and got the same negative result.</p>
  
  <p>Any help or links or anything would be greatly appreciated!</p>
  
  <p>Thanks,
  Andrey</p>
  
  <p><strong>Edit:</strong> <strike>Just tried to switch the font to Arial, and it fell back to Times New Roman again. So apparently the problem is not with the embedding, but with the way I assign the font - meaning this may be less complicated than I originally thought.</strike> Scratch that, Arial worked after I changed embedFonts to false. So the problem <em>is</em> embedding after all. </p>