Draw a TTF font on it's side?
I'm not seeing a function for this, but is there a easy way to draw text sideways, (rotated 90 degrees) is there a trick to doing it?
Something like this should work:
Do you mean draw the text vertically or actually turn it on its side?
Turn it on it's side. I would use the example above, but what on earth is t pointing at?
Oh I get you. t is an ALLEGRO_TRANSFORM*.
T doesn't point at anything, it's a transform, not a vector. He sets up the transform to rotate around the origin by 90 degrees clockwise and then uses the transform before drawing the text. You'll probably want to center your text before you rotate it though.
al_translate_transform(&t , -xpos , -ypos);
al_rotate_transform(&t , M_PI/2.0f);
al_translate_transform(&t , xpos , ypos);
al_draw_text(font , al_map_rgb(255,255,255) , xpos , ypos , ALLEGRO_ALIGN_CENTER , my_string);
I'm not at my main system right now, but does that transform the whole drawing surface. As in, if I was to paste bitmaps or draw primitives, they will also be transformed as well until I reset the use_transform();
The transforms that you 'use' affect the current bitmap target only. But if that is the backbuffer, then it affects all drawing.
I guess the question is, how do you set it back to normal after the text print. There doesn't seem to be a "clear" command and I have other non-rotated things being drawn to my target bitmap. (I admit my matrix math is a little weak so I don't know what an "identity" is)
Thread #617312. Printed from Allegro.cc
int GraphicsContext::drawRotatedText( const std::string& text,agui::Font* font,const agui::Color& color, int x, int y, float deg, int flags )
int fx = font->getTextWidth(text) / 2;
int fy = font->getLineHeight() / 2;
return fx * 2;