问题
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.
回答1:
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
回答2:
in case any one else has issues with DF3 and DF4 ... you can embed both at once,
for example "Helvetica" with DF4 and "Helvetica" with DF3 (the important part is that they can both use the same name) ... then you can use the font "Helvetica" with both old textfields and the newer TLF textfields.
it doubles the filesize, since you are embeding the font twice, but works like a charm.
this also applies to Flex.
来源:https://stackoverflow.com/questions/6096490/using-embedded-fonts-with-tlftextfield