3 Replies Latest reply on Sep 26, 2006 2:52 PM by adamjbrown

    TextField padding

    adamjbrown
      Does anyone know the equation for the padding between a textfields borders and the position of the text itself within the box? I am trying to find a ratio between the _y of a textfield and the actual _y position of the top of the first line. Thanks. -Adam
        • 1. Re: TextField padding
          Rothrock Level 5
          I think it depends upon the font. Also what do you mean the _y position of the top of the first line? The top of the letter "A" or the top of "."?

          But I think a general solution for your problem will be the getTextExtent() method of the the TextFormat class. I think you could use it to find the baseline and then go up the amount of the ascent. Maybe?
          • 2. Re: TextField padding
            adamjbrown Level 1
            Thanks for the reply. What I mean by the _y position is the top of the A. I'm translating a docuement created using a Flash interface into a third party format. To do that I have to convert the font metrics line by line into the third partys markup.

            From what I've found so far it appears that a line in a textfield is 1 1/9, I have no idea why the chose that ratio, the size of the largest font contained in that line. So I can take that plus a 2px padding in the field to determine the _y start of the actual characters.

            Now I'm trying to find out how spacing between lines is determined. The default leading is 2px which with 36 point font is correct. Now, if I bump the font to 96 pixels the space between lines is 12px. Thoughts anyone?
            • 3. Re: TextField padding
              adamjbrown Level 1
              I think I found the answer to the leading issue. It looks like it is using exact pixel values after all between lines.