This content has been marked as final.
Show 2 replies
-
1. Re: Reliably calculating character bounds for Right-To-Left languages using flash.text.engine.* classes?
Brian Vaughn Aug 9, 2012 5:40 AM (in response to Brian Vaughn)Note to myself (and others) - this post seems very promising:
http://forums.adobe.com/message/3155597
More to follow soon, hopefully!
-
2. Re: Reliably calculating character bounds for Right-To-Left languages using flash.text.engine.* classes?
Brian Vaughn Aug 9, 2012 6:04 AM (in response to Brian Vaughn)Update: I was missing something obvious!
It seems like TextLine's getAtomTextBlockBeginIndex and getAtomTextBlockEndIndex methods were exactly what I was looking for. It just took me a while to find them and realize that. So to convert from a logical (unicode) character index to a display (atom) index, you can do this...
private function getCharBounds( charIndex:int ):Rectangle { for ( var childIndex:int = 0; childIndex < textContainer.numChildren; childIndex++ ) { var textLine:TextLine = textContainer.getChildAt( childIndex ) as TextLine; for ( var atomIndex:int = 0; atomIndex < textLine.atomCount; atomIndex++ ) { var charIndexRangeStart:int = textLine.getAtomTextBlockBeginIndex( atomIndex ); var charIndexRangeStop:int = textLine.getAtomTextBlockEndIndex( atomIndex ); if ( charIndex >= charIndexRangeStart && charIndex <= charIndexRangeStop ) { var rectangle:Rectangle = textLine.getAtomBounds( atomIndex ); var point:Point = textContainer.globalToLocal( textLine.localToGlobal( new Point( rectangle.x, rectangle.y ) ) ); rectangle.x = point.x; rectangle.y = point.y; return rectangle; } } } return null; }

