'Allegro 5 font display problems

Using Allegro 5 (5.0.10-1), for some reason text is displayed in a really strange way - it's cut off at certain parts and letters are sometimes not on the same line. See the image below.

Text displayed strangely

I'm loading the font like this:

this->font = al_load_font ("fonts/OpenSans-Regular.ttf", 12, 0)

And drawing the text like this:

al_draw_text (this->font, al_map_rgb (0xE0, 0xE0, 0xE0),
    20.5, 4.5, 0, this->lbl.c_str ());

where lbl holds the text I want to output.

Any ideas what might be causing this?



Solution 1:[1]

It looks like this because you try to draw it at non-integer coordinates (20.5,4.5). Generally, you should only draw text on integer coordinates to avoid this sort of problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Promitheas Nikou