[转]Flex应用中如何利用source属性嵌入字体的例子
http://blog.minidx.com/2008/04/02/674.html
接下来的例子中演示了Flex应用中如何利用[Embed] metadata的source属性嵌入字体。
下面是完整代码:
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" applicationComplete="init();"> <mx:Script> <![CDATA[ import mx.utils.ObjectUtil; [Embed(source="assets/Base 02.ttf", fontName="EmbeddedBase02", mimeType="application/x-font")] private var EmbeddedBase02:Class; private function init():void { var c:Font = new EmbeddedBase02(); ta.text = ObjectUtil.toString(c); } ]]> </mx:Script> <mx:ApplicationControlBar dock="true"> <mx:Label id="lbl" text="The quick brown fox jumped over the lazy dog." fontFamily="EmbeddedBase02" fontSize="18" /> </mx:ApplicationControlBar> <mx:TextArea id="ta" editable="false" width="100%" height="100%" /> </mx:Application>
[Embed(source="assets/Base 02.ttf", fontName="EmbeddedBase02", mimeType="application/x-font", unicodeRange="englishRange")]private var EmbeddedBase02:Class;
[Embed(systemFont="Tahoma", fontName="EmbeddedTahomaItalic", fontStyle="italic", advancedAntiAliasing="true", mimeType="application/x-font")]private var EmbeddedTahomaItalic:Class;