Jump to content
  • Advertisement
Sign in to follow this  
FlaiseSaffron

[java] Text of an arbitrary size.

This topic is 4348 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!