(For CS5 and ActionScript)
I need to get the length of a Line in a TextFrame. Of course, the formula for this is normally endHorizontalOffset - horizontalOffset.
The problem is that if a line has been autmatically hyphenated, the endHorizontalOffset equals the length up to and including the last letter from the first half of the split word, and NOT the length including the end of the automatic hyphen.
I do know how to identify if hyphenation has taken place, but I have no idea how to get the length up to and including the added automatic hyphen.
I'd appreciate any help.
You could convert your line of text temporarily to oulines and work with the visible bounds of that object.
//Duplicates the line to outlines: var myTempObject = myLine.createOutlines(false); //The result is an array holding that object with a length of 1. //Now you can work with the visible bounds: var VB = myTempObject.visibleBounds; //Store the width of the object: var myLength = VB - VB; //Or work with x2 of the visible bounds: var x2 = VB; //Get rid of the temp object: myTempObject.remove();
That will work with lines that are set horizontally…
You really do need ActionScript?