Flash嵌入字体问题

2012-07-05 10:11:20

<h3>1. 嵌入字体</h3><p>Actionscript代码&nbsp;</p><pre class="ql-syntax" spellcheck="false">[Embed(source=<span class="hljs-string">"c:/windows/fonts/FREESCPT.TTF"</span>,&nbsp;fontName=<span class="hljs-string">"Freestyle"</span>,&nbsp;unicodeRange=<span class="hljs-string">"U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E"</span>)]&nbsp;&nbsp; public&nbsp;static&nbsp;var&nbsp;freestyle:Class;&nbsp;&nbsp; </pre><h3>2. 使用字体</h3><p>&nbsp;Actionscript代码</p><pre class="ql-syntax" spellcheck="false"><span class="hljs-keyword">var</span>&nbsp;tf:TextField&nbsp;=&nbsp;<span class="hljs-keyword">new</span>&nbsp;TextField();&nbsp;&nbsp; tf.defaultTextFormat&nbsp;=&nbsp;<span class="hljs-keyword">new</span>&nbsp;TextFormat(<span class="hljs-string">"Freestyle"</span>,&nbsp;<span class="hljs-number">30</span>,&nbsp;<span class="hljs-number">0</span>);&nbsp;&nbsp; tf.embedFonts&nbsp;=&nbsp;<span class="hljs-literal">true</span>;&nbsp;&nbsp; tf.autoSize&nbsp;=&nbsp;<span class="hljs-string">"left"</span>;&nbsp;&nbsp; tf.text&nbsp;=&nbsp;<span class="hljs-string">"Hello&nbsp;World!"</span>;&nbsp;&nbsp; addChild(tf);&nbsp;&nbsp; </pre><p>&nbsp;如果要在Flex3.X中嵌入字体,到此就可以结束了。但是在Flex4.0 SDK中字体很有可能无法显示。这就需要下面的步骤了。</p><h3>3. 解决Flex4.0 SDK的问题</h3><p>&nbsp;方法1,在embed标签中加入embedAsCFF=”false”。</p><p>Actionscript代码&nbsp;</p><pre class="ql-syntax" spellcheck="false">[Embed(source=<span class="hljs-string">"c:/windows/fonts/FREESCPT.TTF"</span>,&nbsp;embedAsCFF=<span class="hljs-string">"false"</span>,&nbsp;fontName=<span class="hljs-string">"Freestyle"</span>,&nbsp;unicodeRange=<span class="hljs-string">"U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E"</span>)]&nbsp;&nbsp; public&nbsp;<span class="hljs-keyword">static</span>&nbsp;<span class="hljs-keyword">var</span>&nbsp;freestyle:Class;&nbsp;&nbsp; </pre><p>&nbsp;方法2,修改SDK目录下flex-config.xml文件。</p><pre class="ql-syntax" spellcheck="false">flash.fonts.AFEFontManager </pre><p>将AFEFontManager挪到的最后一行。</p><p>&nbsp;<strong>注:embedAsCFF 如果不提供这个参数,默认就是true;所以,如果系统你嵌入的字体用于TextField,一定要将其设置为false</strong></p><p><br></p><p><br></p><p><br></p>