Draw rotated text



What is the correct way to draw roated text in Juce? And is it possible, that the function Graphics::addTransform has changed some time ago and is now resetting the bounds?

I am doing the following:

void MyCompoment::paint (Graphics& g)
   g.drawSingleLineText("Text One", 70, 30, Justification::left);
   //"Text One" is drawn OK
   float dbg_bounds = g.getClipBounds().getRight();
   //dbg_bounds is 750, just as I set it 
   g.addTransform(AffineTransform::identity.rotated(-float_Pi / 2.0f));
   dbg_bounds = g.getClipBounds().getRight();
   //strangely, dbg_bounds is 1 now. It seems, addTransform resetted it
   g.drawSingleLineText("Text Two",30,190,Justification::left);
   //because the bounds has size 1, the "Text Two" is not shown 

So basically I am using addTransform in order to draw rotated text. The problem is: After I call addTransform, the bounds of my Graphics object are reset to 1. As a result, no text is drawn, because everything is clipped.

I guess, I am missing something simple here? :-)


The physical clip bounds of a Graphics don't change, but when you apply a transform, then obviously those bounds will appear to be in a different place, because the whole coordinate space has now changed.


Thanks! Did not think about that. Works now. 

One question: has that behaviour changed some time ago? I seem to remember it worked differently before.


Don't think it has changed, unless it was broken before. I think it's all working as intended now.