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 nothrow @nogc extern (C)
12 {
13 	struct ALLEGRO_FONT
14 	{
15 		void* data;
16 		int height;
17 		ALLEGRO_FONT *fallback;
18 		ALLEGRO_FONT_VTABLE* vtable;
19 	}
20 
21 	struct ALLEGRO_FONT_VTABLE
22 	{
23 		int function(in ALLEGRO_FONT* f) font_height;
24 		int function(in ALLEGRO_FONT* f, int ch) char_length;
25 		int function(in ALLEGRO_FONT* f, in ALLEGRO_USTR* text) text_length;
26 		int function(in ALLEGRO_FONT* f, int ch, int x, int y) render_char;
27 		int function(in ALLEGRO_FONT* f, in ALLEGRO_USTR* text, int x, int y) render;
28 		void function(ALLEGRO_FONT* f) destroy;
29 		void function(in ALLEGRO_FONT* f,
30 		  in ALLEGRO_USTR* text, int* bbx, int* bby, int* bbw,
31 		  int* bbh, int* ascent, int* descent) get_text_dimensions;
32 		int function (ALLEGRO_FONT* font, int ranges_count, int* ranges) get_font_ranges;
33 		bool function(const ALLEGRO_FONT *f, int codepoint, int *bbx, int *bby, int *bbw, int *bbh) get_glyph_dimensions;
34 		int function(const ALLEGRO_FONT *font, int codepoint1, int codepoint2) get_glyph_advance;
35 	}
36 
37 	enum
38 	{
39 		ALLEGRO_NO_KERNING       = -1,
40 		ALLEGRO_ALIGN_LEFT       = 0,
41 		ALLEGRO_ALIGN_CENTRE     = 1,
42 		ALLEGRO_ALIGN_CENTER     = 1,
43 		ALLEGRO_ALIGN_RIGHT      = 2,
44 		ALLEGRO_ALIGN_INTEGER    = 4,
45 	}
46 
47 	bool al_register_font_loader(in char* ext, ALLEGRO_FONT* function(in char* filename, int size, int flags) load);
48 	ALLEGRO_FONT* al_load_bitmap_font(in char* filename);
49 	ALLEGRO_FONT* al_load_bitmap_font_flags(in char* filename, int flags);
50 	ALLEGRO_FONT* al_load_font(in char* filename, int size, int flags);
51 
52 	ALLEGRO_FONT* al_grab_font_from_bitmap(ALLEGRO_BITMAP* bmp, int n, in int* ranges);
53 	ALLEGRO_FONT* al_create_builtin_font();
54 
55 	void al_draw_ustr(in ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int flags, in ALLEGRO_USTR* ustr);
56 	void al_draw_text(in ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int flags, in char* text);
57 	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);
58 	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);
59 	void al_draw_textf(in ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int flags, in char* format, ...);
60 	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, ...);
61 	int al_get_text_width(in ALLEGRO_FONT* f, in char* str);
62 	int al_get_ustr_width(in ALLEGRO_FONT* f, in ALLEGRO_USTR* ustr);
63 	int al_get_font_line_height(in ALLEGRO_FONT* f);
64 	int al_get_font_ascent(in ALLEGRO_FONT* f);
65 	int al_get_font_descent(in ALLEGRO_FONT* f);
66 	void al_destroy_font(ALLEGRO_FONT* f);
67 	void al_get_ustr_dimensions(in ALLEGRO_FONT* f, in ALLEGRO_USTR* text, int* bbx, int* bby, int* bbw, int* bbh);
68 	void al_get_text_dimensions(in ALLEGRO_FONT* f,	in char* text, int* bbx, int* bby, int* bbw, int* bbh);
69 	bool al_init_font_addon();
70 	void al_shutdown_font_addon();
71 	uint al_get_allegro_font_version();
72 	int al_get_font_ranges(ALLEGRO_FONT *font, int ranges_count, int* ranges);
73 	void al_draw_glyph(const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int codepoint);
74 	int al_get_glyph_width(const ALLEGRO_FONT *f, int codepoint);
75 	bool al_get_glyph_dimensions(const ALLEGRO_FONT *f, int codepoint, int *bbx, int *bby, int *bbw, int *bbh);
76 	int al_get_glyph_advance(const ALLEGRO_FONT *f, int codepoint1, int codepoint2);
77 	void al_set_fallback_font(ALLEGRO_FONT *font, ALLEGRO_FONT *fallback);
78 	ALLEGRO_FONT* al_get_fallback_font(ALLEGRO_FONT *font);
79 }