Get pixels of the width of a character

awais

New member
Joined
Aug 20, 2003
Messages
4
how can i get the pixels a character in a <div> tag with font verdana and font size 10 has? is there any way out for that?
 
If the font is being displayed in a browser you probably have no way to tell exactly how the browser is choosing to display the text.
Every user could have different preferences for size or perhaps they dont even have the font installed.
 
but what if i have constrained the web application in 800x600 and want to find pixel size of character with verdana font which is normally is installed in windows environment. is there any remedy in this case?
 
Problem is the user (under IE) could go to the view menu, text size and change it. Most other browsers will also allow this.

Just out of interest, what are you trying to acheive - there may be an easier solution.
 
well.. you are quite right.. in fact i am trying to dynamically create table headers. now the width of each table header or say column is to be decided at run time depending upon the number of characters each header has. therefore i have to device some way to calculate the pixels . though i could hard code this thing but things are extra versatile at my end.
 
Cant think of any easy way of managing that. Generally browser based apps suffer compared to windows based apps in the ease / capability of really controling the look and feel.
Maybe possible with either client side scripting or an embedded ActiveX control that could report information back to the server....
 
i forgot to mention one thing that the table column widths are going to be set at server side not on client side and will be fixed for a certain type of dynamic data binding to table. and as i mentioned earlier, if i am just able to find the width in pixels equivalent to a character provided with verdana font and font size of 10, then rest of things can be managed. first the problem is to locate the exact mapping method.
 
Back
Top