hi again
as i remember we had a settextjustify function in Turbo c but i dont know its equal
function in allegro .
corresponding function.
thanks alot.
SEE ALSO
font(3), textout_ex(3), textprintf_centre_ex(3),
textprintf_right_ex(3), textprintf_justify_ex(3), text_height(3),
text_length(3), uszprintf(3)
Emphasis mine.
Is there a reason you can't reply in the first thread?
hi evert
i tried what you said but didnt got desired goal.
main problem was that i coudlnt justify text as horizontal or vertical.
please help me to solve that .
i am asking miran too because it seems so professional in this field.
help me miran,evert,or my friends.
bye.
Is there a reason you can't reply in the first thread?
Saw this one first?
main problem was that i coudlnt justify text as horizontal or vertical.
What do you mean by justify horizontal or vertical?
Saw this one first?
Sorry, I was talking to the OP. He started a thread with an almost identical question before, I gave him an answer (although not as detailed as yours), after which he proceeded to start this one.
Ah, ok.
hi evert
i tried what you said but didnt got desired goal.
main problem was that i coudlnt justify text as horizontal or vertical.
please help me to solve that .
i am asking miran too because it seems so professional in this field.
help me miran,evert,or my friends.
bye.
If you mean rendering text top-down instead of left-right: You can't, really. This would involve rotating characters, something which is not implemented in allegro's text api.
To achieve vertical text output, here's what you can do. First, you use text_length() and text_height() to find the text's size in pixels. Create a memory bitmap of that same size, and fill it with the transparent color (magic pink / #0; bitmap_mask_color() will give you the correct value). Render the text normally onto the memory bitmap. Then use pivot_sprite() to draw the text wherever you want it. Remember that draw_sprite() expects angles in fixed-point, 256-degrees format, so to rotate the text by 90 degrees, you need to use itofix(64) as the angle. Finally, don't forget to clean up the temporary bitmap.
So:
void textout_vertical(BITMAP* bmp, const FONT* font, const char* str, int x, int y, int fg, int bg) { int w = text_length(font, str); int h = text_height(font); BITMAP* buf = create_bitmap(w, h); clear_to_color(buf, bitmap_mask_color(buf)); textout_ex(buf, font, str, 0, 0, fg, bg); pivot_sprite(bmp, buf, x, y, 0, h, itofix(64)); destroy_bitmap(buf); }
This should do the trick.