2

I'm working on an Illustrator script (javascript) and I need to measure the width of a letter. This letter is a TextFrameItem with only one character:

enter image description here

The object has an attribute .width which gives the width of the bounding box above.

The length I need to know is the one of the blue baseline.

Any idea to measure it?

superrache
  • 650
  • 11
  • 26
  • 1
    Is that the TextPath? If so (for CS6-and-later), you could try inspecting its pathPoints. – Jongware May 17 '16 at 11:33
  • No, it's a PointText (text.kind = TextType.POINTTEXT). I don't know either how to get the coordinates of the origin point. The top/left attributes are relatives to the bounding box too. However, I can get the rotation matrix. – superrache May 17 '16 at 11:53

1 Answers1

1

The only reliable way I have found to get the width of text is to rasterize the textlayer (dup a copy if you need to retain the original textlayer for later) and then work off the bounds of the rasterized layer.

Anna Forrest
  • 1,711
  • 14
  • 21
  • good idea, but in my case I have thousands texts to deal with, so for performance troubles, I think it's not conceivable. – superrache Jun 02 '16 at 15:15