@@ -7,11 +7,10 @@ use std::path::Path;
7
7
use sdl2:: get_error;
8
8
use sdl2:: rwops:: RWops ;
9
9
use sdl2:: version:: Version ;
10
- use sdl2:: SdlResult ;
11
10
12
11
use font:: {
13
- internal_load_font,
14
- internal_load_font_at_index,
12
+ internal_load_font,
13
+ internal_load_font_at_index,
15
14
internal_load_font_from_ll,
16
15
Font ,
17
16
} ;
@@ -31,21 +30,21 @@ impl Drop for Sdl2TtfContext {
31
30
32
31
impl Sdl2TtfContext {
33
32
/// Loads a font from the given file with the given size in points.
34
- pub fn load_font ( & self , path : & Path , point_size : u16 ) -> SdlResult < Font > {
33
+ pub fn load_font ( & self , path : & Path , point_size : u16 ) -> Result < Font , String > {
35
34
internal_load_font ( path, point_size)
36
35
}
37
-
38
- /// Loads the font at the given index of the file, with the given
39
- /// size in points.
36
+
37
+ /// Loads the font at the given index of the file, with the given
38
+ /// size in points.
40
39
pub fn load_font_at_index ( & self , path : & Path , index : u32 , point_size : u16 )
41
- -> SdlResult < Font > {
40
+ -> Result < Font , String > {
42
41
internal_load_font_at_index ( path, index, point_size)
43
42
}
44
-
43
+
45
44
/// Loads a font from the given SDL2 rwops object with the given size in
46
45
/// points.
47
- pub fn load_font_from_rwops ( & self , rwops : RWops , point_size : u16 )
48
- -> SdlResult < Font > {
46
+ pub fn load_font_from_rwops ( & self , rwops : RWops , point_size : u16 )
47
+ -> Result < Font , String > {
49
48
let raw = unsafe {
50
49
ffi:: TTF_OpenFontRW ( rwops. raw ( ) , 0 , point_size as c_int )
51
50
} ;
@@ -55,13 +54,13 @@ impl Sdl2TtfContext {
55
54
Ok ( internal_load_font_from_ll ( raw, true ) )
56
55
}
57
56
}
58
-
57
+
59
58
/// Loads the font at the given index of the SDL2 rwops object with
60
59
/// the given size in points.
61
- pub fn load_font_at_index_from_rwops ( & self , rwops : RWops , index : u32 ,
62
- point_size : u16 ) -> SdlResult < Font > {
60
+ pub fn load_font_at_index_from_rwops ( & self , rwops : RWops , index : u32 ,
61
+ point_size : u16 ) -> Result < Font , String > {
63
62
let raw = unsafe {
64
- ffi:: TTF_OpenFontIndexRW ( rwops. raw ( ) , 0 , point_size as c_int ,
63
+ ffi:: TTF_OpenFontIndexRW ( rwops. raw ( ) , 0 , point_size as c_int ,
65
64
index as c_long )
66
65
} ;
67
66
if ( raw as * mut ( ) ) . is_null ( ) {
@@ -117,8 +116,8 @@ impl fmt::Display for InitError {
117
116
}
118
117
}
119
118
120
- /// Initializes the truetype font API and returns a context manager which will
121
- /// clean up the library once it goes out of scope.
119
+ /// Initializes the truetype font API and returns a context manager which will
120
+ /// clean up the library once it goes out of scope.
122
121
pub fn init ( ) -> Result < Sdl2TtfContext , InitError > {
123
122
unsafe {
124
123
if ffi:: TTF_WasInit ( ) == 1 {
@@ -140,4 +139,4 @@ pub fn has_been_initialized() -> bool {
140
139
unsafe {
141
140
ffi:: TTF_WasInit ( ) == 1
142
141
}
143
- }
142
+ }
0 commit comments