Draw a TTF font on it's side?
nshade

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?

Elias

Something like this should work:

Edgar Reynaldo

Do you mean draw the text vertically or actually turn it on its side?

nshade

Turn it on it's side. I would use the example above, but what on earth is t pointing at?

Edgar Reynaldo

EDIT
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.

ALLEGRO_TRANSFORM t;
al_identity_transform(&t);
al_translate_transform(&t , -xpos , -ypos);
al_rotate_transform(&t , M_PI/2.0f);
al_translate_transform(&t , xpos , ypos);
al_use_transform(&t);
al_draw_text(font , al_map_rgb(255,255,255) , xpos , ypos , ALLEGRO_ALIGN_CENTER , my_string);

nshade

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();

Edgar Reynaldo

The transforms that you 'use' affect the current bitmap target only. But if that is the backbuffer, then it affects all drawing.

nshade

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)

Edgar Reynaldo

I think its in the manual.

http://liballeg.org/a5docs/trunk/transformations.html#al_use_transform

Quote:

Call this function with an identity transformation to return to the default behaviour.

However, to reset the projection transform is a little different. But you didn't alter that, so no worries.

jmasterx
  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;
    m_transform.identity();
    m_transform.translate(-fx,-fy);
    m_transform.rotate(deg);
    m_transform.translate(x,y);
    useTransform(m_transform);
    drawText(text,font,color,0,0,flags);
    resetTransform();
    return fx * 2;
  }

https://github.com/jmasterx/StemwaterSpades/blob/master/Spades%20Game/Game/Engine/GraphicsContext.cpp

Thread #617312. Printed from Allegro.cc