0

I create png Images from short pieces of text to be used as floating labels, prompts, speechbubbles, etc in a 3D graphics application. Occasionally some of my text needs to be rotated. Unfortunately the 3D application does not provide rotation for this kind of image. I have it fully working for both rotated and non-rotated text, and even the rotated images are drawn correctly if the text is short, but if I use a longer string, it gets cut off because the BufferedImage is not sized to handle it. Do I need to use trigonometry to size it? I know I could always use a huge rectangle in the BufferedImage, but that seems inelegant.

Note that I only ever create single lines of text. If I need multiple lines occasionally, I use multiple images and stack them, it just works better for me that way.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
casgage
  • 529
  • 1
  • 7
  • 18
  • *"Do I need to use trigonometry to size it?"* more or less yes - [for example](https://stackoverflow.com/questions/37758061/rotate-a-buffered-image-in-java/37758533#37758533) – MadProgrammer Nov 17 '17 at 21:01
  • How do you rotate the text in the first place? If you use `AffineTransformOp` to rotate, it already has a [method to give you the bounds](https://docs.oracle.com/javase/7/docs/api/java/awt/image/AffineTransformOp.html#getBounds2D(java.awt.image.BufferedImage)) required for the result... – Harald K Nov 18 '17 at 13:05

0 Answers0