我在使用TLF时遇到了一些问题,我需要解析文本,并为文本字段中的每个字符获取x和y。这就是我目前所知道的..。
从TextFlow获取每个TextLine:
if (textflow.flowComposer) {
for (var i:int = 0; i < textflow.flowComposer.numLines; i++) {
var flowLine:TextFlowLine = textflow.flowComposer.findLineAtPosition(i);
var textLine:TextLine = flowLine.getTextLine(true);
}
}获取TextLine的每个“原子”:
var charPosition:int = textLine.textBlockBeginIndex;
while (charPosition < textLine.textBlockBeginIndex + textLine.rawTextLength) {
var atomIndex:int = textLine.getAtomIndexAtCharIndex(charPosition);
textLine.getAtomBounds(atomIndex);
charPosition = textLine.getAtomTextBlockEndIndex(atomIndex);
}这可以用来获得每个字符的边界,但我仍然需要一些更多的数据,比如它是什么字符,它的字体大小是什么?在做textLine.dump()时,我想我得到了这个数据,但没有得到字符,我得到了一个叫做gid的东西,似乎指向了正在使用的字符,但我不知道如何准确地得到那个字符。有什么好主意?
发布于 2011-06-08 17:17:24
在adobe forum for TLF的金黄的帮助下解决了我的问题。我还没有完全尝试过,但现在似乎可以用了。
https://stackoverflow.com/questions/6198736
复制相似问题