Packagevegas.text
Classpublic class FontLoader
InheritanceFontLoader Inheritance CoreLoader Inheritance flash.display.Loader

This loader load an external swf who contains embed fonts.

Example :

     import vegas.events.FontEvent ;
     import vegas.text.CoreTextField ;
     import vegas.text.FontLoader ;
     
     import flash.events.Event ;
     import flash.net.URLRequest ;
     import flash.system.LoaderContext ;
     import flash.text.TextFormat ;
     
     var field1:CoreTextField = new CoreTextField( null , 150 , 20 ) ;
     field1.border     = true ;
     field1.embedFonts = true ;
     field1.x          = 25 ;
     field1.y          = 25 ;
     
     var field2:CoreTextField = new CoreTextField( null , 150 , 20 ) ;
     field2.x      = 25 ;
     field2.y      = 50 ;
     field2.border = true ;
     
     field2.textColor = 0x000000 ;
     field2.embedFonts = true ;
     
     addChild(field1) ;
     addChild(field2) ;
     
     var addFont:Function = function( e:FontEvent ):void
     {
         trace( e.type + " font:" + e.font ) ;
     }
     
     var complete:Function = function( e:Event )
     {
     
         trace( "fonts : " + Font.enumerateFonts() ) ;
         
         field1.defaultTextFormat = new TextFormat("Arial Black", 12 , 0xFFFFFF ) ;
         field1.text = "hello world" ;
         
         field2.defaultTextFormat = new TextFormat("Myriad Pro", 12 , 0xFFFFFF ) ;
         field2.text = "hello world" ;
     }
     
     var request:URLRequest = new URLRequest( "fonts/fonts.swf" ) ;
     
     var loader:FontLoader = new FontLoader() ;
     
     loader.context = new LoaderContext( false , ApplicationDomain.currentDomain ) ;
     
     loader.contentLoaderInfo.addEventListener( Event.COMPLETE , complete ) ;
     loader.addEventListener( FontEvent.ADD_FONT , addFont ) ;
     
     loader.registerFontClassName( "ArialBlack" ) ;
     loader.registerFontClassName( "MyriadPro" ) ;
     
     // You can use the autoRegister flag, the loader find the Font class in the external library for you
     // loader.autoRegister = true ;
     
     loader.load( request  ) ;
     

the external file "font/fonts.swf" contains in this library the two Font symbols.



Public Properties
 PropertyDefined By
  autoRegister : Boolean
Indicates if the fonts in the external swf library (symbol class) are auto registered when the external file is loading.
FontLoader
 Inheritedcontext : LoaderContext
The LoaderContext object of this loader.
CoreLoader
 Inheritedlogger : Logger
Determinates the internal ILogger reference of this Logable object.
CoreLoader
Protected Properties
 PropertyDefined By
  _fontClassNames : HashSet
The font class name.
FontLoader
Public Methods
 MethodDefined By
  
Creates a new FontLoader instance.
FontLoader
 Inherited
isLocked():Boolean
Returns true if the object is locked.
CoreLoader
 Inherited
load(request:URLRequest, context:LoaderContext = null):void
[override] Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into an object that is a child of this Loader object.
CoreLoader
 Inherited
lock():void
Locks the object.
CoreLoader
  
registerFontByName(name:String, domain:ApplicationDomain = null):void
Register the specified Font with the passed-in font name.
FontLoader
  
registerFontClassName(name:String):Boolean
Registers a new FontClassName in the specified FontLoader.
FontLoader
 Inherited
resetLock():void
Reset the lock security of the display.
CoreLoader
  
size():uint
Returns the number of embed fonts to load and create with this loader.
FontLoader
  
toArray():Array
Returns the Array representation of the font names.
FontLoader
 Inherited
unlock():void
Unlocks the display.
CoreLoader
  
unRegisterFontClassName(name:String):Boolean
Unregisters a new FontClassName in the specified FontLoader.
FontLoader
Protected Methods
 MethodDefined By
  
complete(e:Event):void
Invoked when the FontLoader process is complete.
FontLoader
Events
 Event Summary Defined By
  Dispatched when a new font is registered in the application.FontLoader
Property Detail
_fontClassNamesproperty
protected var _fontClassNames:HashSet

The font class name.

autoRegisterproperty 
public var autoRegister:Boolean

Indicates if the fonts in the external swf library (symbol class) are auto registered when the external file is loading.

Constructor Detail
FontLoader()Constructor
public function FontLoader()

Creates a new FontLoader instance.

Method Detail
complete()method
protected function complete(e:Event):void

Invoked when the FontLoader process is complete.

Parameters

e:Event

registerFontByName()method 
public function registerFontByName(name:String, domain:ApplicationDomain = null):void

Register the specified Font with the passed-in font name.

Parameters

name:String — The full class name of the font to register.
 
domain:ApplicationDomain (default = null) — The ApplicationDomain use to get the definition of the Font class with the specified name. If this parameter is null the ApplicationDomain.currentDomain is used.

registerFontClassName()method 
public function registerFontClassName(name:String):Boolean

Registers a new FontClassName in the specified FontLoader.

Parameters

name:String

Returns
Boolean
size()method 
public function size():uint

Returns the number of embed fonts to load and create with this loader.

Returns
uint — the number of embed fonts to load and create with this loader.
toArray()method 
public function toArray():Array

Returns the Array representation of the font names.

Returns
Array — the Array representation of the font names.
unRegisterFontClassName()method 
public function unRegisterFontClassName(name:String):Boolean

Unregisters a new FontClassName in the specified FontLoader.

Parameters

name:String

Returns
Boolean
Event Detail
addFont Event
Event Object Type: vegas.events.FontEvent
FontEvent.type property = vegas.events.FontEvent.ADD_FONT

Dispatched when a new font is registered in the application.