I'm using Allegro 5.0.8 al_draw_text to draw text on a bitmap (backbuffer). However, I've noticed that the first character of the string is always skipped. Moreover, whenever the same character appears in the string, it is skipped again.

For example:

font = al_load_font(path.c_str(), 100, 0);
std::string str = "01230450678";    
al_draw_text(font, color, 100, 100, 0, str.c_str());

Will print "12345678", skipping all occurrences of '0'

I've tried several TTF fonts, which work with other graphic software. I've noticed that this sometimes may or may not happen with the same font, depending only on the text size on screen (font size)

Edit: I've formatted the code and added the arguments I've used to load the font.

Edit2: Here is a complete code to replicate this using Allegro 5.0.8.

This code should print "0123045670890", but, instead, it renders the following image: (Note: I didn't cleared the memory because the error appears before program finishes) enter image description here


#include <string>

#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_opengl.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_primitives.h>

using namespace std;


int main(int argc, char * argv[])

    ALLEGRO_DISPLAY * mainWindow= al_create_display(1200, 1000);

    ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
    string file = al_path_cstr(path, '/');
    file = file + "arial.ttf";
    ALLEGRO_FONT * font = al_load_font(file.c_str(), 50, 0);

    al_draw_filled_rectangle(0, 0, 1200, 1000, al_map_rgb(0,0,0));

    al_draw_text(font, al_map_rgb(255,0,0), 50, 50, 0, "0123045670890");

    al_save_bitmap("d:\\teste.bmp", al_get_backbuffer(mainWindow));



    return 0;
  • 1
    \$\begingroup\$ Have you tried you using the same command with a C char array ? \$\endgroup\$
    – Taigi
    Commented Jan 7, 2013 at 16:00
  • \$\begingroup\$ Yes. It's the same. \$\endgroup\$
    – Alex
    Commented Jan 7, 2013 at 16:45
  • 2
    \$\begingroup\$ Without any other information to go on, that sound like a bug. Not sure what would cause it. You should probably post a small-but-complete example that can be used to reproduce the issue @ allegro.cc/forums/board/allegrodev \$\endgroup\$
    – Matthew
    Commented Jan 8, 2013 at 15:40
  • 1
    \$\begingroup\$ Does it work if you use memory bitmap for the font? al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP) before loading the font. \$\endgroup\$
    – Matthew
    Commented Jan 8, 2013 at 18:01
  • \$\begingroup\$ It worked with ALLEGRO_MEMORY_BITMAP. But I haven't found anything related to that in the documentation. Does this means I should always load fonts on regular memory instead of video memory, and may this decrease the performance? Please, put this in an answer so I can close the question, as it fixed the problem. \$\endgroup\$
    – Alex
    Commented Jan 9, 2013 at 0:44

1 Answer 1


It sounds like a bug with caching glyphs. These sorts of glitches generally are only applicable to video memory, so if you switch to a memory bitmap font by calling this before loading the font you can work around the issue:


You'll need to clear the flags after you load the font, or else all subsequent bitmaps will be software based as well.

However, this is not a good long term solution, as using memory bitmaps may significantly degrade performance.

While the above will probably get you up and running, you should at some point:

  • Upgrade your OpenGL drivers if applicable
  • Try out Allegro 5.1.X, as it may have fixes that have not yet made it to 5.0.X.

If neither of those solve the issue, then you should file a bug report, including the sample source code and details of your OS and video card.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .