Debian Codegraph @

src/derelict/sdl2/ttf.d

raw
1 /*
2
3 Boost Software License - Version 1.0 - August 17th,2003
4
5 Permission is hereby granted,free of charge,to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license(the "Software") to use,reproduce,display,distribute,
8 execute,and transmit the Software,and to prepare derivative works of the
9 Software,and to permit third-parties to whom the Software is furnished to
10 do so,all subject to the following:
11
12 The copyright notices in the Software and this entire statement,including
13 the above license grant,this restriction and the following disclaimer,
14 must be included in all copies of the Software,in whole or in part,and
15 all derivative works of the Software,unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18
19 THE SOFTWARE IS PROVIDED "AS IS",WITHOUT WARRANTY OF ANY KIND,EXPRESS OR
20 IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE,TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY,WHETHER IN CONTRACT,TORT OR OTHERWISE,
24 ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26
27 */
28 module derelict.sdl2.ttf;
29
30 import core.stdc.config;
31 import derelict.sdl2.config,
32 derelict.sdl2.internal.sdl_types;
33
34 static if(staticSDL)
35 import derelict.sdl2.internal.sdl_static : SDL_GetError,SDL_SetError;
36 else
37 import derelict.sdl2.internal.sdl_dynamic : SDL_GetError,SDL_SetError;
38
39 enum : Uint8 {
40 SDL_TTF_MAJOR_VERSION = 2,
41 SDL_TTF_MINOR_VERSION = 0,
42 SDL_TTF_PATCHLEVEL = 12,
43 }
44 alias TTF_MAJOR_VERSION = SDL_TTF_MAJOR_VERSION;
45 alias TTF_MINOR_VERSION = SDL_TTF_MINOR_VERSION;
46 alias TTF_PATCHLEVEL = SDL_TTF_PATCHLEVEL;
47
48 enum {
49 UNICODE_BOM_NATIVE = 0xFEFF,
50 UNICODE_BOM_SWAPPED = 0xFFFE,
51 TTF_STYLE_NORMAL = 0x00,
52 TTF_STYLE_BOLD = 0x01,
53 TTF_STYLE_ITALIC = 0x02,
54 TTF_STYLE_UNDERLINE = 0x04,
55 TTF_STYLE_STRIKETHROUGH = 0x08,
56 }
57
58 enum {
59 TTF_HINTING_NORMAL = 0,
60 TTF_HINTING_LIGHT = 1,
61 TTF_HINTING_MONO = 2,
62 TTF_HINTING_NONE = 3,
63 }
64
65 alias TTF_SetError = SDL_SetError;
66 alias TTF_GetError = SDL_GetError;
67
68 struct TTF_Font;
69
70 @nogc nothrow {
71 void SDL_TTF_VERSION(SDL_version* X) {
72 X.major = SDL_TTF_MAJOR_VERSION;
73 X.minor = SDL_TTF_MINOR_VERSION;
74 X.patch = SDL_TTF_PATCHLEVEL;
75 }
76
77 void TTF_VERSION(SDL_version* X) { SDL_TTF_VERSION(X); }
78 }
79
80 static if(staticTTF) {
81 extern(C) @nogc nothrow {
82 SDL_version* TTF_Linked_Version();
83 void TTF_ByteSwappedUNICODE(int);
84 int TTF_Init();
85 TTF_Font * TTF_OpenFont(const(char)*,int);
86 TTF_Font * TTF_OpenFontIndex(const(char)*,int,c_long );
87 TTF_Font * TTF_OpenFontRW(SDL_RWops*,int,int);
88 TTF_Font * TTF_OpenFontIndexRW(SDL_RWops*,int,int,c_long);
89 int TTF_GetFontStyle(const(TTF_Font)*);
90 void TTF_SetFontStyle(const(TTF_Font)*,int style);
91 int TTF_GetFontOutline(const(TTF_Font)*);
92 void TTF_SetFontOutline(TTF_Font*,int);
93 int TTF_GetFontHinting(const(TTF_Font)*);
94 void TTF_SetFontHinting(TTF_Font*,int);
95 int TTF_FontHeight(const(TTF_Font)*);
96 int TTF_FontAscent(const(TTF_Font)*);
97 int TTF_FontDescent(const(TTF_Font)*);
98 int TTF_FontLineSkip(const(TTF_Font)*);
99 int TTF_GetFontKerning(const(TTF_Font)*);
100 void TTF_SetFontKerning(TTF_Font*,int);
101 int TTF_FontFaces(const(TTF_Font)*);
102 int TTF_FontFaceIsFixedWidth(const(TTF_Font)*);
103 char* TTF_FontFaceFamilyName(const(TTF_Font)*);
104 char* TTF_FontFaceStyleName(const(TTF_Font)*);
105 int TTF_GlyphIsProvided(const(TTF_Font)*,Uint16);
106 int TTF_GlyphMetrics(TTF_Font*,Uint16,int*,int*,int*,int*,int*);
107 int TTF_SizeText(TTF_Font*,const(char)*,int*,int*);
108 int TTF_SizeUTF8(TTF_Font*,const(char)*,int*,int*);
109 int TTF_SizeUNICODE(TTF_Font*,Uint16*,int*,int*);
110 SDL_Surface* TTF_RenderText_Solid(TTF_Font*,const(char)*,SDL_Color);
111 SDL_Surface* TTF_RenderUTF8_Solid(TTF_Font*,const(char)*,SDL_Color);
112 SDL_Surface* TTF_RenderUNICODE_Solid(TTF_Font*,const(Uint16)*,SDL_Color);
113 SDL_Surface* TTF_RenderGlyph_Solid(TTF_Font*,Uint16,SDL_Color);
114 SDL_Surface* TTF_RenderText_Shaded(TTF_Font*,const(char)*,SDL_Color,SDL_Color);
115 SDL_Surface* TTF_RenderUTF8_Shaded(TTF_Font*,const(char)*,SDL_Color,SDL_Color);
116 SDL_Surface* TTF_RenderUNICODE_Shaded(TTF_Font*,const(Uint16)*,SDL_Color,SDL_Color);
117 SDL_Surface* TTF_RenderGlyph_Shaded(TTF_Font*,Uint16,SDL_Color,SDL_Color);
118 SDL_Surface* TTF_RenderText_Blended(TTF_Font*,const(char)*,SDL_Color);
119 SDL_Surface* TTF_RenderUTF8_Blended(TTF_Font*,const(char)*,SDL_Color);
120 SDL_Surface* TTF_RenderUNICODE_Blended(TTF_Font*,const(Uint16)*,SDL_Color);
121 SDL_Surface* TTF_RenderText_Blended_Wrapped(TTF_Font*,const(char)*,SDL_Color,Uint32);
122 SDL_Surface* TTF_RenderUTF8_Blended_Wrapped(TTF_Font*,const(char)*,SDL_Color,Uint32);
123 SDL_Surface* TTF_RenderUNICODE_Blended_Wrapped(TTF_Font*,const(Uint16)*,SDL_Color,Uint32);
124 SDL_Surface* TTF_RenderGlyph_Blended(TTF_Font*,Uint16,SDL_Color);
125 void TTF_CloseFont(TTF_Font*);
126 void TTF_Quit();
127 int TTF_WasInit();
128 int TTF_GetFontKerningSize(TTF_Font*,int,int);
129 }
130 }
131 else {
132 import derelict.util.loader,
133 derelict.util.system;
134
135 extern(C) @nogc nothrow {
136 alias da_TTF_Linked_Version = SDL_version* function();
137 alias da_TTF_ByteSwappedUNICODE = void function(int);
138 alias da_TTF_Init = int function();
139 alias da_TTF_OpenFont = TTF_Font * function(const(char)*,int);
140 alias da_TTF_OpenFontIndex = TTF_Font * function(const(char)*,int,c_long );
141 alias da_TTF_OpenFontRW = TTF_Font * function(SDL_RWops*,int,int);
142 alias da_TTF_OpenFontIndexRW = TTF_Font * function(SDL_RWops*,int,int,c_long);
143 alias da_TTF_GetFontStyle = int function(const(TTF_Font)*);
144 alias da_TTF_SetFontStyle = void function(const(TTF_Font)*,int style);
145 alias da_TTF_GetFontOutline = int function(const(TTF_Font)*);
146 alias da_TTF_SetFontOutline = void function(TTF_Font*,int);
147 alias da_TTF_GetFontHinting = int function(const(TTF_Font)*);
148 alias da_TTF_SetFontHinting = void function(TTF_Font*,int);
149 alias da_TTF_FontHeight = int function(const(TTF_Font)*);
150 alias da_TTF_FontAscent = int function(const(TTF_Font)*);
151 alias da_TTF_FontDescent = int function(const(TTF_Font)*);
152 alias da_TTF_FontLineSkip = int function(const(TTF_Font)*);
153 alias da_TTF_GetFontKerning = int function(const(TTF_Font)*);
154 alias da_TTF_SetFontKerning = void function(TTF_Font*,int);
155 alias da_TTF_FontFaces = int function(const(TTF_Font)*);
156 alias da_TTF_FontFaceIsFixedWidth = int function(const(TTF_Font)*);
157 alias da_TTF_FontFaceFamilyName = char* function(const(TTF_Font)*);
158 alias da_TTF_FontFaceStyleName = char* function(const(TTF_Font)*);
159 alias da_TTF_GlyphIsProvided = int function(const(TTF_Font)*,Uint16);
160 alias da_TTF_GlyphMetrics = int function(TTF_Font*,Uint16,int*,int*,int*,int*,int*);
161 alias da_TTF_SizeText = int function(TTF_Font*,const(char)*,int*,int*);
162 alias da_TTF_SizeUTF8 = int function(TTF_Font*,const(char)*,int*,int*);
163 alias da_TTF_SizeUNICODE = int function(TTF_Font*,Uint16*,int*,int*);
164 alias da_TTF_RenderText_Solid = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color);
165 alias da_TTF_RenderUTF8_Solid = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color);
166 alias da_TTF_RenderUNICODE_Solid = SDL_Surface* function(TTF_Font*,const(Uint16)*,SDL_Color);
167 alias da_TTF_RenderGlyph_Solid = SDL_Surface* function(TTF_Font*,Uint16,SDL_Color);
168 alias da_TTF_RenderText_Shaded = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color,SDL_Color);
169 alias da_TTF_RenderUTF8_Shaded = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color,SDL_Color);
170 alias da_TTF_RenderUNICODE_Shaded = SDL_Surface* function(TTF_Font*,const(Uint16)*,SDL_Color,SDL_Color);
171 alias da_TTF_RenderGlyph_Shaded = SDL_Surface* function(TTF_Font*,Uint16,SDL_Color,SDL_Color);
172 alias da_TTF_RenderText_Blended = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color);
173 alias da_TTF_RenderUTF8_Blended = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color);
174 alias da_TTF_RenderUNICODE_Blended = SDL_Surface* function(TTF_Font*,const(Uint16)*,SDL_Color);
175 alias da_TTF_RenderText_Blended_Wrapped = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color,Uint32);
176 alias da_TTF_RenderUTF8_Blended_Wrapped = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color,Uint32);
177 alias da_TTF_RenderUNICODE_Blended_Wrapped = SDL_Surface* function(TTF_Font*,const(Uint16)*,SDL_Color,Uint32);
178 alias da_TTF_RenderGlyph_Blended = SDL_Surface* function(TTF_Font*,Uint16,SDL_Color);
179 alias da_TTF_CloseFont = void function(TTF_Font*);
180 alias da_TTF_Quit = void function();
181 alias da_TTF_WasInit = int function();
182 alias da_TTF_GetFontKerningSize = int function(TTF_Font*,int,int);
183 }
184
185 __gshared {
186 da_TTF_Linked_Version TTF_Linked_Version;
187 da_TTF_ByteSwappedUNICODE TTF_ByteSwappedUNICODE;
188 da_TTF_Init TTF_Init;
189 da_TTF_OpenFont TTF_OpenFont;
190 da_TTF_OpenFontIndex TTF_OpenFontIndex;
191 da_TTF_OpenFontRW TTF_OpenFontRW;
192 da_TTF_OpenFontIndexRW TTF_OpenFontIndexRW;
193 da_TTF_GetFontStyle TTF_GetFontStyle;
194 da_TTF_SetFontStyle TTF_SetFontStyle;
195 da_TTF_GetFontOutline TTF_GetFontOutline;
196 da_TTF_SetFontOutline TTF_SetFontOutline;
197 da_TTF_GetFontHinting TTF_GetFontHinting;
198 da_TTF_SetFontHinting TTF_SetFontHinting;
199 da_TTF_FontHeight TTF_FontHeight;
200 da_TTF_FontAscent TTF_FontAscent;
201 da_TTF_FontDescent TTF_FontDescent;
202 da_TTF_FontLineSkip TTF_FontLineSkip;
203 da_TTF_GetFontKerning TTF_GetFontKerning;
204 da_TTF_SetFontKerning TTF_SetFontKerning;
205 da_TTF_FontFaces TTF_FontFaces;
206 da_TTF_FontFaceIsFixedWidth TTF_FontFaceIsFixedWidth;
207 da_TTF_FontFaceFamilyName TTF_FontFaceFamilyName;
208 da_TTF_FontFaceStyleName TTF_FontFaceStyleName;
209 da_TTF_GlyphIsProvided TTF_GlyphIsProvided;
210 da_TTF_GlyphMetrics TTF_GlyphMetrics;
211 da_TTF_SizeText TTF_SizeText;
212 da_TTF_SizeUTF8 TTF_SizeUTF8;
213 da_TTF_SizeUNICODE TTF_SizeUNICODE;
214 da_TTF_RenderText_Solid TTF_RenderText_Solid;
215 da_TTF_RenderUTF8_Solid TTF_RenderUTF8_Solid;
216 da_TTF_RenderUNICODE_Solid TTF_RenderUNICODE_Solid;
217 da_TTF_RenderGlyph_Solid TTF_RenderGlyph_Solid;
218 da_TTF_RenderText_Shaded TTF_RenderText_Shaded;
219 da_TTF_RenderUTF8_Shaded TTF_RenderUTF8_Shaded;
220 da_TTF_RenderUNICODE_Shaded TTF_RenderUNICODE_Shaded;
221 da_TTF_RenderGlyph_Shaded TTF_RenderGlyph_Shaded;
222 da_TTF_RenderText_Blended TTF_RenderText_Blended;
223 da_TTF_RenderUTF8_Blended TTF_RenderUTF8_Blended;
224 da_TTF_RenderUNICODE_Blended TTF_RenderUNICODE_Blended;
225 da_TTF_RenderText_Blended_Wrapped TTF_RenderText_Blended_Wrapped;
226 da_TTF_RenderUTF8_Blended_Wrapped TTF_RenderUTF8_Blended_Wrapped;
227 da_TTF_RenderUNICODE_Blended_Wrapped TTF_RenderUNICODE_Blended_Wrapped;
228 da_TTF_RenderGlyph_Blended TTF_RenderGlyph_Blended;
229 da_TTF_CloseFont TTF_CloseFont;
230 da_TTF_Quit TTF_Quit;
231 da_TTF_WasInit TTF_WasInit;
232 da_TTF_GetFontKerningSize TTF_GetFontKerningSize;
233 }
234
235 class DerelictSDL2ttfLoader : SharedLibLoader {
236 this()
237 {
238 super(libNames);
239 }
240
241 protected override void loadSymbols()
242 {
243 bindFunc(cast(void**)&TTF_Linked_Version,"TTF_Linked_Version");
244 bindFunc(cast(void**)&TTF_ByteSwappedUNICODE,"TTF_ByteSwappedUNICODE");
245 bindFunc(cast(void**)&TTF_Init,"TTF_Init");
246 bindFunc(cast(void**)&TTF_OpenFont,"TTF_OpenFont");
247 bindFunc(cast(void**)&TTF_OpenFontIndex,"TTF_OpenFontIndex");
248 bindFunc(cast(void**)&TTF_OpenFontRW,"TTF_OpenFontRW");
249 bindFunc(cast(void**)&TTF_OpenFontIndexRW,"TTF_OpenFontIndexRW");
250 bindFunc(cast(void**)&TTF_GetFontStyle,"TTF_GetFontStyle");
251 bindFunc(cast(void**)&TTF_SetFontStyle,"TTF_SetFontStyle");
252 bindFunc(cast(void**)&TTF_GetFontOutline,"TTF_GetFontOutline");
253 bindFunc(cast(void**)&TTF_SetFontOutline,"TTF_SetFontOutline");
254 bindFunc(cast(void**)&TTF_GetFontHinting,"TTF_GetFontHinting");
255 bindFunc(cast(void**)&TTF_SetFontHinting,"TTF_SetFontHinting");
256 bindFunc(cast(void**)&TTF_FontHeight,"TTF_FontHeight");
257 bindFunc(cast(void**)&TTF_FontAscent,"TTF_FontAscent");
258 bindFunc(cast(void**)&TTF_FontDescent,"TTF_FontDescent");
259 bindFunc(cast(void**)&TTF_FontLineSkip,"TTF_FontLineSkip");
260 bindFunc(cast(void**)&TTF_GetFontKerning,"TTF_GetFontKerning");
261 bindFunc(cast(void**)&TTF_SetFontKerning,"TTF_SetFontKerning");
262 bindFunc(cast(void**)&TTF_FontFaces,"TTF_FontFaces");
263 bindFunc(cast(void**)&TTF_FontFaceIsFixedWidth,"TTF_FontFaceIsFixedWidth");
264 bindFunc(cast(void**)&TTF_FontFaceFamilyName,"TTF_FontFaceFamilyName");
265 bindFunc(cast(void**)&TTF_FontFaceStyleName,"TTF_FontFaceStyleName");
266 bindFunc(cast(void**)&TTF_GlyphIsProvided,"TTF_GlyphIsProvided");
267 bindFunc(cast(void**)&TTF_GlyphMetrics,"TTF_GlyphMetrics");
268 bindFunc(cast(void**)&TTF_SizeText,"TTF_SizeText");
269 bindFunc(cast(void**)&TTF_SizeUTF8,"TTF_SizeUTF8");
270 bindFunc(cast(void**)&TTF_SizeUNICODE,"TTF_SizeUNICODE");
271 bindFunc(cast(void**)&TTF_RenderText_Solid,"TTF_RenderText_Solid");
272 bindFunc(cast(void**)&TTF_RenderUTF8_Solid,"TTF_RenderUTF8_Solid");
273 bindFunc(cast(void**)&TTF_RenderUNICODE_Solid,"TTF_RenderUNICODE_Solid");
274 bindFunc(cast(void**)&TTF_RenderGlyph_Solid,"TTF_RenderGlyph_Solid");
275 bindFunc(cast(void**)&TTF_RenderText_Shaded,"TTF_RenderText_Shaded");
276 bindFunc(cast(void**)&TTF_RenderUTF8_Shaded,"TTF_RenderUTF8_Shaded");
277 bindFunc(cast(void**)&TTF_RenderUNICODE_Shaded,"TTF_RenderUNICODE_Shaded");
278 bindFunc(cast(void**)&TTF_RenderGlyph_Shaded,"TTF_RenderGlyph_Shaded");
279 bindFunc(cast(void**)&TTF_RenderText_Blended,"TTF_RenderText_Blended");
280 bindFunc(cast(void**)&TTF_RenderUTF8_Blended,"TTF_RenderUTF8_Blended");
281 bindFunc(cast(void**)&TTF_RenderUNICODE_Blended,"TTF_RenderUNICODE_Blended");
282 bindFunc(cast(void**)&TTF_RenderText_Blended_Wrapped,"TTF_RenderText_Blended_Wrapped");
283 bindFunc(cast(void**)&TTF_RenderUTF8_Blended_Wrapped,"TTF_RenderUTF8_Blended_Wrapped");
284 bindFunc(cast(void**)&TTF_RenderUNICODE_Blended_Wrapped,"TTF_RenderUNICODE_Blended_Wrapped");
285 bindFunc(cast(void**)&TTF_RenderGlyph_Blended,"TTF_RenderGlyph_Blended");
286 bindFunc(cast(void**)&TTF_CloseFont,"TTF_CloseFont");
287 bindFunc(cast(void**)&TTF_Quit,"TTF_Quit");
288 bindFunc(cast(void**)&TTF_WasInit,"TTF_WasInit");
289 bindFunc(cast(void**)&TTF_GetFontKerningSize,"TTF_GetFontKerningSize");
290 }
291 }
292
293 __gshared DerelictSDL2ttfLoader DerelictSDL2ttf;
294 alias DerelictSDL2TTF = DerelictSDL2ttf;
295
296 shared static this()
297 {
298 DerelictSDL2ttf = new DerelictSDL2ttfLoader();
299 }
300
301 private:
302 static if(Derelict_OS_Windows)
303 enum libNames = "SDL2_ttf.dll";
304 else static if(Derelict_OS_Mac)
305 enum libNames = "/usr/local/lib/libSDL2_ttf.dylib,../Frameworks/SDL2_ttf.framework/SDL2_ttf,/Library/Frameworks/SDL2_ttf.framework/SDL2_ttf,/System/Library/Frameworks/SDL2_ttf.framework/SDL2_ttf";
306 else static if(Derelict_OS_Posix)
307 enum libNames = "libSDL2_ttf.so,libSDL2_ttf-2.0.so,libSDL2_ttf-2.0.so.0,/usr/local/lib/libSDL2_ttf-2.0.so,/usr/local/lib/libSDL2_ttf-2.0.so.0";
308 else
309 static assert(0,"Need to implement SDL2_ttf libNames for this operating system.");
310 }
311
312 alias TTF_RenderText = TTF_RenderText_Shaded;
313 alias TTF_RenderUTF8 = TTF_RenderUTF8_Shaded;
314 alias TTF_RenderUNICODE = TTF_RenderUNICODE_Shaded;