Link to home
Start Free TrialLog in
Avatar of zabbas
zabbas

asked on

Font Size - Point Vs Pixel

Hi,

Is there any way to compute pixels out of given font size. I mean how many pixels are there in one point. I know there should be some formula to calculate this as it depends upon current  resolution and monitor size etc. At the moment I am working on PC with windows having resolution of 1600*1200 pixels in 24 bit mode. the monitor size is 19 inch.

regards

zaheer
ASKER CERTIFIED SOLUTION
Avatar of fl0yd
fl0yd

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
Avatar of ishmell
ishmell

Any idea how to calculate pixel width for text in non-fixed width fonts? Can you get point sizes for each character?
That's a tough one, and I can only give you a way to approximate this value: GetTextExtentPoint32.

You'll run into a 'problem' that's known as kerning, i.e. the process that calculates the runlength of a character based on the combination of *both* characters involved. As an example consider how the placement of 'e' may be different in these 2 cases: Ne and Te. In the latter case, the lower-case 'e' may be placed closer to the previous character than it would be in the first case.

So the height of a string is the only parameter you can calculate precisely.

.f
hmm.. thx