Page 1 of 1

How to get num pixels for 1 EM when user increases font size

Posted: Sun Jun 22, 2008 12:44 am
by SavoyeSmith
Hi,
I know the default number of pixels for '1 em' is 16.
Now suppose a user increases the font size using the browser menu
View | Font size

I would like to know how many pixels the an 'em' is now....it could be 24, 36, etc depending on how big the user made the font. How can i get that in php code?

Any ideas. Maybe Image functions can do it?

Thanks
Savoye

Re: How to get num pixels for 1 EM when user increases font size

Posted: Sun Jun 22, 2008 1:53 am
by Eran
Two things:
1. em is a relative unit and is dependent on the inherited font-size for the element or the declared font-size for the document. 1em equals 100%, 1.2em equals 120% etc. It is not necessarily 16px
2. You have no control on the client side (ie browser) using PHP. To calculate font-size you would have to use Javascript