0
在試圖在flex 4中使用嵌入字體時遇到了相當多的問題。這裏是情況。使用在運行時加載的嵌入字體的示例Flex 4運行時加載模塊
我有一個主要的應用程序,拳頭通過URL加載字體。這是字體文件代碼:
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時的嵌入字體。
[SWF] /assets/FontLib.swf - 89,594 bytes after decompression libsss [object Font],[object FontLib_myriadFont]
一旦加載了字體swf,然後通過使用ModuleLoader的URL加載第一個模塊。在模塊I執行上創作完成,看看下面的代碼,如果字體加載:
protected function bookstoremodule1_creationCompleteHandler(event:FlexEvent):void
{
var fonts:Array = Font.enumerateFonts(false);
trace('bs',fonts); // This shows Verdana as a registered font
}
那加載模塊似乎已經拿起字體:
load module success: bs [object FontLib_myriadFont]
然而,當我不能讓它適用於火花RichText組件。下面是它的mxml:
<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時,它會停止工作。
任何想法?我已經試過的東西負荷,但仍沒有運氣:(
感謝
感謝那肯定幫助我瞭解升技更多。如果我的理解,這意味着SWF中加載字體SWF則SWF中加載的SWF B,這意思是Swf B永遠不會找到由SWF A加載的字體,因爲它不在正確的SWF上下文中?如果是這樣,那麼Swf B如何列舉正確的字體呢? – charleetm 2010-07-14 18:25:11