Created
February 29, 2012 15:25
-
-
Save heartcode/1941579 to your computer and use it in GitHub Desktop.
(unicodeRange) Font embedding for ActionScript projects using Flex 4.0+ SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.heartcode.utils.fonts | |
{ | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.text.Font; | |
/** | |
* | |
*/ | |
public class FontLibrary extends Sprite | |
{ | |
[Embed(source = "../../../../../../libs/fonts/Arial.ttf", embedAsCFF="false", fontName="appFont", advancedAntiAliasing="true", fontWeight="normal", mimeType="application/x-font-truetype", unicodeRange = "U+0000-U+007e,U+0095-U+0628,U+0097-U+063a,U+0114-U+0648,U+064a")] | |
private static var appFont:Class; | |
public static const appFontName:String = "appFont"; | |
[Embed(source = "../../../../../../libs/fonts/ArialBold.ttf", embedAsCFF="false", fontName="appBoldFont", advancedAntiAliasing="true", fontWeight="normal", mimeType="application/x-font-truetype", unicodeRange = "U+0000-U+007e,U+0095-U+0628,U+0097-U+063a,U+0114-U+0648,U+064a")] | |
private static var appBoldFont:Class; | |
public static const appBoldFontName:String = "appBoldFont"; | |
// Variables for testing the embedding | |
private static const TEXT_BASIC:String = "abcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n0123456789\n„”!'\"'#«»€£₤$%&'()*+,-./:;<=>?@[\]^_`{|}~©®¹²³\n\nابتثجحخدذرزسشصضطظعغفقكلمنهوي"; | |
private static const fontFamilies:Vector.<String> = new Vector.<String>(3, true); | |
/** | |
* | |
*/ | |
public function FontLibrary(test:Boolean=true):void { | |
Font.registerFont(appFont); | |
Font.registerFont(appBoldFont); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment