使用在运行时加载的嵌入式字体的示例Flex 4运行时加载的模块 [英] Example of using embedded fonts loaded at runtime Flex 4 runtime loaded modules
问题描述
在尝试在flex 4中使用嵌入字体时遇到很多问题.这种情况.
am having quite alot of problems trying to use embeded fonts in flex 4. Here is the situation.
我有一个主应用程序,该应用程序首先通过URL加载字体.这是字体文件代码:
I have a main application that fist load the fonts via a URL. This is the font file code:
package{
import flash.display.Sprite;
import flash.text.Font;
public class FontLib extends Sprite
{
[Embed(source="MyriadPro-Regular.otf", fontWeight= "normal", fontName="Myriad Pro", fontFamily="Myriad Pro",mimeType="application/x-font", embedAsCFF="true")]
public const myriadFont:Class;
public function FontLib()
{
Font.registerFont(myriadFont);
var fonts:Array = Font.enumerateFonts(false);
trace('libsss',fonts);
}
}}
这似乎行得通.由于跟踪显示了加载字体swf时的嵌入字体.
That seems to work ok. As the trace shows the embedded font when the font swf is loaded.
[SWF] /assets/FontLib.swf - 89,594 bytes after decompression libsss [object Font],[object FontLib_myriadFont]
一旦加载了字体swf,我便使用ModuleLoader通过URL来加载第一个模块.在模块中,我在创建完成时执行以下代码,以查看是否加载了字体:
Once the font swf is loaded I then load the fist module via a URL using ModuleLoader. In the module I execute the following code on creation complete to see if the fonts are loaded:
protected function bookstoremodule1_creationCompleteHandler(event:FlexEvent):void
{
var fonts:Array = Font.enumerateFonts(false);
trace('bs',fonts); // This shows Verdana as a registered font
}
那加载的模块似乎已经选择了字体:
Thats loaded module seem to have picked up the font:
load module success: bs [object FontLib_myriadFont]
但是,当我无法将其应用于Spark RichText组件时.这是它的mxml:
However when I cannot get it to apply to a spark RichText component. Here is the mxml for it:
<s:RichText fontLookup="embeddedCFF" renderingMode="cff" ai:aa="2" color="#2F4160" columnCount="1" fontFamily="Myriad Pro" fontSize="18.0737" height="20" d:id="4" kerning="on" tabStops="S40.665699005127 S81.3313980102539 S121.997097015381 S162.662796020508" text="Shopping Cart (0)" d:userLabel="Shopping Cart (0)" flm:variant="1" whiteSpaceCollapse="preserve" width="168" x="53" y="12" x.down="54" y.down="13" id="richtext1">
<s:filters>
<s:DropShadowFilter blurX="0" blurY="0" color="#FFFFFF" distance="1.41421" quality="2"/>
</s:filters>
</s:RichText>
当字体直接嵌入模块中时,mxml定义很好.当字体作为swf加载时,它只是停止工作.
The mxml definition is fine when the font is embedded directly in the module. It just stops working when the font is loaded as a swf.
有什么想法吗?我已经尝试了很多东西,但是仍然没有运气:(
Any ideas? I have tried loads of things but still having no luck :(
谢谢
推荐答案
很遗憾,我没有太多时间来深入研究此问题,但本文可能会让您感兴趣:
I unfortunately don't have too much time to have a deep look at this problem but this article might interest you :
http://blogs.adobe.com/aharui/2010/03 /flex_and_embedded_fonts.html
它讨论了注册字体并在模块中使用它们
It talks about registering fonts and using them in modules
这篇关于使用在运行时加载的嵌入式字体的示例Flex 4运行时加载的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!