1#![allow(non_camel_case_types)]
6
7pub use self::allegro_font::*;
8
9pub mod allegro_font
10{
11 use allegro_sys::{ALLEGRO_BITMAP, ALLEGRO_COLOR, ALLEGRO_USTR};
12 use allegro_util::c_bool;
13 use libc::*;
14
15 #[repr(C)]
16 #[derive(Copy, Clone)]
17 pub struct ALLEGRO_FONT
18 {
19 pub data: *mut c_void,
20 pub height: c_int,
21 pub vtable: *mut ALLEGRO_FONT_VTABLE,
22 }
23
24 #[repr(C)]
25 pub struct ALLEGRO_FONT_VTABLE
26 {
27 pub font_height: Option<extern "C" fn(arg1: *const ALLEGRO_FONT) -> c_int>,
28 pub font_ascent: Option<extern "C" fn(arg1: *const ALLEGRO_FONT) -> c_int>,
29 pub font_descent: Option<extern "C" fn(arg1: *const ALLEGRO_FONT) -> c_int>,
30 pub char_length: Option<extern "C" fn(arg1: *const ALLEGRO_FONT, arg2: c_int) -> c_int>,
31 pub text_length:
32 Option<extern "C" fn(arg1: *const ALLEGRO_FONT, arg2: *const ALLEGRO_USTR) -> c_int>,
33 pub render_char: Option<
34 extern "C" fn(
35 arg1: *const ALLEGRO_FONT,
36 arg2: ALLEGRO_COLOR,
37 arg3: c_int,
38 arg4: c_float,
39 arg5: c_float,
40 ) -> c_int,
41 >,
42 pub render: Option<
43 extern "C" fn(
44 arg1: *const ALLEGRO_FONT,
45 arg2: ALLEGRO_COLOR,
46 arg3: *const ALLEGRO_USTR,
47 arg4: c_float,
48 arg5: c_float,
49 ) -> c_int,
50 >,
51 pub destroy: Option<extern "C" fn(arg1: *mut ALLEGRO_FONT)>,
52 pub get_text_dimensions: Option<
53 extern "C" fn(
54 arg1: *const ALLEGRO_FONT,
55 arg2: *const ALLEGRO_USTR,
56 arg3: *mut c_int,
57 arg4: *mut c_int,
58 arg5: *mut c_int,
59 arg6: *mut c_int,
60 ),
61 >,
62 }
63 allegro_util::derive_copy_clone!(ALLEGRO_FONT_VTABLE);
64
65 pub const ALLEGRO_ALIGN_LEFT: c_int = 0;
66 pub const ALLEGRO_ALIGN_CENTRE: c_int = 1;
67 pub const ALLEGRO_ALIGN_CENTER: c_int = 1;
68 pub const ALLEGRO_ALIGN_RIGHT: c_int = 2;
69 pub const ALLEGRO_ALIGN_INTEGER: c_int = 4;
70
71 unsafe extern "C" {
72 pub fn al_register_font_loader(
73 ext: *const c_char,
74 load: Option<
75 extern "C" fn(arg1: *const c_char, arg2: c_int, arg3: c_int) -> *mut ALLEGRO_FONT,
76 >,
77 ) -> c_bool;
78 pub fn al_load_bitmap_font(filename: *const c_char) -> *mut ALLEGRO_FONT;
79 pub fn al_load_font(
80 filename: *const c_char, size: c_int, flags: c_int,
81 ) -> *mut ALLEGRO_FONT;
82 pub fn al_grab_font_from_bitmap(
83 bmp: *mut ALLEGRO_BITMAP, n: c_int, ranges: *const c_int,
84 ) -> *mut ALLEGRO_FONT;
85 pub fn al_create_builtin_font() -> *mut ALLEGRO_FONT;
86 pub fn al_draw_ustr(
87 font: *const ALLEGRO_FONT, color: ALLEGRO_COLOR, x: c_float, y: c_float, flags: c_int,
88 ustr: *const ALLEGRO_USTR,
89 );
90 pub fn al_draw_text(
91 font: *const ALLEGRO_FONT, color: ALLEGRO_COLOR, x: c_float, y: c_float, flags: c_int,
92 text: *const c_char,
93 );
94 pub fn al_draw_justified_text(
95 font: *const ALLEGRO_FONT, color: ALLEGRO_COLOR, x1: c_float, x2: c_float, y: c_float,
96 diff: c_float, flags: c_int, text: *const c_char,
97 );
98 pub fn al_draw_justified_ustr(
99 font: *const ALLEGRO_FONT, color: ALLEGRO_COLOR, x1: c_float, x2: c_float, y: c_float,
100 diff: c_float, flags: c_int, text: *const ALLEGRO_USTR,
101 );
102 pub fn al_get_text_width(f: *const ALLEGRO_FONT, str: *const c_char) -> c_int;
103 pub fn al_get_ustr_width(f: *const ALLEGRO_FONT, ustr: *const ALLEGRO_USTR) -> c_int;
104 pub fn al_get_font_line_height(f: *const ALLEGRO_FONT) -> c_int;
105 pub fn al_get_font_ascent(f: *const ALLEGRO_FONT) -> c_int;
106 pub fn al_get_font_descent(f: *const ALLEGRO_FONT) -> c_int;
107 pub fn al_destroy_font(f: *mut ALLEGRO_FONT);
108 pub fn al_get_ustr_dimensions(
109 f: *const ALLEGRO_FONT, text: *const ALLEGRO_USTR, bbx: *mut c_int, bby: *mut c_int,
110 bbw: *mut c_int, bbh: *mut c_int,
111 );
112 pub fn al_get_text_dimensions(
113 f: *const ALLEGRO_FONT, text: *const c_char, bbx: *mut c_int, bby: *mut c_int,
114 bbw: *mut c_int, bbh: *mut c_int,
115 );
116 pub fn al_init_font_addon();
117 pub fn al_shutdown_font_addon();
118 pub fn al_get_allegro_font_version() -> u32;
119 }
120}