Results 1 to 1 of 1
Jun 3, 2002, 09:29 #1
- Join Date
- Aug 2001
- Livonia, MI, USA
- 0 Post(s)
- 0 Thread(s)
Cross-Platform Font Sizes using PHP (Long)
A while back, I read the following article at WebMonkey entitled "Sizing Up the Browsers".
I was most impressed with the information about text sizing on page 3 of the article. My thought was, if we know exactly what font specifications we need to achieve the same size in all browsers, and browser detection is relativly easy these days, why are we still solving this problem by hand? It seems that all the pieces exist to solve this problem, and they just need to be pulled together.
Well, as I'm sure all of you know, it's a lot easier to provide a problem than it is a solution. I took a stab at a solution and I would like the input of the community regarding it.
Ok, code first, explanation later:
The code is rather simple. It parses CSS looking for font-size attributes. When it finds one, it looks at the value for the font size and the browser being used to view the page, and translates it into an equivalent value for that browser.
Currently, all font-sizes in the CSS must be set as integers that correspond with the sizes of font size HTML tags in IE6 for Windows. The idea is, if the fonts are the correct size in that browser, this script will make sure they are the same size in any. I believe in the future it would be possible to make the script handle font-sizes that are specified in other forms than integers.
The script also allows for a designer to choose what format the sizes should be in the style sheet. The script can translate sizes into size keywords (small, medium, large, etc.), em's, pixels, and points.
There is also one disadvantage. Any page that uses this script would have to be a PHP script. This could slow down load times a bit because the page would have to be processed by the PHP parser, but I think it would be completely unnoticable.
Do you think this can be developed and polished into a viable solution for automatically making fonts appear at the same size in any browser?
Any suggestions for improving this script would also be greatly appreciated.