1 module allegro5.allegro_font; 2 3 version(ALLEGRO_NO_PRAGMA_LIB) {} 4 else 5 { 6 pragma(lib, "allegro_font"); 7 } 8 9 import allegro5.allegro; 10 11 extern (C) 12 { 13 struct ALLEGRO_FONT 14 { 15 void* data; 16 int height; 17 ALLEGRO_FONT_VTABLE* vtable; 18 } 19 20 struct ALLEGRO_FONT_VTABLE 21 { 22 int function(in ALLEGRO_FONT* f) font_height; 23 int function(in ALLEGRO_FONT* f, int ch) char_length; 24 int function(in ALLEGRO_FONT* f, in ALLEGRO_USTR* text) text_length; 25 int function(in ALLEGRO_FONT* f, int ch, int x, int y) render_char; 26 int function(in ALLEGRO_FONT* f, in ALLEGRO_USTR* text, int x, int y) render; 27 void function(ALLEGRO_FONT* f) destroy; 28 void function(in ALLEGRO_FONT* f, 29 in ALLEGRO_USTR* text, int* bbx, int* bby, int* bbw, 30 int* bbh, int* ascent, int* descent) get_text_dimensions; 31 int function (ALLEGRO_FONT* font, int ranges_count, int* ranges) get_font_ranges; 32 } 33 34 enum 35 { 36 ALLEGRO_ALIGN_LEFT = 0, 37 ALLEGRO_ALIGN_CENTRE = 1, 38 ALLEGRO_ALIGN_CENTER = 1, 39 ALLEGRO_ALIGN_RIGHT = 2, 40 ALLEGRO_ALIGN_INTEGER = 4 41 } 42 43 bool al_register_font_loader(in char* ext, ALLEGRO_FONT* function(in char* filename, int size, int flags) load); 44 ALLEGRO_FONT* al_load_bitmap_font(in char* filename); 45 ALLEGRO_FONT* al_load_bitmap_font_flags(in char* filename, int flags); 46 ALLEGRO_FONT* al_load_font(in char* filename, int size, int flags); 47 48 ALLEGRO_FONT* al_grab_font_from_bitmap(ALLEGRO_BITMAP* bmp, int n, in int* ranges); 49 ALLEGRO_FONT* al_create_builtin_font(); 50 51 void al_draw_ustr(in ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int flags, in ALLEGRO_USTR* ustr); 52 void al_draw_text(in ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int flags, in char* text); 53 void al_draw_justified_text(in ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x1, float x2, float y, float diff, int flags, in char* text); 54 void al_draw_justified_ustr(in ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x1, float x2, float y, float diff, int flags, in ALLEGRO_USTR* text); 55 void al_draw_textf(in ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int flags, in char* format, ...); 56 void al_draw_justified_textf(in ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x1, float x2, float y, float diff, int flags, in char* format, ...); 57 int al_get_text_width(in ALLEGRO_FONT* f, in char* str); 58 int al_get_ustr_width(in ALLEGRO_FONT* f, in ALLEGRO_USTR* ustr); 59 int al_get_font_line_height(in ALLEGRO_FONT* f); 60 int al_get_font_ascent(in ALLEGRO_FONT* f); 61 int al_get_font_descent(in ALLEGRO_FONT* f); 62 void al_destroy_font(ALLEGRO_FONT* f); 63 void al_get_ustr_dimensions(in ALLEGRO_FONT* f, in ALLEGRO_USTR* text, int* bbx, int* bby, int* bbw, int* bbh, int* ascent, int* descent); 64 void al_get_text_dimensions(in ALLEGRO_FONT* f, in char* text, int* bbx, int* bby, int* bbw, int* bbh, int* ascent, int* descent); 65 void al_init_font_addon(); 66 void al_shutdown_font_addon(); 67 uint al_get_allegro_font_version(); 68 int al_get_font_ranges(ALLEGRO_FONT *font, int ranges_count, int* ranges); 69 }