使用在运行时加载的嵌入字体的示例 Flex 4 运行时加载的模块 [英] Example of using embedded fonts loaded at runtime Flex 4 runtime loaded modules

查看:19
本文介绍了使用在运行时加载的嵌入字体的示例 Flex 4 运行时加载的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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 加载 fist 模块.在模块中,我在创建完成时执行以下代码以查看字体是否已加载:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆