Skip to main content
Inspiring
May 11, 2010
Answered

Character Coordinates

  • May 11, 2010
  • 1 reply
  • 943 views

Hi,

I'm doing this to find the coordinates of a flowElement in the text flow

var flowline:TextFlowLine = textFlow.flowComposer.findLineAtPosition( flowElement.getAbsoluteStart() );
var rect:Rectangle = flowline.getBounds();

With this, I get x and y of the whole line, x is always the container padding.

How can I get the coordinates of a character, not the whole line?

Tks.

This topic has been closed for replies.
Correct answer

TLF actually doesn't know where the characters are drawn - that's the job of the new text engine inside of Flash Player. So you can't get the information you want from any of the classes in the flashx.textLayout packages.

What you need is to drill down to the flash.text.engine classes. From the TLF class TextFlowLine you can get the corresponding flash.text.engine.TextLine, which has AtomBounds methods for determining where glyphs are placed inside the line. They're called Atoms because a single Atom may be a glyph representing one or more characters (for instance, an fi ligature is two characters but one atom)

var textLine:TextLine = flowline.getTextLine();

var firstAtomBounds:Rectangle = textLine.getAtomBounds(0);

var secondAtomBounds:Rectangle = textLine.getAtomBounds(1);

These rects will be relative to the TextLine's bounds.

1 reply

Correct answer
May 11, 2010

TLF actually doesn't know where the characters are drawn - that's the job of the new text engine inside of Flash Player. So you can't get the information you want from any of the classes in the flashx.textLayout packages.

What you need is to drill down to the flash.text.engine classes. From the TLF class TextFlowLine you can get the corresponding flash.text.engine.TextLine, which has AtomBounds methods for determining where glyphs are placed inside the line. They're called Atoms because a single Atom may be a glyph representing one or more characters (for instance, an fi ligature is two characters but one atom)

var textLine:TextLine = flowline.getTextLine();

var firstAtomBounds:Rectangle = textLine.getAtomBounds(0);

var secondAtomBounds:Rectangle = textLine.getAtomBounds(1);

These rects will be relative to the TextLine's bounds.

Participating Frequently
May 12, 2010
They're called Atoms because a single Atom may be a glyph representing one or more characters (for instance, an fi ligature is two characters but one atom)


Actually, the input string <f, i> will result in two atoms, regardless of whether the font forms a ligature or not.

It's for a string of the form <e, combining acute> that you will get a single atom.Roughly atom = default grapheme cluster (in the Unicode sense) = combining sequence or hangul jamo sequence, except for Indic scripts where atom = akshara (e.g. <ka, virama, ka> is a single atom).

Eric.