0

我在我的 flex 应用程序中嵌入了一个字体。这适用于任何组件而不会出现问题。

  @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

4

1 回答 1

1

这是一个错误。您可以在adobe 论坛中找到更多信息。还有第二个链接,指向一种解决方法。

BR弗兰克

于 2011-01-28T11:00:57.207 回答