Sign in to follow this  
FlaiseSaffron

[java] Text of an arbitrary size.

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
Not quite; I want to know how many point sizes a certain number of pixels takes up. If I have a cell 10x14 pixels, for example, what size font do I paste in there to fill it?

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

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