Results 1 to 5 of 5
Thread: Drawing strings in Java
- 05-11-2010, 01:25 PM #1
Member
- Join Date
- May 2010
- Posts
- 1
- Rep Power
- 0
Drawing strings in Java
Hello,
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...
Best regards
- 05-11-2010, 09:56 PM #2
Member
- Join Date
- May 2010
- Location
- northern california
- Posts
- 7
- Rep Power
- 0
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?
- 05-11-2010, 11:05 PM #4
Member
- Join Date
- May 2010
- Location
- northern california
- Posts
- 7
- Rep Power
- 0
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
Similar Threads
-
drawing shapes in java help
By alphajoseph in forum Java 2DReplies: 2Last Post: 09-29-2009, 06:35 PM -
The java Strings
By greenteachacha in forum Jobs DiscussionReplies: 8Last Post: 04-16-2009, 05:08 AM -
Sorting strings in java?
By alexander.s in forum New To JavaReplies: 10Last Post: 09-01-2008, 04:14 AM -
Java Drawing PUZZLE
By Cyorxamp in forum AWT / SwingReplies: 3Last Post: 06-09-2008, 10:35 AM -
Help with drawing strings!
By JavaInLove in forum AWT / SwingReplies: 1Last Post: 02-05-2008, 03:39 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks