Thanks for the great answer! clears up alot of things for me. Now how do i loop thorugh every character for that leaf? or rather how do i know what character each "atom" is bound to? Is this correct?
while (charPosition < textLine.textBlockBeginIndex + textLine.rawTextLength) {
var atomIndex:int = textLine.getAtomIndexAtCharIndex(charPosition);
var atom:Object = new Object;
atom['char'] = _source.getText(charPosition,charPosition+1);
atom['x'] = textLine.getAtomBounds(atomIndex).x;
atom['y'] = textLine.getAtomBounds(atomIndex).y;
atom['width'] = textLine.getAtomBounds(atomIndex).width;
atom['height'] = textLine.getAtomBounds(atomIndex).height;
var range:TextRange = new TextRange(_source,charPosition,charPosition);
var format:TextLayoutFormat = _source.interactionManager.getCommonCharacterFormat(range);
atom['fontFamily'] = format.fontFamily;
atom['fontSize'] = format.fontSize;
charPosition = textLine.getAtomTextBlockEndIndex(atomIndex);
}
I seem to get one empty atom at the end of this loop.
rawTextLength : int
[read-only] The length of the raw text in the text block that became the line, including the U+FDEF characters representing graphic elements and any trailing spaces, which are part of the line but not are displayed.
Your code seems good. I did not tried to get the atom of textline ago, so I can only share the experience I had.
1.textline.y give me the bottom of the textline not the top. So you need to differ textline.y from textLine.getAtomBounds(atomIndex).y;
2.When you use TLF, code like "_source.interactionManager.getCommonCharacterFormat"is not recommended.
You need to write the code as follows to skip the call of getter function when you will use _source.interactionManager many times. Because when you run "a.b", you call the "get b()" in class "a". "get b()" may be a large function and cost a lot.
var editManager:SelectionManager = _source.interactionManager as SelectionManager;
editManager.getCommonCharacterFormat()