Drawing strings in Java
I have some questions regarding drawing strings in Java, more exactly regarding the determination and measurement of the size of strings.
The API says that the unit of the parameter size in the constructor Font(String name, int style, int size) is point. But how is the relationship between points and pixels in Java? I found serveral resources on the web which all say different things.
Some states that in Java one point is equal to one pixel. Others say that Java knows points as well as pixels and that one point is not necessarily one pixel. But what's right? I searched the API and others official Sun documents (eg. the tutorials), but I can't find any official resource from Sun in which the relation between pixels and points is explained - neither statements that one point is equal to one pixel nor statements against that. Does any one have a link where Sun explains that?
Second question: What exactly is the size of a font which I give the constructor Font(String name, int style, int size)? Is it the distance from the font's baseline to the top of most alphanumeric characters? Or the distance from the bottom of most alphanumeric characters with descenders to the top of most alphanumeric characters?
Third question: Do the methods of the class FontMetrics such as getLeading(), getAscent() or getDescent() return pixel values or point values? If there is a difference at all...
Take a look at this URL: Javadoc error confuses Pixels with Points
In general, pixel vs. point size is platform/device/implementation dependent.
Chapter 5 of "Java 2D API Graphics" has a good introduction to the FontMetrics, TextLayout, LineMetrics, and FontRenderContext classes.
Finally, when using getLeading() etc. for screen drawing, I have always found the return values to have pixel units.
Has this question been cross-posted in the sun forums? OP, did you read the users agreement that you signed on joining this forum? Have you checked the Sun forum for their policy on cross-posts?
Fubarable, were you referring to my reply to the original posting or the original posting? rtc1
Sorry for being unclear. I was referring to the OP as it looked familiar. I have found the cross-posted here: Java 2D - Drawing strings in Java
Originally Posted by rtc1