Skip to content

Latest commit

 

History

History
249 lines (206 loc) · 10.3 KB

SDL_ttf.h

File metadata and controls

249 lines (206 loc) · 10.3 KB
 
Jun 21, 2001
Jun 21, 2001
1
2
/*
SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
Dec 8, 2008
Dec 8, 2008
3
Copyright (C) 1997-2009 Sam Lantinga
Jun 21, 2001
Jun 21, 2001
4
Oct 5, 2001
Oct 5, 2001
5
6
7
8
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Jun 21, 2001
Jun 21, 2001
9
Oct 5, 2001
Oct 5, 2001
10
This library is distributed in the hope that it will be useful,
Jun 21, 2001
Jun 21, 2001
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
Oct 5, 2001
Oct 5, 2001
12
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
Jun 21, 2001
Jun 21, 2001
14
Oct 5, 2001
Oct 5, 2001
15
16
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Jun 21, 2001
Jun 21, 2001
17
18
19
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
Dec 14, 2001
Dec 14, 2001
20
slouken@libsdl.org
Jun 21, 2001
Jun 21, 2001
21
22
*/
Dec 14, 2001
Dec 14, 2001
23
24
/* $Id$ */
Oct 5, 2001
Oct 5, 2001
25
/* This library is a wrapper around the excellent FreeType 2.0 library,
Jun 21, 2001
Jun 21, 2001
26
available at:
Oct 5, 2001
Oct 5, 2001
27
http://www.freetype.org/
Jun 21, 2001
Jun 21, 2001
28
29
*/
Jul 23, 2003
Jul 23, 2003
30
31
#ifndef _SDL_TTF_H
#define _SDL_TTF_H
Jun 21, 2001
Jun 21, 2001
32
33
34
35
36
37
38
39
40
#include "SDL.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
Aug 25, 2002
Aug 25, 2002
41
42
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
Jul 23, 2003
Jul 23, 2003
43
44
#define SDL_TTF_MAJOR_VERSION 2
#define SDL_TTF_MINOR_VERSION 0
Sep 26, 2009
Sep 26, 2009
45
#define SDL_TTF_PATCHLEVEL 10
Aug 25, 2002
Aug 25, 2002
46
47
/* This macro can be used to fill a version structure with the compile-time
Nov 3, 2002
Nov 3, 2002
48
* version of the SDL_ttf library.
Aug 25, 2002
Aug 25, 2002
49
*/
Jul 23, 2003
Jul 23, 2003
50
#define SDL_TTF_VERSION(X) \
Aug 25, 2002
Aug 25, 2002
51
{ \
Jul 23, 2003
Jul 23, 2003
52
53
54
(X)->major = SDL_TTF_MAJOR_VERSION; \
(X)->minor = SDL_TTF_MINOR_VERSION; \
(X)->patch = SDL_TTF_PATCHLEVEL; \
Aug 25, 2002
Aug 25, 2002
55
56
}
Jul 23, 2003
Jul 23, 2003
57
58
59
60
61
62
/* Backwards compatibility */
#define TTF_MAJOR_VERSION SDL_TTF_MAJOR_VERSION
#define TTF_MINOR_VERSION SDL_TTF_MINOR_VERSION
#define TTF_PATCHLEVEL SDL_TTF_PATCHLEVEL
#define TTF_VERSION(X) SDL_TTF_VERSION(X)
Aug 25, 2002
Aug 25, 2002
63
64
/* This function gets the version of the dynamically linked SDL_ttf library.
it should NOT be used to fill a version structure, instead you should
Jul 23, 2003
Jul 23, 2003
65
use the SDL_TTF_VERSION() macro.
Aug 25, 2002
Aug 25, 2002
66
67
68
*/
extern DECLSPEC const SDL_version * SDLCALL TTF_Linked_Version(void);
Feb 10, 2003
Feb 10, 2003
69
70
71
72
73
/* ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) */
#define UNICODE_BOM_NATIVE 0xFEFF
#define UNICODE_BOM_SWAPPED 0xFFFE
/* This function tells the library whether UNICODE text is generally
Feb 10, 2003
Feb 10, 2003
74
75
byteswapped. A UNICODE BOM character in a string will override
this setting for the remainder of that string.
Feb 10, 2003
Feb 10, 2003
76
77
*/
extern DECLSPEC void SDLCALL TTF_ByteSwappedUNICODE(int swapped);
Aug 25, 2002
Aug 25, 2002
78
Jun 21, 2001
Jun 21, 2001
79
80
81
82
/* The internal structure containing font information */
typedef struct _TTF_Font TTF_Font;
/* Initialize the TTF engine - returns 0 if successful, -1 on error */
Apr 13, 2002
Apr 13, 2002
83
extern DECLSPEC int SDLCALL TTF_Init(void);
Jun 21, 2001
Jun 21, 2001
84
Dec 2, 2002
Dec 2, 2002
85
86
87
88
/* Open a font file and create a font of the specified point size.
* Some .fon fonts will have several sizes embedded in the file, so the
* point size becomes the index of choosing which size. If the value
* is too high, the last indexed size will be the default. */
Apr 13, 2002
Apr 13, 2002
89
90
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFont(const char *file, int ptsize);
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndex(const char *file, int ptsize, long index);
Aug 25, 2002
Aug 25, 2002
91
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize);
Aug 25, 2002
Aug 25, 2002
92
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index);
Jun 21, 2001
Jun 21, 2001
93
Oct 17, 2009
Oct 17, 2009
94
/* Set and retrieve the font style */
Jun 21, 2001
Jun 21, 2001
95
96
97
98
#define TTF_STYLE_NORMAL 0x00
#define TTF_STYLE_BOLD 0x01
#define TTF_STYLE_ITALIC 0x02
#define TTF_STYLE_UNDERLINE 0x04
Oct 17, 2009
Oct 17, 2009
99
#define TTF_STYLE_STRIKETHROUGH 0x08
Feb 13, 2007
Feb 13, 2007
100
extern DECLSPEC int SDLCALL TTF_GetFontStyle(const TTF_Font *font);
Apr 13, 2002
Apr 13, 2002
101
extern DECLSPEC void SDLCALL TTF_SetFontStyle(TTF_Font *font, int style);
Oct 11, 2009
Oct 11, 2009
102
103
extern DECLSPEC int SDLCALL TTF_GetFontOutline(const TTF_Font *font);
extern DECLSPEC void SDLCALL TTF_SetFontOutline(TTF_Font *font, int outline);
Jun 21, 2001
Jun 21, 2001
104
Sep 26, 2009
Sep 26, 2009
105
106
107
108
109
110
111
112
/* Set and retrieve FreeType hinter settings */
#define TTF_HINTING_NORMAL 0
#define TTF_HINTING_LIGHT 1
#define TTF_HINTING_MONO 2
#define TTF_HINTING_NONE 3
extern DECLSPEC int SDLCALL TTF_GetFontHinting(const TTF_Font *font);
extern DECLSPEC void SDLCALL TTF_SetFontHinting(TTF_Font *font, int hinting);
Jun 21, 2001
Jun 21, 2001
113
/* Get the total height of the font - usually equal to point size */
Feb 13, 2007
Feb 13, 2007
114
extern DECLSPEC int SDLCALL TTF_FontHeight(const TTF_Font *font);
Jun 21, 2001
Jun 21, 2001
115
116
117
118
/* Get the offset from the baseline to the top of the font
This is a positive value, relative to the baseline.
*/
Feb 13, 2007
Feb 13, 2007
119
extern DECLSPEC int SDLCALL TTF_FontAscent(const TTF_Font *font);
Jun 21, 2001
Jun 21, 2001
120
121
122
123
/* Get the offset from the baseline to the bottom of the font
This is a negative value, relative to the baseline.
*/
Feb 13, 2007
Feb 13, 2007
124
extern DECLSPEC int SDLCALL TTF_FontDescent(const TTF_Font *font);
Jun 21, 2001
Jun 21, 2001
125
126
/* Get the recommended spacing between lines of text for this font */
Feb 13, 2007
Feb 13, 2007
127
extern DECLSPEC int SDLCALL TTF_FontLineSkip(const TTF_Font *font);
Jun 21, 2001
Jun 21, 2001
128
Sep 26, 2009
Sep 26, 2009
129
130
131
132
/* Get/Set whether or not kerning is allowed for this font */
extern DECLSPEC int SDLCALL TTF_GetFontKerning(const TTF_Font *font);
extern DECLSPEC void SDLCALL TTF_SetFontKerning(TTF_Font *font, int allowed);
Nov 1, 2001
Nov 1, 2001
133
/* Get the number of faces of the font */
Feb 13, 2007
Feb 13, 2007
134
extern DECLSPEC long SDLCALL TTF_FontFaces(const TTF_Font *font);
Nov 1, 2001
Nov 1, 2001
135
136
/* Get the font face attributes, if any */
Feb 13, 2007
Feb 13, 2007
137
138
139
extern DECLSPEC int SDLCALL TTF_FontFaceIsFixedWidth(const TTF_Font *font);
extern DECLSPEC char * SDLCALL TTF_FontFaceFamilyName(const TTF_Font *font);
extern DECLSPEC char * SDLCALL TTF_FontFaceStyleName(const TTF_Font *font);
Nov 1, 2001
Nov 1, 2001
140
Jul 24, 2007
Jul 24, 2007
141
142
143
/* Check wether a glyph is provided by the font or not */
extern DECLSPEC int SDLCALL TTF_GlyphIsProvided(const TTF_Font *font, Uint16 ch);
Aug 31, 2003
Aug 31, 2003
144
145
146
147
/* Get the metrics (dimensions) of a glyph
To understand what these metrics mean, here is a useful link:
http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
*/
Apr 13, 2002
Apr 13, 2002
148
extern DECLSPEC int SDLCALL TTF_GlyphMetrics(TTF_Font *font, Uint16 ch,
Jun 21, 2001
Jun 21, 2001
149
150
151
152
int *minx, int *maxx,
int *miny, int *maxy, int *advance);
/* Get the dimensions of a rendered string of text */
Apr 13, 2002
Apr 13, 2002
153
154
155
extern DECLSPEC int SDLCALL TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h);
extern DECLSPEC int SDLCALL TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h);
extern DECLSPEC int SDLCALL TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h);
Jun 21, 2001
Jun 21, 2001
156
157
158
159
160
161
162
/* Create an 8-bit palettized surface and render the given text at
fast quality with the given font and color. The 0 pixel is the
colorkey, giving a transparent background, and the 1 pixel is set
to the text color.
This function returns the new surface, or NULL if there was an error.
*/
Apr 13, 2002
Apr 13, 2002
163
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
164
const char *text, SDL_Color fg);
Apr 13, 2002
Apr 13, 2002
165
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
166
const char *text, SDL_Color fg);
Apr 13, 2002
Apr 13, 2002
167
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
168
169
170
171
172
173
174
175
176
const Uint16 *text, SDL_Color fg);
/* Create an 8-bit palettized surface and render the given glyph at
fast quality with the given font and color. The 0 pixel is the
colorkey, giving a transparent background, and the 1 pixel is set
to the text color. The glyph is rendered without any padding or
centering in the X direction, and aligned normally in the Y direction.
This function returns the new surface, or NULL if there was an error.
*/
Apr 13, 2002
Apr 13, 2002
177
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Solid(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
178
179
180
181
182
183
184
Uint16 ch, SDL_Color fg);
/* Create an 8-bit palettized surface and render the given text at
high quality with the given font and colors. The 0 pixel is background,
while other pixels have varying degrees of the foreground color.
This function returns the new surface, or NULL if there was an error.
*/
Apr 13, 2002
Apr 13, 2002
185
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
186
const char *text, SDL_Color fg, SDL_Color bg);
Apr 13, 2002
Apr 13, 2002
187
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Shaded(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
188
const char *text, SDL_Color fg, SDL_Color bg);
Apr 13, 2002
Apr 13, 2002
189
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Shaded(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
190
191
192
193
194
195
196
197
198
const Uint16 *text, SDL_Color fg, SDL_Color bg);
/* Create an 8-bit palettized surface and render the given glyph at
high quality with the given font and colors. The 0 pixel is background,
while other pixels have varying degrees of the foreground color.
The glyph is rendered without any padding or centering in the X
direction, and aligned normally in the Y direction.
This function returns the new surface, or NULL if there was an error.
*/
Apr 13, 2002
Apr 13, 2002
199
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Shaded(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
200
201
202
203
204
205
Uint16 ch, SDL_Color fg, SDL_Color bg);
/* Create a 32-bit ARGB surface and render the given text at high quality,
using alpha blending to dither the font with the given color.
This function returns the new surface, or NULL if there was an error.
*/
Apr 13, 2002
Apr 13, 2002
206
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
207
const char *text, SDL_Color fg);
Apr 13, 2002
Apr 13, 2002
208
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
209
const char *text, SDL_Color fg);
Apr 13, 2002
Apr 13, 2002
210
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
211
212
213
214
215
216
217
218
const Uint16 *text, SDL_Color fg);
/* Create a 32-bit ARGB surface and render the given glyph at high quality,
using alpha blending to dither the font with the given color.
The glyph is rendered without any padding or centering in the X
direction, and aligned normally in the Y direction.
This function returns the new surface, or NULL if there was an error.
*/
Apr 13, 2002
Apr 13, 2002
219
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Blended(TTF_Font *font,
Jun 21, 2001
Jun 21, 2001
220
221
222
223
224
225
226
227
228
229
230
Uint16 ch, SDL_Color fg);
/* For compatibility with previous versions, here are the old functions */
#define TTF_RenderText(font, text, fg, bg) \
TTF_RenderText_Shaded(font, text, fg, bg)
#define TTF_RenderUTF8(font, text, fg, bg) \
TTF_RenderUTF8_Shaded(font, text, fg, bg)
#define TTF_RenderUNICODE(font, text, fg, bg) \
TTF_RenderUNICODE_Shaded(font, text, fg, bg)
/* Close an opened font file */
Apr 13, 2002
Apr 13, 2002
231
extern DECLSPEC void SDLCALL TTF_CloseFont(TTF_Font *font);
Jun 21, 2001
Jun 21, 2001
232
233
/* De-initialize the TTF engine */
Apr 13, 2002
Apr 13, 2002
234
extern DECLSPEC void SDLCALL TTF_Quit(void);
Jun 21, 2001
Jun 21, 2001
235
Sep 3, 2002
Sep 3, 2002
236
237
238
/* Check if the TTF engine is initialized */
extern DECLSPEC int SDLCALL TTF_WasInit(void);
Jun 21, 2001
Jun 21, 2001
239
240
241
242
243
244
/* We'll use SDL for reporting errors */
#define TTF_SetError SDL_SetError
#define TTF_GetError SDL_GetError
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
Feb 19, 2002
Feb 19, 2002
245
}
Jun 21, 2001
Jun 21, 2001
246
247
248
#endif
#include "close_code.h"
Jul 23, 2003
Jul 23, 2003
249
#endif /* _SDL_TTF_H */