-
Notifications
You must be signed in to change notification settings - Fork 1
Alternatives
Alternative solutions to use a font in Flash
The simplest, more demanding. Allow device font (if font installed on user's device) to be used, but disallow graphical and transformation effets like blend modes, filters, rotation, scaling.
Pro :
- Simplest and lightest
Con :
- Work only with installed fonts on device
- Some effects not work with
flash.text.TextField, only if there are rasterized (BitmapData)
Primitive way, usefull when we need to embed a font with only for Latin1 text or just for few chars.
Advantages :
- Simple only for few fonts
Disadvantages :
-
Add weight needed to be loaded, depends number of fonts, their complexity and number of embedded chars
-
Could have heavy for Unicode fonts
2 kind of external libraries exsiting: shared library and runtime shared library (loaded dynamically). Used to externalize an application part, like fonts, code, images, etc., reducing the main application binary weight.
It's supported natively by Flash Player via the usage of SWF tag ImportAsset2. It's know where resources are located and try load it automatically.
This functionality could be used in Flash Professional, at Share in property panel of library elements.
The external SWF must contains the SWF tag ExportAssets defining importable elements.
Advantages :
- Could be used in common for multiple projects
Disadvantages :
-
Could have heavy weight for Unicode fonts
-
Can't change location (library and/or main SWF) without need to recompile
-
Handle load progression is impossible
Same way describe below, but made dynamically (with code), where the location is not predefined. Be able to determine location depending variables like localisation, player version, geolocalisation, etc.
- load the library container with
loaderInstance.load(urlRequestInstance); - once completly loaded, register font
Font.registerFont(loaderInstance.contentLoaderInfo.applicationDomain.getDefinition("fontClassName") as Class);
Advantages :
- Could be used in common for multiple projects
Disadvantages :
-
Need handling load of external SWF and its content
-
Could have heavy weight for Unicode fonts
-
Need to link font to an ActionScript class (with the SWF tag
SymbolClass) in library
Since FlashPlayer 9.0.115.0
SWF files could be signed (*.swz). It's enable crossdomain cache of FlashPlayer, speeding load of same libraries on multiple domains.
Once the signed SWF loaded, this one is keept Ad vitam æternam on user device under a unique ID which allow access to other domains (but on all domains the same original must be present in case of).
var requestInstance:URLRequest = new URLRequest("repository location of SWZ file");
requestInstance.hash = "SHA-256 key";//Where located the file is, the hash permit to identify it and get back from cache directly or if it's not present, loaded from provided URL
urlLoaderInstance.load(requestInstance);//The load of SWZ work only with an URLLoader
[…]//Once the file completly loaded
var loaderInstance:Loader = new Loader();
loaderInstance.load(urlLoaderInstance.data);//load bytes of the SWZNote: Adobe call signed SWF: RSL (Runtime Shared Library)
Note 2: It seem according comment in source of TagValues.java from Flex SDK that SWF Tag ImportAsset2 support also "SHA-1" hash for SWZ
- flash.net.URLRequest.digest
- fl.rsl package
- Improving Flex application performance using the Flash Player cache
It could be used, server side for FontStream
Server side, it's possible to generate a SWF on the fly with a CGI (Flex for Apache, swfmill, etc.), contais one static textfield with needed font chars.
Client side, a simple HTTP call, allow load of it and display :
displayObjectContainerInstance.addChild(loaderInstance);//add the loader to the displaylist
loaderInstance.load(urlRequestInstance);//start loadingAdvantages :
- Simple to handle it, client side
- Small quantity of data over network
Disadvantages :
- Disk and CPU usage, convert format (TTF to SWF)
- Limited usage to dynamic text field, can't handle cumulative resources (successive additions of previous load) ^1^
- Complex server side setting up (could be impossible with specific configurations)
- Need good practices to handle unused ressources client side (
loaderInstance.unloadAndStop()) ^1^
- This disadvantage not exist if, for FontStream, this way is used server side