/ Published in: ActionScript 3
embeded multiple fonts
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package { import flash.text.Font; public class MyFonts { [Embed(source = '../fonts/visitor2.ttf', fontName = 'visitor2', embedAsCFF = 'false')] private var visitor2:Class; [Embed(source = '../fonts/bitlow.ttf', fontName = 'bitlow', embedAsCFF = 'false')] private var bitlow:Class; [Embed(source = '../fonts/Sansation_Regular.ttf', fontName = 'Sansation_Regular', embedAsCFF = 'false')] private var Sansation_Regular:Class; [Embed(source = '../fonts/LiberationSerif_Regular.ttf', fontName = 'LiberationSerif_Regular', embedAsCFF = 'false')] private var LiberationSerif_Regular:Class; [Embed(source = '../fonts/f04b_08.ttf', fontName = 'f04b_08', embedAsCFF = 'false')] private var f04b_08:Class; [Embed(source = '../fonts/calibri.ttf', fontName = 'calibri', embedAsCFF = 'false')] private var calibri:Class; [Embed(source = '../fonts/baars.ttf', fontName = 'baars', embedAsCFF = 'false')] private var baars:Class; [Embed(source = '../fonts/BabelSans.ttf', fontName = 'BabelSans', embedAsCFF = 'false')] private var BabelSans:Class; private static const MyFonts:Array = [ 'visitor2', 'bitlow', 'Sansation_Regular', 'LiberationSerif_Regular', 'f04b_08', 'calibri', 'baars', 'BabelSans' ]; public function MyFonts() { var length:int = MyFonts.length; for (var i:int; i < length; i++) { Font.registerFont(this[MyFonts[i]]); } } } } private var tfStatus:TextField; private function showStatusMessage(message:String):void { if (!tfStatus) { tfStatus = new TextField(); var format:TextFormat = new TextFormat(); format.size = 10; format.align = TextFormatAlign.CENTER; format.font = "Sansation_Regular"; tfStatus.embedFonts = true; //tfStatus.autoSize = TextFieldAutoSize.CENTER; tfStatus.defaultTextFormat = format; tfStatus.text = message; tfStatus.width = stage.stageWidth - 10; tfStatus.wordWrap = false; tfStatus.x = 5; tfStatus.y = 460; tfStatus.antiAliasType = AntiAliasType.ADVANCED; tfStatus.visible = true; addChild(tfStatus); } else { tfStatus.visible = true; tfStatus.text = message; } }
URL: http://www.flashdevelop.org/community/viewtopic.php?f=13&t=7999