Sign in to follow this  

[java] Text of an arbitrary size.

This topic is 4135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to create a Font object that will make a Graphics object display text at a certain size so everything in the window lines up. Is there a conversion formula for a font point size making characters of a certain number of pixels?

Share this post


Link to post
Share on other sites
Found this:

http://www.experts-exchange.com/Programming/Game_Development/Game_Graphics/Q_20686438.html

Quote:

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.


I think the default setting is 72 dpi. So a 10 point font will be 10 pixels by 10 pixels. However, a proportional font will be a max of 10 pixels wide.

Share this post


Link to post
Share on other sites

This topic is 4135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this