Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5] Can't load ttf font

This thread is locked; no one can reply to it. rss feed Print
[A5] Can't load ttf font
Dizzy Egg
Member #10,824
March 2009
avatar

EDIT: IGNORE ME I'M A RTFM MAN! ;D, sorted it now, ttf you SILLY EGG!

Hello

I've just setup A5 and Code::Blocks and all was going well until I tried to load a font. My program always returns (-1) when I check if the font exists!

I'm using Windows 7 and have tried the full path too (C:/Fonts/Arial.ttf). Below is an example, any suggestions would be helpful as I'm a little stuck, probably something painfully obvious that I can't see!

#SelectExpand
1#include "allegro.h" 2#include "allegro_font.h" 3 4using namespace std; 5 6int main() 7{ 8 al_init(); 9 al_install_keyboard(); 10 al_init_font_addon(); 11 12 int liFlags = ALLEGRO_FULLSCREEN; 13 14 al_set_new_display_flags(liFlags); 15 16 ALLEGRO_DISPLAY *lcAllegroDisplay = al_create_display(1024, 768); 17 18 ALLEGRO_KEYBOARD_STATE lcKeyboardState; 19 20 ALLEGRO_FONT *lcAllegroFont; 21 22 lcAllegroFont = al_load_font("arial.ttf", 20, 0); 23 24 if(!lcAllegroFont) 25 { 26 exit(-1); 27 } 28 29 while(!al_key_down(&lcKeyboardState, ALLEGRO_KEY_ESCAPE)) 30 { 31 al_draw_text(lcAllegroFont, al_map_rgb(255, 255, 0), 20.0, 20.0, 0, "HELLO!"); 32 33 al_get_keyboard_state(&lcKeyboardState); 34 al_flip_display(); 35 } 36 37 al_shutdown_font_addon(); 38 al_uninstall_keyboard(); 39 al_uninstall_system(); 40 41 return 0; 42}

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

William Labbett
Member #4,486
March 2004
avatar

al_init_ttf_addon();

EDIT : nm

Go to: