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.
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.
drawMultiLineText(). Just set a width about half of font size, works like a charm, except I canât seem to get it to make a new line if there is a âspaceâ character!
Thanks for your tips.
Have to admit, I donât really remember the exact use case from then. Already five years ago
But in case I get into the same situation again, I will test your hint.
Youâll most likely have to convert your string of text into a GlyphArrangement and then from there, convert it to a Path object, which you can then apply a transform to.