I have embedded a Font in my flex app. That works on any components without problems.
@font-face {
src:url("../assets/fonts/wedtxtn.ttf");
fontFamily: "CSSFont";
cff: true;
}
However, when I try to apply the font to my TextFlow object, it is not working. However, it does work when I use the FTE and do it my self. I debugged through the TLF and the looks like the correct FontDescription is created.
Here is the code I use to create text (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
this is a bug. More informations yo can find in the adobe forum. There are a second link, pointing to a workaround.
BR Frank