title: Embedded font from dynamically loaded swf not recognised
body: <p>I am working on an application which needs to load fonts dynamically based upon the fonts used in a given document that the user opens. The fonts are used in a RichEditableTextControl so need to be CFF format. </p>
  
  <p>If I add the code:</p>
  
  <pre><code>[Embed(source="/assets/fonts/AvenirLTStd Book.otf",
  fontFamily="EmbedAvenir LT Std 45 Book",
  mimeType="application/x-font",
  embedAsCFF="true")]
  public const embeddedFont:Class;
  </code></pre>
  
  <p>to the main SWF then the text displays correctly with the embedded font but moving the code to a separate file and adding a loader as per the information I found at the following link does not load the font - <a href="http://www.scottgmorgan.com/blog/index.php/2007/06/18/runtime-font-embedding-in-as3-there-is-no-need-to-embed-the-entire-fontset-anymore/" rel="nofollow">http://www.scottgmorgan.com/blog/index.php/2007/06/18/runtime-font-embedding-in-as3-there-is-no-need-to-embed-the-entire-fontset-anymore/</a></p>
  
  <p>The loader code is:</p>
  
  <pre><code>private function loadFont(url:String):void {
      var loader:Loader = new Loader();
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fontLoaded);
      loader.load(new URLRequest(url));
  }
  
  private function fontLoaded(event:Event):void {
      var FontLibrary:Class = event.target.applicationDomain.getDefinition("FontAvenirLTStd") as Class;
      Font.registerFont(FontLibrary.embeddedFont);
  }
  </code></pre>
  
  <p>There is an error thrown at the <code>Font.registerFont</code> line to say that the parameter being passed cannot be null. I have checked in debug mode and the issue seems to be that the class exists but does not have any content. The FontLibrary class is instantiated but the only child entry in the debugger is _prototype so trying to access the <code>embeddedFont</code> property does return undefined.</p>
  
  <p>At the moment the font SWF is in the assets folder of the main project so I don't believe there should be any security restrictions and, as I said, the SWF loading part appears to work.</p>
  
  <p>One thing which is hampering my diagnostics is that I am not sure if the problem is the font SWF not being created correctly and having no content or if the main app is unable to load it. Any help on at least being able to narrow that down would be appreciated.</p>
  
  <p>I would appreciate all the help I can get on this as I have been stuck at this problem for some time and it is a key part of the application.</p>
  
  <p>Thanks in advance to everyone.</p>