Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Hi,

Is it possible to measure the pixelsize of an innerHTML text?

I want to show the height and width of text.
I tried it with "offsetWidth" and "offsetHeigth", but then you get the dimensions of the fontframe :
http://www.stickers.be/Forum-Images/span.jpg[^]


Take the text in your drawing prog and measure it.
Then break the text apart (convert to outlines). That's the height I need.
See example :
http://www.frogstyling.be/textoutlines.jpg[^]
Posted
Updated 18-Feb-12 4:36am
v3
Comments
Dalek Dave 4-Jan-11 6:51am    
Edited for Readability.

Have a look at the link below. It just might be a style that prevents you from measuring correctly. You could try it and have a look.
http://chamnapchhorn.blogspot.com/2008/06/determine-real-offsetwidthoffsetheight.html[^]

Also, maybe this bug report can help (with the work around given):
http://www.quirksmode.org/bugreports/archives/2005/08/Wrong_offsetWidth_in_Mozilla_and_Opera.html[^]

Good luck!
 
Share this answer
 
v2
If you check the DOM, you can probably find the font that is in effect for the particular element, and then determine the height that way.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900