Search code examples
c++visual-studiovisual-studio-2012allegroallegro5

Unable to load font in Allegro


I'm playing around with Allegro 5 in C++ and Visual Studio 2012, but for some reason I can't get a font to load using the sample code from the Allegro wiki:

    ALLEGRO_FONT *font = al_load_ttf_font("pirulen.ttf",72,0 );

   if (!font){
      fprintf(stderr, "Could not load 'pirulen.ttf'.\n");
      return false;
   }

   al_clear_to_color(al_map_rgb(50,10,70));
   al_draw_text(font, al_map_rgb(255,255,255), 640/2, (480/4),ALLEGRO_ALIGN_CENTRE, "It worked!");

I've tried placing the font file in about every feasible directory in my Visual Studio project, as well as in the directory the .exe is in (as is suggested by several other threads). I also tried just dropping a copy of it on the C: drive and calling it with the fully qualified path: I tried C:\\pirulen.ttf and C:/pirulen.ttf neither of which worked. I've also tried adding it to the "Resource Files" folder in my project, but that did not work either.

Any advice on what could be going on?

Thanks.


Solution

  • Everything that needs to be said is here: