|
| ||||||||||
| Tags: adobe air, application, class, embedded fonts, font, loader obejct, swf file, url |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Embedding fonts at runtime in Adobe AIR
|
|
#2
| |||
| |||
| 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
| |||
| |||
| 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
| ||||
| ||||
| 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 !!! |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 05:42 PM |
| Type 1 fonts are not visible on Adobe CS3 | Lapentti | Windows Software | 5 | 29-06-2010 02:05 AM |
| Fonts are missing in Adobe Reader 2.0 | Doumbia | Windows Software | 5 | 27-06-2010 02:53 AM |
| Can Adobe fonts used in a logo be legal | Nataliey | Windows Software | 4 | 26-06-2010 12:46 PM |
| Adobe Type 1 fonts in windows 7 | Tylerrr | Operating Systems | 4 | 02-04-2010 06:05 AM |