Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Font Size Calculate

Status
Not open for further replies.

Toyman

Programmer
Jun 19, 2001
68
0
0
GB
Hi

This is want I want to do...

I've got 3 Lines (3 x Strings)..
Lets say
Line1 = "Hello World"
Line2 = "Goodbye World"
Line3 = "Here I am again World"

I want to calculate the rectangular erea around the 3 lines.
So
x = 0
y = 0
width = (size of each character (in font size))
height = (size of largest character (in font size) * 3)

Plus all the spaces between characters, line feeds .. bla bla bla..

The bottom lines is, that I want to draw 'n rectagle around the text, and the text could be in any font/font size/bold or plain/italic bla bla bla.

Hope this make sense...

Thanks
Toyman
 
see:

FontMetrics java.awt.Graphics.getFontMetrics(Font)
and
java.awt.FontMetrics.getStringBounds(String, Graphics)

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top