Any idea how to calculate pixel width for text in non-fixed width fonts? Can you get point sizes for each character?
Main Topics
Browse All TopicsHi,
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
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
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
Business Accounts
Answer for Membership
by: fl0ydPosted on 2003-07-28 at 07:10:21ID: 9019896
A point is 1/72 inch. With that formula you can convert between inches and points. What's missing is the number of pixels in an inch. You can retrieve that by calling GetDeviceCaps( hdc, LOGPIXELSY ) which returns the number of pixels in 1 logical inch of your screen. A logical inch isn't exactly 1 inch if you measure it, but that isn't a problem as the point size only relates to logical inches on your screen.
Hope that helped,
.f