Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: module to measure string in pixels

by dws (Chancellor)
on May 25, 2005 at 19:35 UTC ( #460430=note: print w/replies, xml ) Need Help??


in reply to module to measure string in pixels

I thought if there is any way to measure the expected length in pixels with Perl. You guys know of any?

That information isn't available on the server side, since the server doesn't have knowledge of what fonts the user has installed on the client side, and browsers do font substitution if the requested font isn't available.

What you could do is use CSS to specify a fixed-width font for the option text. Something like (untested):

<style type="text/css"> #form_s option { font: "courier new", monospace; } </style>
then you can line up your text by counting characters.

Replies are listed 'Best First'.
Re^2: module to measure string in pixels
by ww (Archbishop) on May 25, 2005 at 19:50 UTC
    dws ++! Very good.
    catch: user can/may have overiden your style sheet.
    bottom line: should work for most

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://460430]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2020-10-29 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (269 votes). Check out past polls.

    Notices?