root/trunk/DerelictSDLttf/derelict/sdl/ttf.d

Revision 327, 7.2 kB (checked in by aldacron, 5 years ago)

[DerelictSDL]
* updated to SDL 1.2.13
* now uses no-typedef function pointer declarations
* updated copyright headers
[DerelictSDLNet/ttf]
* updated copyright headers

Line 
1 /*
2  * Copyright (c) 2004-2009 Derelict Developers
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the names 'Derelict', 'DerelictSDLttf', nor the names of its contributors
17  *   may be used to endorse or promote products derived from this software
18  *   without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 module derelict.sdl.ttf;
33
34 private
35 {
36     import derelict.sdl.sdl;
37     import derelict.util.loader;
38 }
39
40 private void load(SharedLib lib)
41 {
42     bindFunc(TTF_Linked_Version)("TTF_Linked_Version", lib);
43     bindFunc(TTF_ByteSwappedUNICODE)("TTF_ByteSwappedUNICODE", lib);
44     bindFunc(TTF_Init)("TTF_Init", lib);
45     bindFunc(TTF_OpenFont)("TTF_OpenFont", lib);
46     bindFunc(TTF_OpenFontIndex)("TTF_OpenFontIndex", lib);
47     bindFunc(TTF_OpenFontRW)("TTF_OpenFontRW", lib);
48     bindFunc(TTF_OpenFontIndexRW)("TTF_OpenFontIndexRW", lib);
49     bindFunc(TTF_GetFontStyle)("TTF_GetFontStyle", lib);
50     bindFunc(TTF_SetFontStyle)("TTF_SetFontStyle", lib);
51     bindFunc(TTF_FontHeight)("TTF_FontHeight", lib);
52     bindFunc(TTF_FontAscent)("TTF_FontAscent", lib);
53     bindFunc(TTF_FontDescent)("TTF_FontDescent", lib);
54     bindFunc(TTF_FontLineSkip)("TTF_FontLineSkip", lib);
55     bindFunc(TTF_FontFaces)("TTF_FontFaces", lib);
56     bindFunc(TTF_FontFaceIsFixedWidth)("TTF_FontFaceIsFixedWidth", lib);
57     bindFunc(TTF_FontFaceFamilyName)("TTF_FontFaceFamilyName", lib);
58     bindFunc(TTF_FontFaceStyleName)("TTF_FontFaceStyleName", lib);
59     bindFunc(TTF_GlyphMetrics)("TTF_GlyphMetrics", lib);
60     bindFunc(TTF_SizeText)("TTF_SizeText", lib);
61     bindFunc(TTF_SizeUTF8)("TTF_SizeUTF8", lib);
62     bindFunc(TTF_SizeUNICODE)("TTF_SizeUNICODE", lib);
63     bindFunc(TTF_RenderText_Solid)("TTF_RenderText_Solid", lib);
64     bindFunc(TTF_RenderUTF8_Solid)("TTF_RenderUTF8_Solid", lib);
65     bindFunc(TTF_RenderUNICODE_Solid)("TTF_RenderUNICODE_Solid", lib);
66     bindFunc(TTF_RenderGlyph_Solid)("TTF_RenderGlyph_Solid", lib);
67     bindFunc(TTF_RenderText_Shaded)("TTF_RenderText_Shaded", lib);
68     bindFunc(TTF_RenderUTF8_Shaded)("TTF_RenderUTF8_Shaded", lib);
69     bindFunc(TTF_RenderUNICODE_Shaded)("TTF_RenderUNICODE_Shaded", lib);
70     bindFunc(TTF_RenderGlyph_Shaded)("TTF_RenderGlyph_Shaded", lib);
71     bindFunc(TTF_RenderText_Blended)("TTF_RenderText_Blended", lib);
72     bindFunc(TTF_RenderUTF8_Blended)("TTF_RenderUTF8_Blended", lib);
73     bindFunc(TTF_RenderUNICODE_Blended)("TTF_RenderUNICODE_Blended", lib);
74     bindFunc(TTF_RenderGlyph_Blended)("TTF_RenderGlyph_Blended", lib);
75     bindFunc(TTF_CloseFont)("TTF_CloseFont", lib);
76     bindFunc(TTF_Quit)("TTF_Quit", lib);
77     bindFunc(TTF_WasInit)("TTF_WasInit", lib);
78 }
79
80
81 GenericLoader DerelictSDLttf;
82 static this() {
83     DerelictSDLttf.setup(
84         "SDL_ttf.dll",
85         "libSDL_ttf.so, libSDL_ttf-2.0.so, libSDL_ttf-2.0.so.0",
86         "./Frameworks/SDL_ttf.framework/SDL_ttf, /Library/Frameworks/SDL_ttf.framework/SDL_ttf, /System/Library/Frameworks/SDL_ttf.framework/SDL_ttf",
87         &load
88     );
89 }
90
91 enum : Uint8
92 {
93     SDL_TTF_MAJOR_VERSION = 2,
94     SDL_TTF_MINOR_VERSION = 0,
95     SDL_TTF_PATCHLEVEL    = 9,
96 }
97 alias SDL_TTF_MAJOR_VERSION TTF_MAJOR_VERSION;
98 alias SDL_TTF_MINOR_VERSION TTF_MINOR_VERSION;
99 alias SDL_TTF_PATCHLEVEL TTF_PATCHLEVEL;
100
101 enum
102 {
103     UNICODE_BOM_NATIVE = 0xFEFF,
104     UNICODE_BOM_SWAPPED = 0xFFFE,
105     TTF_STYLE_NORMAL = 0x00,
106     TTF_STYLE_BOLD = 0x01,
107     TTF_STYLE_ITALIC = 0x02,
108     TTF_STYLE_UNDERLINE = 0x04,
109 }
110
111 alias SDL_SetError TTF_SetError;
112 alias SDL_GetError TTF_GetError;
113
114 struct _TTF_Font {}
115 typedef _TTF_Font TTF_Font;
116
117 void SDL_TTF_VERSION(SDL_version* X)
118 {
119     X.major = SDL_TTF_MAJOR_VERSION;
120     X.minor = SDL_TTF_MINOR_VERSION;
121     X.patch = SDL_TTF_PATCHLEVEL;
122 }
123
124 void TTF_VERSION(SDL_version* X) { SDL_TTF_VERSION(X); }
125
126 extern (C)
127 {
128     SDL_version* function() TTF_Linked_Version;
129     void function(int) TTF_ByteSwappedUNICODE;
130     int function() TTF_Init;
131     TTF_Font * function (char*, int) TTF_OpenFont;
132     TTF_Font * function (char*, int, long ) TTF_OpenFontIndex;
133     TTF_Font * function (SDL_RWops*, int, int) TTF_OpenFontRW;
134     TTF_Font * function (SDL_RWops*, int, int, long) TTF_OpenFontIndexRW;
135     int function (TTF_Font*) TTF_GetFontStyle;
136     void function (TTF_Font*, int style) TTF_SetFontStyle;
137     int function(TTF_Font*) TTF_FontHeight;
138     int function(TTF_Font*) TTF_FontAscent;
139     int function(TTF_Font*) TTF_FontDescent;
140     int function(TTF_Font*) TTF_FontLineSkip;
141     int function(TTF_Font*) TTF_FontFaces;
142     int function(TTF_Font*) TTF_FontFaceIsFixedWidth;
143     char* function(TTF_Font*) TTF_FontFaceFamilyName;
144     char* function(TTF_Font*) TTF_FontFaceStyleName;
145     int function (TTF_Font*, Uint16, int*, int*, int*, int*, int*) TTF_GlyphMetrics;
146     int function (TTF_Font*, char*, int*, int*) TTF_SizeText;
147     int function (TTF_Font*, char*, int*, int*) TTF_SizeUTF8;
148     int function (TTF_Font*, Uint16*, int*, int*) TTF_SizeUNICODE;
149     SDL_Surface* function (TTF_Font*, char*, SDL_Color) TTF_RenderText_Solid;
150     SDL_Surface* function (TTF_Font*, char*, SDL_Color) TTF_RenderUTF8_Solid;
151     SDL_Surface* function (TTF_Font*, Uint16*, SDL_Color) TTF_RenderUNICODE_Solid;
152     SDL_Surface* function (TTF_Font*, Uint16, SDL_Color) TTF_RenderGlyph_Solid;
153     SDL_Surface* function (TTF_Font*, char*, SDL_Color, SDL_Color) TTF_RenderText_Shaded;
154     SDL_Surface* function (TTF_Font*, char*, SDL_Color, SDL_Color) TTF_RenderUTF8_Shaded;
155     SDL_Surface* function (TTF_Font*, Uint16*, SDL_Color, SDL_Color) TTF_RenderUNICODE_Shaded;
156     SDL_Surface* function (TTF_Font*, Uint16, SDL_Color, SDL_Color) TTF_RenderGlyph_Shaded;
157     SDL_Surface* function (TTF_Font*, char*, SDL_Color) TTF_RenderText_Blended;
158     SDL_Surface* function (TTF_Font*, char*, SDL_Color) TTF_RenderUTF8_Blended;
159     SDL_Surface* function (TTF_Font*, Uint16*, SDL_Color) TTF_RenderUNICODE_Blended;
160     SDL_Surface* function (TTF_Font*, Uint16, SDL_Color) TTF_RenderGlyph_Blended;
161     void function (TTF_Font*) TTF_CloseFont;
162     void function () TTF_Quit;
163     int function () TTF_WasInit;
164 }
165
166 alias TTF_RenderText_Shaded TTF_RenderText;
167 alias TTF_RenderUTF8_Shaded TTF_RenderUTF8;
168 alias TTF_RenderUNICODE_Shaded TTF_RenderUNICODE;
Note: See TracBrowser for help on using the browser.