Mercurial > molko
comparison libcore/core/font.c @ 169:eb0a7ab71023
misc: extreme cleanup, closes #2506
While here, remove unneeded stuff.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 20 Oct 2020 17:39:13 +0200 |
parents | e05a792f6910 |
children | 6992085d47fd |
comparison
equal
deleted
inserted
replaced
168:aab824406d3d | 169:eb0a7ab71023 |
---|---|
21 | 21 |
22 #include <SDL_ttf.h> | 22 #include <SDL_ttf.h> |
23 | 23 |
24 #include "color.h" | 24 #include "color.h" |
25 #include "error.h" | 25 #include "error.h" |
26 #include "error_p.h" | |
27 #include "font.h" | 26 #include "font.h" |
28 #include "texture_p.h" | 27 #include "texture_p.h" |
29 #include "util.h" | 28 #include "util.h" |
30 | 29 |
31 bool | 30 bool |
33 { | 32 { |
34 assert(font); | 33 assert(font); |
35 assert(path); | 34 assert(path); |
36 | 35 |
37 if (!(font->handle = TTF_OpenFont(path, size))) | 36 if (!(font->handle = TTF_OpenFont(path, size))) |
38 return error_sdl(); | 37 return errorf("%s", SDL_GetError()); |
39 | 38 |
40 return true; | 39 return true; |
41 } | 40 } |
42 | 41 |
43 bool | 42 bool |
48 | 47 |
49 SDL_RWops *ops; | 48 SDL_RWops *ops; |
50 | 49 |
51 if (!(ops = SDL_RWFromConstMem(buffer, buflen)) || | 50 if (!(ops = SDL_RWFromConstMem(buffer, buflen)) || |
52 (!(font->handle = TTF_OpenFontRW(ops, true, size)))) | 51 (!(font->handle = TTF_OpenFontRW(ops, true, size)))) |
53 return error_sdl(); | 52 return errorf("%s", SDL_GetError()); |
54 | 53 |
55 return true; | 54 return true; |
56 } | 55 } |
57 | 56 |
58 void | 57 void |
95 func = TTF_RenderUTF8_Solid; | 94 func = TTF_RenderUTF8_Solid; |
96 break; | 95 break; |
97 } | 96 } |
98 | 97 |
99 if (!(surface = func(font->handle, text, fg))) | 98 if (!(surface = func(font->handle, text, fg))) |
100 return error_sdl(); | 99 return errorf("%s", SDL_GetError()); |
101 | 100 |
102 return texture_from_surface(tex, surface); | 101 return texture_from_surface(tex, surface); |
103 } | 102 } |
104 | 103 |
105 unsigned int | 104 unsigned int |
115 { | 114 { |
116 assert(font_ok(font)); | 115 assert(font_ok(font)); |
117 assert(text); | 116 assert(text); |
118 | 117 |
119 if (TTF_SizeUTF8(font->handle, text, (int *)w, (int *)h) != 0) | 118 if (TTF_SizeUTF8(font->handle, text, (int *)w, (int *)h) != 0) |
120 return error_sdl(); | 119 return errorf("%s", SDL_GetError()); |
121 | 120 |
122 return true; | 121 return true; |
123 } | 122 } |
124 | 123 |
125 void | 124 void |