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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vertical Text Orientation

Status
Not open for further replies.

JackMH

Programmer
Nov 9, 2001
18
US
I have a requirement to draw text in a vertical fashion on a Canvas (or JComponent). I thought that it would be easy and a
common requirement but apparently not so.

The Font class includes a deriveFont() method that has as a parameter of an AffineTransform instance. I used a 90degree rotate transform as follows:

Font vFont = hFont.deriveFont(AffineTransform.getRotateInstance(Math.PI / 2))

The effect is to rotate the WRITING DIRECTION not the CHARACTER ORIENTATION. I need both so this isn't very useful.

I have also tried creating from a string a GlyphVector and rotating each glyph. The result is similar to deriving fonts.

I have one solution and that is to convert each character to an image and rotate the image and paint one character at a time, but in the application that I have that is not a very practical solution. I need to end up with an image of an entire character string with each character rotated 90deg counter clockwise and the entire image rotated 90deg clockwise.

Any suggestions would be greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top