• Post Reply Bookmark Topic Watch Topic
  • New Topic

Font Size In User Coordinate Space  RSS feed

 
Landon Blake
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having some trouble determining how font size (which is specified in points) relates to the user space coordinate system used to draw Java shapes using the Graphics2D object. If I create a font that is 10 points high, and a square that is 10 units by 10 units and draw them on the same JPanel using a Graphics2D object, how will their sizes compare?

Does this question make sense? I know that there are approximately 72 points to an inch. Does this mean that a Glyph that was drawn 10 points tall would be 720 pixels tall?

Thanks,

Landon
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I don't have a direct answer to this question (and yes, it does make sense), and it's anyway easy enough to write a little program that puts a 10pt font next to a 10px square for comparison, you might want to check out the FontMetrics class. For a given string in a given font it can tell you how big in pixels the string is going to be -horizontally and vertically- on the screen.
 
Landon Blake
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

Thanks for the response. I'm glad that my question made sense. I think I'm going to end up using a GlyphVector. I'll get its bounds as a Rectangle2D and then extract the height in user units from that.

Thanks,

Landon
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!