我在我的flex应用程序中嵌入了一个Font。这对任何组件都没有问题。
@font-face {
src:url("../assets/fonts/wedtxtn.ttf");
fontFamily: "CSSFont";
cff: true;
}
但是,当我尝试将字体应用于我的TextFlow对象时,它无法正常工作。但是,当我使用FTE并自己动手时,它确实有效。我通过TLF调试,看起来像是创建了正确的FontDescription。
以下是我用来创建文字的代码(Full Source @ Pastbin)
var element:SpriteVisualElement = new SpriteVisualElement;
element.verticalCenter = 0;
element.horizontalCenter = 0;
// Create Text using TLF
var span:SpanElement = new SpanElement();
span.text = "Hello World!";
var p:ParagraphElement = new ParagraphElement();
p.addChild(span);
var tf:TextFlow = new TextFlow();
tf.addChild(p);
tf.fontLookup = FontLookup.EMBEDDED_CFF;
tf.renderingMode = RenderingMode.CFF;
tf.fontFamily = "CSSFont";
var textContent:Sprite = new Sprite;
textContent.y = -50;
element.addChild(textContent);
var textController:ContainerController = new ContainerController(textContent);
textController.verticalScrollPolicy = ScrollPolicy.OFF;
textController.horizontalScrollPolicy = ScrollPolicy.OFF;
tf.flowComposer.addController(textController);
tf.flowComposer.updateAllControllers();
// Create text using FTE
var fontDescription:FontDescription = new FontDescription("CSSFont");
fontDescription.fontLookup = FontLookup.EMBEDDED_CFF;
fontDescription.renderingMode = RenderingMode.CFF;
var format:ElementFormat = new ElementFormat(fontDescription,25);
var textElement:TextElement = new TextElement("Hello World", format);
var textBlock:TextBlock = new TextBlock(textElement);
var tl:TextLine = textBlock.createTextLine();
tl.y = 50;
element.addChild(tl);
addElement(element);
Flex v4.1, TLF v1.1