2 Replies Latest reply on Feb 25, 2010 7:24 PM by Steve Wright

    String length in Pixels?



      String length in Pixels?


      Is there any way to determine how long a text string is in pixels? For example, "short string" is 100 pixels, and "this is a long string" is 200 pixels?



        • 1. Re: String length in Pixels?
             I dont think you can. It would depend on the font and font size. Using a monospaced font with a fixed size perhaps can help you.
          • 2. Re: String length in Pixels?
            Steve Wright

            Theres a custom function on Brian Dunning's Website (if I remember correctly) which may help, although it could never really be accurate.


            Different characters (unless fixed width are used) have different pixel values.

            The custom function relies on a fixed font & size and then basically substitutes each letter for a pixel value. 


            Something along these lines (but I made the values up)


            A = 5

            B = 5


            I = 3

            W = 7 


            Can you not achieve the desired effect by limiting characters