Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Embedding fonts at runtime in Adobe AIR

Windows Software


Reply
 
Thread Tools Search this Thread
  #1  
Old 30-06-2010
Member
 
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 ?

Reply With Quote
  #2  
Old 30-06-2010
Dr. V
 
Posts: n/a
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;
Reply With Quote
  #3  
Old 30-06-2010
Member
 
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);
                }
            }
Reply With Quote
  #4  
Old 30-06-2010
Member
 
Join Date: May 2008
Posts: 2,675
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 !!!
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Embedding fonts at runtime in Adobe AIR"
Thread Thread Starter Forum Replies Last Post
Embedding an Adobe font using Cufon Sarag Windows Software 4 29-06-2010 06:42 PM
Type 1 fonts are not visible on Adobe CS3 Lapentti Windows Software 5 29-06-2010 03:05 AM
Fonts are missing in Adobe Reader 2.0 Doumbia Windows Software 5 27-06-2010 03:53 AM
Can Adobe fonts used in a logo be legal Nataliey Windows Software 4 26-06-2010 01:46 PM
Adobe Type 1 fonts in windows 7 Tylerrr Operating Systems 4 02-04-2010 07:05 AM


All times are GMT +5.5. The time now is 10:07 AM.