Results 1 to 4 of 4

Thread: Embedding fonts at runtime in Adobe AIR

  1. #1
    Join Date
    Apr 2010
    Posts
    42

    Embedding fonts at runtime in Adobe AIR

    I am going to do something that I haven't did before but got some hints about this, it can be possible and then started to do it. I need some help of you all. I am trying to register fonts which are saved within the external SWF , and wanted to embed them at the runtime into an Adobe AIR application. I am just working with a File object to load the SWF in this case, but am not completely sure about the procedure to register the fonts and what I have to do after that. Anyone has any suggestion or guidelines for this ?

  2. #2
    Dr. V Guest

    Re: Embedding fonts at runtime in Adobe AIR

    There are some little bit changes that you have to commit to do this. And some of the object are available through which you can do it. You need to use a Loader obejct to load the SWF. Then after reference the class name for the font in the specified SWF file, it can be implemented in this way :

    var Fontttt:Font = new Font1(); // "Font1" class name specified for font in the SWF file.
    var Formatttt:TextFormat = new TextFormat();
    Formatttt.font = Fontttt.fontName;

  3. #3
    Join Date
    Apr 2010
    Posts
    42

    Re: Embedding fonts at runtime in Adobe AIR

    Here is the code which I have to perform this task . Commonly, I issued a button, a file open dialog pops up, and then I use a Loader to load the SWF. But I don't have any idea about the registration procedure of the font after that? Is what I am manipulating in fontLoaded() fine ?

    Code:
    import flash.utils.describeType;
                import mx.controls.SWFLoader;
                private var FtFile: FileReference = new FileReference();
                
                private var Ft: File = new File();
                
                private function initApp(): void
                {
                    var embdFonts: Array = Font.enumerateFonts(false);
                    trace ("=== BEFORE ===");
                    for (var lpi: int = 0; lp < embdFonts.length; lp++)
                    {
                        var item: Font = embdFonts[lp];
                        trace("["+lp+"] name: "+item.fontName + ", style: "+ item.fontStyle+", type: "+item.fontType);
                    }    
                    btnLoadFont.addEventListener(MouseEvent.CLICK, loadFont);
                }
                
                private function loadFont(e: MouseEvent): void
                {
                    Ft.browseForOpen("Select Font");
                    Ft.addEventListener(Event.SELECT, fontSelect);
               
                }
                
                private function fontSelect(e: Event): void
                {
                    trace("File: "+Ft.url);
                    var loader: Loader = new Loader();
                    var context: LoaderContext;
                    
                    var loaderInfo: LoaderInfo = loader.contentLoaderInfo;
                    
                    loaderInfo.addEventListener(Event.COMPLETE, fontLoaded);
                    context = new LoaderContext( true, new ApplicationDomain( ApplicationDomain.currentDomain ) );
                    loader.load(new URLRequest(Ft.url), context);
                }
                
                private function fontLoaded(e: Event): void
                {
                    trace(e.target);
                    
                    var FtLib:Class = ApplicationDomain((e.target as LoaderInfo).applicationDomain).getDefinition('_Verdana') as Class;
                   
                    Font.registerFont(FtLib);
                    
              
                    var embdFonts: Array = Font.enumerateFonts(false);
                    trace("=== AFTER ===");
                    for (var lp: int = 0; lp < embdFonts.length; lp++)
                    {
                        var item: Font = embdFonts[lp];
                        trace("["+lp+"] name: "+item.fontName + ", style: "+ item.fontStyle+", type: "+item.fontType);
                    }
                }

  4. #4
    Join Date
    May 2008
    Posts
    2,684

    Re: Embedding fonts at runtime in Adobe AIR

    Actually! I got you now, Do you desired the user to open to choose a SWF file which has the font? This may cause the issue because the URL is not present in the application directory. If you just need to load a SWF file, entitled as EmbeddedFonts.swf in your application folder specified as which has embedded fonts, make the changes in your according to this !!!

Similar Threads

  1. Embedding an Adobe font using Cufon
    By Sarag in forum Windows Software
    Replies: 4
    Last Post: 29-06-2010, 05:42 PM
  2. Type 1 fonts are not visible on Adobe CS3
    By Lapentti in forum Windows Software
    Replies: 5
    Last Post: 29-06-2010, 02:05 AM
  3. Fonts are missing in Adobe Reader 2.0
    By Doumbia in forum Windows Software
    Replies: 5
    Last Post: 27-06-2010, 02:53 AM
  4. Can Adobe fonts used in a logo be legal
    By Nataliey in forum Windows Software
    Replies: 4
    Last Post: 26-06-2010, 12:46 PM
  5. Adobe Type 1 fonts in windows 7
    By Tylerrr in forum Operating Systems
    Replies: 4
    Last Post: 02-04-2010, 06:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •