嵌入字体flash.text.engine [英] embedded font flash.text.engine

查看:115
本文介绍了嵌入字体flash.text.engine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完全用完了这个想法。由此可见,并且是我的previous问题的一部分:

I've completely run out of ideas on this. It follows, and is part of my previous question:

<一个href="http://stackoverflow.com/questions/12763516/embedding-a-font-in-a-swf-using-as3/12807110#12807110">embedding使用AS3 SWF中的一种字体

embedding a font in a swf using as3

我只是似乎没有能够得到使用我的嵌入字体的flash.text.engine。 NB的字体已被加载到应用程序(如嵌入在瑞士法郎)用户选择后两种语言(用于翻译和从)。似乎有一点点的信息暗示,现在是需要使用fontswf应用程序,它是在SDK中。我曾尝试这样做,可加载生成的SWF文件,但我无法找到如何将这些被装载的任何信息(即低于getDefinition和registerFont位,因为没有课在这些SWF不工作),并应用到text.engine对象。该人士为嵌入是在回答上面我的问题。这是一个测试AS3演示如何这是行不通的!

I just don't seem to be able to get the flash.text.engine to use my embedded font. NB the font has to be loaded into the application (as embedded in swf) after the user has chosen the two languages (for translation to and from). There seems to be a little info implying that it is now necessary to use the fontswf application which is in the sdk. I have tried this and produced loadable swf files but I can't find any info on how these are then loaded (i.e. the getDefinition and registerFont bits below don't work as there are no classes in these swf) and applied to text.engine objects. The source for the embedding is in my answer to my question above. This is a test as3 which demonstrates how it doesn't work!

package 
{
import flash.display.Loader;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.engine.ElementFormat;
import flash.text.engine.FontDescription;
import flash.text.engine.TextBlock;
import flash.text.engine.TextLine;
import flash.text.engine.TextElement;
import flash.net.URLRequest;
import flash.text.Font;

public class Main extends Sprite 
{
    private var loader:Loader;
    private var tl:TextLine;

    public function Main():void 
    {
        loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE,fontLoaded);
        loader.load(new URLRequest("EnglishF.swf"));
    }

    private function fontLoaded(evt:Event):void {
        var FontClass:Class
        FontClass = evt.target.applicationDomain.getDefinition("EnglishF") as Class;
        try {
            Font.registerFont(FontClass.myFont);
            trace("successfully loaded " + FontClass); 
            // gives 'successfully loaded EnglishF'
        } catch (err:Error) {}
        var fontList:Array = Font.enumerateFonts();
        for (var i:int = 0; i < fontList.length; i++) {
            trace(fontList[i].fontName, fontList[i].fontType); 
            // gives 'EnglishF embeddedCFF'
        }
        var block:TextBlock = new TextBlock();
        var font:FontDescription = new FontDescription("EnglishF");
        var formt:ElementFormat = new ElementFormat(font, 30);
        trace(FontDescription.isFontCompatible("EnglishF","normal","normal"), formt.fontDescription.fontName); 
        // gives 'true EnglishF'
        formt.color = 0x882233;
        var span:TextElement = new TextElement("Hello World. This is certainly NOT in the Font provided!", formt);
        block.content = span;
        tl = block.createTextLine();
        tl.x = 10;
        tl.y = tl.ascent + 10;
        addChild(tl);
    }
}
}

难道我做错什么,或者这是不可能的?

Am I doing anything wrong, or is this impossible?

推荐答案

希望这会有所帮助。根据该行:

Hopefully this will help. Under this line:

var font:FontDescription = new FontDescription("EnglishF");

添加以下行:

add the following line:

font.fontLookup = FontLookup.EMBEDDED_CFF;

这将让文本框架知道你正在使用的不是常规的嵌入字体(在文本域使用)一个CFF字体(在新文本框架中使用)。

This will let the text framework know that you're using a CFF font (used in the new text framework), instead of a regular embedded font (used in TextFields).

希望这有助于。

乔丹

这篇关于嵌入字体flash.text.engine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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