Some symbols don't draw with TTF font

Trying to draw text with a TTF font, but I keep getting missing symbols.

In the test case for me it's the first symbol used from the TTF font that repeatedly refuses to draw.

Tried latest SVNs of both 5.0 and 5.1 branches with the same results.

Am I doing something wrong here?

Linux x86-64.

1#include <stdio.h> 2#include <allegro5/allegro.h> 3#include <allegro5/allegro_image.h> 4#include <allegro5/allegro_font.h> 5#include <allegro5/allegro_ttf.h> 6 7 8int main(int argc, char **argv) 9{ 10 ALLEGRO_DISPLAY *display = NULL; 11 ALLEGRO_EVENT_QUEUE *event_queue = NULL; 12 ALLEGRO_FONT *bmp_font, *ttf_font; 13 14 al_init(); 15 16 al_install_keyboard(); 17 18 al_set_new_display_option(ALLEGRO_SAMPLES, 4, ALLEGRO_SUGGEST); 19 display = al_create_display(640, 480); 20 21 al_init_image_addon(); 22 23 al_init_font_addon(); 24 al_init_ttf_addon(); 25 bmp_font = al_load_bitmap_font("a4_font.tga"); 26 ttf_font = al_load_ttf_font("WHITRABT.TTF", 16, 0); 27 28 event_queue = al_create_event_queue(); 29 30 al_register_event_source(event_queue, al_get_display_event_source(display)); 31 al_register_event_source(event_queue, al_get_keyboard_event_source()); 32 33 while (1) { 34 if(al_is_event_queue_empty(event_queue)) { 35 al_set_target_bitmap(al_get_backbuffer(display)); 36 al_clear_to_color(al_map_rgb(0,0,0)); 37 al_draw_text(bmp_font, al_map_rgb(255,255,0), 16, 16, 0, "HelleH"); 38 al_draw_text(ttf_font, al_map_rgb(255,255,0), 16, 32, 0, "HelleH"); 39 al_draw_text(ttf_font, al_map_rgb(255,255,0), 16, 48, 0, "HelleH"); 40 //al_draw_text(bmp_font, al_map_rgb(255,255,0), 16, 64, 0, "101.101"); 41 //al_draw_text(ttf_font, al_map_rgb(255,255,0), 16, 80, 0, "101.101"); 42 //al_draw_text(ttf_font, al_map_rgb(255,255,0), 16, 96, 0, "101.101"); 43 al_flip_display(); 44 } 45 46 ALLEGRO_EVENT ev; 47 al_wait_for_event(event_queue, &ev); 48 if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE 49 || ev.type == ALLEGRO_EVENT_KEY_UP && ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { 50 break; 51 } 52 } 53 54 al_destroy_font(ttf_font); 55 al_destroy_font(bmp_font); 56 al_destroy_display(display); 57 al_destroy_event_queue(event_queue); 58 59 return 0; 60}


I tried your code on my machine using "consolas.ttf" and works fine... If you send me "WHITRABT.TTF" and "a4_font.tga" I could try it... Otherwise try with another font to see what happens.


Te most likely explanation is that those characters don't exist in that particular font, which means you should use another font.

If you send me "WHITRABT.TTF" and "a4_font.tga"

a4_font.tga comes with Allegro.

Evert said:

a4_font.tga comes with Allegro.

Hohohohoh... It's true... ;D

I can't find the WHITRABT.ttf font on internet!


I have tried different fonts with the same effect.

In the test code if I prepend the string with another symbol then that symbol won't draw at all, but the previous first symbol ('H' in this case) will then draw fine.


hm.. it sounds like an encoding problem? what IDE are you using?

try to set your encoding format as UTF-8.


I wonder if it has to do with the FBO drawing change (the font cache doesn't use FBOs, but an active FBO might prevent locking). Try putting a file called allegro5.cfg next to your executable with the following contents:

force_opengl_version = 1.2

Is there any change?

Also, can you run with the debug version and attach allegro.log? Or well, the interesting info is mainly OpenGL driver and version (glxinfo | grep "version\|renderer").


The cfg file did the trick. Looks to be working perfectly now.

Log is attached.

glxinfo | grep "version\|renderer":

server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL renderer string: ATI Radeon HD 5700 Series
OpenGL version string: 4.0.10237 Compatibility Profile Context
OpenGL shading language version string: 4.00


Thomas Fjellstrom

That kinda sucks though.. Disabling FBOs is pretty harsh. What happens if you skip that? or bump the version of GL up to 2.1, or both?


Gl 2.1 makes no difference. Faulty without FBO disabled, right with it disabled.


Thanks for all the info! I wonder if this was introduced with the patches to delete unused FBOs. Do you have an allegro.log from a run where FBOs are enabled?

Anyway, I don't have an ATI card to reproduce it here right now but I added it to the bug tracker.


An allegro.log from a run where FBOs are enabled is attached.

Thread #606984. Printed from