akrinke / Font-Stash

A dynamic font glyph cache for OpenGL.
114 stars 18 forks source link

Right justification #1

Closed textchimp closed 11 years ago

textchimp commented 11 years ago

Not exactly an issue, more a question: is there any way to specify right justification for text when using sth_draw_text(), i.e. so that the x argument would be interpreted as where the text should end, not begin?

Thanks!

akrinke commented 11 years ago

No, there is currently no way to chang the text alignment.

You can use sth_dim_text to get the text dimensions and adjust the x coordinate of the text rendering appropriately.

float minx, miny, maxx, maxy, width;
sth_dim_text(stash, droidRegular, 24.0f, "Your text here", &minx, &miny, &maxx, &maxy);
width = maxx - minx;
...