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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SavoyeSmith
Forum Newbie
Posts: 1
Joined: Sun Jan 20, 2008 9:30 pm

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

Post 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
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

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

Post 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
Post Reply