Link to home
Start Free TrialLog in
Avatar of aiuWebServices
aiuWebServices

asked on

CSS Font Width Calculation

Hi All,

The issue that I've come across is that I have a label that displays the month of the year and I need to calculate the width of the month so that all months are approximately 130 pixels in length. What I was hoping to do is to change the letter-spacing style on the fly but I'm having a real hard time getting the width of the text. So for example if I am using Arial and a font size of 16 I need to find the calculation to make sure that the month of JULY is approximately the same width as DECEMBER.  

The System.Drawing.Graphics class for windows development has a method called MessageString but I cannot seem to find a similar method for ASP .NET. Also I tried to cheat and just get the Label.Width.Value and do a calculation with that but it returns a value of 0 in the Page_Load method. Also if there is a slick way to do this just using CSS I'd love to know it.

Any help would be greatly appreciated

Thanks
Avatar of russellC
russellC
Flag of United States of America image

can I ask why they need to be the same width?  It may look weird if you do not change the hight also, this could possibly stretch your letters to look funny on months like july.
Avatar of Bob Learned
I believe that what you are talking about concerns using kerning techniques.

Understanding Typography Controls with CSS
http://www.creativepro.com/article/understanding-typography-controls-with-css

"Kerning and Leading
Probably the most interesting of the new properties are the kerning and leading settings. If you don't already know, kerning is the spacing between letters and leading is the spacing between lines. Leading controls are an especially nice feature of CSS, as there's no such thing as one-size-fits-all leading. Some fonts need more, while others need less to make them more readable."
ASKER CERTIFIED SOLUTION
Avatar of kumar754
kumar754
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial