Easiest way to get vertical text


Hi - I’m trying to render some vertically aligned characters like this:


And without the character rotation of an affine transform. Is there an easy way to do this?


I would say the most flexible method would be to make your own, perhaps based on Label. E.g., start with something like this:

[code]class VertLabel : public Label
VertLabel(String text)
: Label(text, text)

void paint(Graphics& g)
	if(isBeingEdited()) return;
	String text = getText();
	const Font& font = getFont();
	const float height = font.getHeight();
	float y = 0;
	for(int i = 0; i < text.length(); ++i)
		g.drawText(text.substring(i, i+1), 0, y, getWidth(), height, Justification::left, false);
		y += height;


Then you get all the behaviour of Label. Making the editibility work elegantly might be tricky but you could override setEditable() to prevent that. Positioning the text in the above example could be more like label (in that perhaps it should be vertically centred or better still based on the Justification of the Label). You could add methods to control the vertical line spacing here too.