1 Reply Latest reply on Aug 20, 2011 6:25 AM by Laubender

    How to Get the Length of a Line Which Has Been Hyphenated

    mlavie Level 1

      (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.

       

      TIA

       

      mlavie

        • 1. Re: How to Get the Length of a Line Which Has Been Hyphenated
          Laubender Adobe Community Professional & MVP

          Hi, mlavie!

          You could convert your line of text temporarily to oulines and work with the visible bounds of that object.
          Here some sample code in JavaScript (ExtendScript) not in ActionScript:

           

          //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[0].visibleBounds;
          
          //Store the width of the object:
          var myLength = VB[3] - VB[1];
          
          //Or work with x2 of the visible bounds:
          
          var x2 = VB[3];
          
          //Get rid of the temp object:
          myTempObject.remove();
          

           

          That will work with lines that are set horizontally…

           

          You really do need ActionScript?

           

          Uwe