Skip to main content
Known Participant
October 20, 2011
Question

Flash 11, Embedded Fonts - Not Calculated Until Rendered?

  • October 20, 2011
  • 1 reply
  • 2377 views

Hello,

I upgraded to Flash 11 from 10.3 and my truncation logic using TLF no longer works correctly with embedded fonts because, it seems, TextFlow is not processing or applying the embedded font until it is rendered in it's container on screen. To clarify, here is the function I am using to calculate the point at which I need to truncate:

public static function findLastVisibleIndex(textFlow:TextFlow, width:int, height:int):int {

                                        var textFlowComposer:IFlowComposer = textFlow.flowComposer;

                                        if (textFlowComposer.numControllers == 0) {

                                                  textFlowComposer.addController(new ContainerController(new Sprite(), width, height));

                                        }

                                        var lastContainerController:ContainerController = textFlowComposer.getControllerAt(textFlowComposer.numControllers - 1);

                                        lastContainerController.setCompositionSize(width, height);

                                        textFlowComposer.updateAllControllers();

 

                                        var lastVisibleTextFlowLine:TextFlowLine = lastContainerController.tlf_internal::getLastVisibleLine();

                                        var endPosition:int = lastVisibleTextFlowLine.absoluteStart + lastVisibleTextFlowLine.textLength - 1;

 

                                        return endPosition;

}

If I use any device font like Times, Courier, Arial, etc. it measures perfectly to the last character than can fit in a container of a specified size. In Flash 10.3 this works the same/correctly with embedded fonts (I tested it again to be sure). When I upgraded to Flash 11, however, it seems the embedded fonts aren't taking in time. The reason I think that is because when I look at:

trace(textFlowComposer.getLineAt(i).getTextLine(true).textBlock.dump().toString());

If I use an embedded font, I always get Times Roman (while the size is correct at 18):

<glyph isEmbedded='n' fontName='Times New Roman' isBold='n' isItalic='n' gid='42' pointSize='18.00000000000' x='0.00000000000' y='0.00000000000' rotation='0' color='#FF000000'/>

But if I use a device font, the font name is populated correctly.

To add some more information, I am running the above function BEFORE containers (i.e. RichEditableText) are rendered on screen. This is key for my requirements. If, however, I run the above function AFTER containers are renderered - that is, passing in a TextFlow from a rendered RichEditableText on some button click - then everything works again.

So my question is, how can I mimic what is happeneing to TextFlow after everything is rendered but without having to renderer it? And why is the behaviour different between Flash 10.3 and 11?

Thanks!

This topic has been closed for replies.

1 reply

Adobe Employee
October 21, 2011

It's a player issue, which we have no idea. Please post to http://forums.adobe.com/community/flashplayer/using_flashplayer.

TLF is based on Flash Text Engine, and does not have additional code to handle the process you mentioned. We have to debug it to know if there can be a workaround.

Known Participant
October 23, 2011

This may not actually be a Flash Player 11 issue - after further review I see that I'm having the same problems in 10.3. Please see this simplified compilable test app that demonstrates the issue: http://dl.dropbox.com/u/480077/FlexTestTLF.zip

You will notice 4 RichEditableTextContainers. The first two use device fonts (Courier and Arial), and they truncate perfectly. If you look at the trace in the console, you will notice that the fontName is correct as well. The third box, in red, is the problem. This box tries to employ an embeded font, but if you look at the trace, it's not accepting the font and instead using the default Times New Roman. Needless to say if you scroll through the text, you will see that the text is not properly truncated because it's measuring based on Times New Roman but displaying the embedded font. The fourth box is exactly the same as the third box, but solves the problem by applying the truncation at updateComplete, rather than on initialize. If you look at the trace, the font is correct.

What do you make of this? Is there a way to mimic what happens to textFlow on updateComplete but inside initialize?

Thanks.

Known Participant
October 24, 2011

Should I create a new thread for this?