在TLFTextField中使用嵌入的字体 [英] Using embedded fonts with TLFTextField

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

问题描述

我不知道你的情况,但是我很难把我的头弄到TLF。



我正在使用Flash CS5。我有从外部SWF加载的嵌入式字体。据我所知,它嵌入正确 - 它曾经工作之前,我从经典的TextField切换 - 但我需要切换,因为我需要先进的连字支持。我的代码是:

  //设置... 
var text:TFLTextField = new TLFTextField();
text.width = 530;
text.height = 330;
text.type = TextFieldType.INPUT;
text.text =在这里输入你自己的文字;
text.embedFonts = true;
addChild(text);

var format:TextLayoutFormat = new TextLayoutFormat();
format.fontSize = currentSize;
format.ligatureLevel = LigatureLevel.EXOTIC;

textFlow = text.textFlow;
textFlow.hostFormat = format;
textFlow.flowComposer.updateAllControllers();

...稍后当字体被加载时:

private function fontLoadedHandler(e:Event):void {
var a:Array = Font.enumerateFonts();

for(var i:Number = 0; i< a.length; i ++){
trace(a [i]); //字体名称在列表中显示得很好...

$ b var format:TextLayoutFormat = new TextLayoutFormat();
format.fontFamily = e.currentTarget.fontName;
format.fontLookup = FontLookup.EMBEDDED_CFF;
format.fontSize = currentSize;

textFlow.invalidateAllFormats();
textFlow.hostFormat = format;

textFlow.flowComposer.updateAllControllers();



$ b当我编译时,它默认为Times New Roman。我已经做了一个合理的谷歌搜索量,并发现这一点: http://forums.adobe.com/message / 3477909



这个家伙似乎和我有类似的问题,但我已经尝试了他的解决方案,得到了同样的负面结果。



任何帮助或链接或任何东西将不胜感激!

谢谢,
Andrey



编辑: 只是尝试将字体切换为Arial,并再次回到Times New Roman。所以显然,问题不在于嵌入,而是在于我分配字体的方式 - 这意味着这可能不像我原先想象的那么复杂。刮开,Arial在将embedFonts更改为false后工作。所以这个问题毕竟是嵌入的。

解决方案

对,我现在知道问题到底是什么。我要离开这个来作为TLF(很多人想象中的)很困惑的其他人的警告。



这个问题来自于大纲格式TLF和经典文本使用。显然,TLF只能与DF4一起工作,而Classic Text只能与DF3一起工作。您可以从嵌入对话框的Actionscript选项卡(Flash CS5,不确定CS4)更改这些设置。



我不确定是否有解决方法为此 - 我一定会去寻找一个,因为此刻我需要同时使用DF3和连字 - 但我认为这足以帮助任何其他人在未来遇到这个问题。 p>

Andrey


I don't know about you but I'm having a really hard time getting my head around TLF.

I'm using Flash CS5. I've got an embedded font loaded from an external SWF. As far as I can tell, it's embedded properly - it used to work before I switched from the classic TextField - but I needed to switch because I need the advanced ligature support. My code is:

//setting up...
var text:TFLTextField = new TLFTextField();
text.width = 530;
text.height = 330;
text.type = TextFieldType.INPUT;
text.text = "Enter your own text here";
text.embedFonts = true;
addChild(text);

var format:TextLayoutFormat = new TextLayoutFormat();
format.fontSize = currentSize;
format.ligatureLevel = LigatureLevel.EXOTIC;

textFlow = text.textFlow;
textFlow.hostFormat = format;
textFlow.flowComposer.updateAllControllers();

//... later on, when the font is loaded:

private function fontLoadedHandler(e:Event):void {
var a:Array = Font.enumerateFonts();

for (var i:Number = 0; i < a.length; i++) {
trace(a[i]); //font name shows up just fine in the list...
}

var format:TextLayoutFormat = new TextLayoutFormat();
format.fontFamily = e.currentTarget.fontName;
format.fontLookup = FontLookup.EMBEDDED_CFF;
format.fontSize = currentSize;

textFlow.invalidateAllFormats();
textFlow.hostFormat = format;           

textFlow.flowComposer.updateAllControllers();
}

When I compile, it defaults to Times New Roman. I've done a reasonable amount of Googling, and discovered this: http://forums.adobe.com/message/3477909

The guy seems to have a similar problem to mine, but I've tried his solution and got the same negative result.

Any help or links or anything would be greatly appreciated!

Thanks, Andrey

Edit: Just tried to switch the font to Arial, and it fell back to Times New Roman again. So apparently the problem is not with the embedding, but with the way I assign the font - meaning this may be less complicated than I originally thought. Scratch that, Arial worked after I changed embedFonts to false. So the problem is embedding after all.

解决方案

Right, I know exactly what the problem is now. I'm leaving this to serve as a warning for anyone else who's tremendously confused by TLF (a lot of people I imagine).

The problem arises from compatibility issues between the outline formats that TLF and Classic Text use. Apparently, TLF only works exclusively with DF4, and Classic Text works exclusively with DF3. You can change these settings from the Embed dialog, under the Actionscript tab (Flash CS5, not sure about CS4).

I'm not really sure if there is a workaround for this - and I'm definitely going to look for one since at the moment I need to use both DF3 AND ligatures - but I think this is enough of an answer to help anyone else who stumbles upon this issue in the future.

Andrey

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

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