summary refs log tree commit diff stats
path: root/vendor/SDL2_ttf/include
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/SDL2_ttf/include')
-rw-r--r--vendor/SDL2_ttf/include/SDL_ttf.h387
1 files changed, 387 insertions, 0 deletions
diff --git a/vendor/SDL2_ttf/include/SDL_ttf.h b/vendor/SDL2_ttf/include/SDL_ttf.h new file mode 100644 index 0000000..dd346ff --- /dev/null +++ b/vendor/SDL2_ttf/include/SDL_ttf.h
@@ -0,0 +1,387 @@
1/*
2 SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
3 Copyright (C) 2001-2022 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/* This library is a wrapper around the excellent FreeType 2.0 library,
23 available at:
24 http://www.freetype.org/
25*/
26
27/* Note: In many places, SDL_ttf will say "glyph" when it means "code point."
28 Unicode is hard, we learn as we go, and we apologize for adding to the
29 confusion. */
30
31#ifndef SDL_TTF_H_
32#define SDL_TTF_H_
33
34#include "SDL.h"
35#include "begin_code.h"
36
37/* Set up for C function definitions, even when using C++ */
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
43*/
44#define SDL_TTF_MAJOR_VERSION 2
45#define SDL_TTF_MINOR_VERSION 0
46#define SDL_TTF_PATCHLEVEL 18
47
48/* This macro can be used to fill a version structure with the compile-time
49 * version of the SDL_ttf library.
50 */
51#define SDL_TTF_VERSION(X) \
52{ \
53 (X)->major = SDL_TTF_MAJOR_VERSION; \
54 (X)->minor = SDL_TTF_MINOR_VERSION; \
55 (X)->patch = SDL_TTF_PATCHLEVEL; \
56}
57
58/* Backwards compatibility */
59#define TTF_MAJOR_VERSION SDL_TTF_MAJOR_VERSION
60#define TTF_MINOR_VERSION SDL_TTF_MINOR_VERSION
61#define TTF_PATCHLEVEL SDL_TTF_PATCHLEVEL
62#define TTF_VERSION(X) SDL_TTF_VERSION(X)
63
64/**
65 * This is the version number macro for the current SDL_ttf version.
66 */
67#define SDL_TTF_COMPILEDVERSION \
68 SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL)
69
70/**
71 * This macro will evaluate to true if compiled with SDL_ttf at least X.Y.Z.
72 */
73#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
74 (SDL_TTF_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
75
76/* Make sure this is defined (only available in newer SDL versions) */
77#ifndef SDL_DEPRECATED
78#define SDL_DEPRECATED
79#endif
80
81/* This function gets the version of the dynamically linked SDL_ttf library.
82 it should NOT be used to fill a version structure, instead you should
83 use the SDL_TTF_VERSION() macro.
84 */
85extern DECLSPEC const SDL_version * SDLCALL TTF_Linked_Version(void);
86
87/* This function stores the version of the FreeType2 library in use.
88 TTF_Init() should be called before calling this function.
89 */
90extern DECLSPEC void SDLCALL TTF_GetFreeTypeVersion(int *major, int *minor, int *patch);
91
92/* This function stores the version of the HarfBuzz library in use,
93 or 0 if HarfBuzz is not available.
94 */
95extern DECLSPEC void SDLCALL TTF_GetHarfBuzzVersion(int *major, int *minor, int *patch);
96
97/* ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) */
98#define UNICODE_BOM_NATIVE 0xFEFF
99#define UNICODE_BOM_SWAPPED 0xFFFE
100
101/* This function tells the library whether UNICODE text is generally
102 byteswapped. A UNICODE BOM character in a string will override
103 this setting for the remainder of that string.
104*/
105extern DECLSPEC void SDLCALL TTF_ByteSwappedUNICODE(SDL_bool swapped);
106
107/* The internal structure containing font information */
108typedef struct _TTF_Font TTF_Font;
109
110/* Initialize the TTF engine - returns 0 if successful, -1 on error */
111extern DECLSPEC int SDLCALL TTF_Init(void);
112
113/* Open a font file and create a font of the specified point size.
114 * Some .fon fonts will have several sizes embedded in the file, so the
115 * point size becomes the index of choosing which size. If the value
116 * is too high, the last indexed size will be the default. */
117extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFont(const char *file, int ptsize);
118extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndex(const char *file, int ptsize, long index);
119/* Open a font file from a SDL_RWops: 'src' must be kept alive for the lifetime of the TTF_Font.
120 * 'freesrc' can be set so that TTF_CloseFont closes the RWops */
121extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize);
122extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index);
123
124/* Opens a font using the given horizontal and vertical target resolutions (in DPI).
125 * DPI scaling only applies to scalable fonts (e.g. TrueType). */
126extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontDPI(const char *file, int ptsize, unsigned int hdpi, unsigned int vdpi);
127extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexDPI(const char *file, int ptsize, long index, unsigned int hdpi, unsigned int vdpi);
128extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontDPIRW(SDL_RWops *src, int freesrc, int ptsize, unsigned int hdpi, unsigned int vdpi);
129extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexDPIRW(SDL_RWops *src, int freesrc, int ptsize, long index, unsigned int hdpi, unsigned int vdpi);
130
131/* Set font size dynamically */
132extern DECLSPEC int SDLCALL TTF_SetFontSize(TTF_Font *font, int ptsize);
133extern DECLSPEC int SDLCALL TTF_SetFontSizeDPI(TTF_Font *font, int ptsize, unsigned int hdpi, unsigned int vdpi);
134
135/* Set and retrieve the font style */
136#define TTF_STYLE_NORMAL 0x00
137#define TTF_STYLE_BOLD 0x01
138#define TTF_STYLE_ITALIC 0x02
139#define TTF_STYLE_UNDERLINE 0x04
140#define TTF_STYLE_STRIKETHROUGH 0x08
141extern DECLSPEC int SDLCALL TTF_GetFontStyle(const TTF_Font *font);
142extern DECLSPEC void SDLCALL TTF_SetFontStyle(TTF_Font *font, int style);
143extern DECLSPEC int SDLCALL TTF_GetFontOutline(const TTF_Font *font);
144extern DECLSPEC void SDLCALL TTF_SetFontOutline(TTF_Font *font, int outline);
145
146/* Set and retrieve FreeType hinter settings */
147#define TTF_HINTING_NORMAL 0
148#define TTF_HINTING_LIGHT 1
149#define TTF_HINTING_MONO 2
150#define TTF_HINTING_NONE 3
151#define TTF_HINTING_LIGHT_SUBPIXEL 4
152extern DECLSPEC int SDLCALL TTF_GetFontHinting(const TTF_Font *font);
153extern DECLSPEC void SDLCALL TTF_SetFontHinting(TTF_Font *font, int hinting);
154
155/* Get the total height of the font - usually equal to point size */
156extern DECLSPEC int SDLCALL TTF_FontHeight(const TTF_Font *font);
157
158/* Get the offset from the baseline to the top of the font
159 This is a positive value, relative to the baseline.
160 */
161extern DECLSPEC int SDLCALL TTF_FontAscent(const TTF_Font *font);
162
163/* Get the offset from the baseline to the bottom of the font
164 This is a negative value, relative to the baseline.
165 */
166extern DECLSPEC int SDLCALL TTF_FontDescent(const TTF_Font *font);
167
168/* Get the recommended spacing between lines of text for this font */
169extern DECLSPEC int SDLCALL TTF_FontLineSkip(const TTF_Font *font);
170
171/* Get/Set whether or not kerning is allowed for this font */
172extern DECLSPEC int SDLCALL TTF_GetFontKerning(const TTF_Font *font);
173extern DECLSPEC void SDLCALL TTF_SetFontKerning(TTF_Font *font, int allowed);
174
175/* Get the number of faces of the font */
176extern DECLSPEC long SDLCALL TTF_FontFaces(const TTF_Font *font);
177
178/* Get the font face attributes, if any */
179extern DECLSPEC int SDLCALL TTF_FontFaceIsFixedWidth(const TTF_Font *font);
180extern DECLSPEC char * SDLCALL TTF_FontFaceFamilyName(const TTF_Font *font);
181extern DECLSPEC char * SDLCALL TTF_FontFaceStyleName(const TTF_Font *font);
182
183/* Check wether a glyph is provided by the font or not */
184extern DECLSPEC int SDLCALL TTF_GlyphIsProvided(TTF_Font *font, Uint16 ch);
185extern DECLSPEC int SDLCALL TTF_GlyphIsProvided32(TTF_Font *font, Uint32 ch);
186
187/* Get the metrics (dimensions) of a glyph
188 To understand what these metrics mean, here is a useful link:
189 http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
190 */
191extern DECLSPEC int SDLCALL TTF_GlyphMetrics(TTF_Font *font, Uint16 ch,
192 int *minx, int *maxx,
193 int *miny, int *maxy, int *advance);
194extern DECLSPEC int SDLCALL TTF_GlyphMetrics32(TTF_Font *font, Uint32 ch,
195 int *minx, int *maxx,
196 int *miny, int *maxy, int *advance);
197
198/* Get the dimensions of a rendered string of text */
199extern DECLSPEC int SDLCALL TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h);
200extern DECLSPEC int SDLCALL TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h);
201extern DECLSPEC int SDLCALL TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h);
202
203/* Get the measurement string of text without rendering
204 e.g. the number of characters that can be rendered before reaching 'measure_width'
205
206 in:
207 measure_width - in pixels to measure this text
208 out:
209 count - number of characters that can be rendered
210 extent - latest calculated width
211*/
212extern DECLSPEC int SDLCALL TTF_MeasureText(TTF_Font *font, const char *text, int measure_width, int *extent, int *count);
213extern DECLSPEC int SDLCALL TTF_MeasureUTF8(TTF_Font *font, const char *text, int measure_width, int *extent, int *count);
214extern DECLSPEC int SDLCALL TTF_MeasureUNICODE(TTF_Font *font, const Uint16 *text, int measure_width, int *extent, int *count);
215
216/* Create an 8-bit palettized surface and render the given text at
217 fast quality with the given font and color. The 0 pixel is the
218 colorkey, giving a transparent background, and the 1 pixel is set
219 to the text color.
220 This function returns the new surface, or NULL if there was an error.
221*/
222extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font,
223 const char *text, SDL_Color fg);
224extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font,
225 const char *text, SDL_Color fg);
226extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font,
227 const Uint16 *text, SDL_Color fg);
228
229/* Create an 8-bit palettized surface and render the given text at
230 fast quality with the given font and color. The 0 pixel is the
231 colorkey, giving a transparent background, and the 1 pixel is set
232 to the text color.
233 Text is wrapped to multiple lines on line endings and on word boundaries
234 if it extends beyond wrapLength in pixels.
235 If wrapLength is 0, only wrap on new lines.
236 This function returns the new surface, or NULL if there was an error.
237*/
238extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid_Wrapped(TTF_Font *font,
239 const char *text, SDL_Color fg, Uint32 wrapLength);
240extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid_Wrapped(TTF_Font *font,
241 const char *text, SDL_Color fg, Uint32 wrapLength);
242extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid_Wrapped(TTF_Font *font,
243 const Uint16 *text, SDL_Color fg, Uint32 wrapLength);
244
245/* Create an 8-bit palettized surface and render the given glyph at
246 fast quality with the given font and color. The 0 pixel is the
247 colorkey, giving a transparent background, and the 1 pixel is set
248 to the text color. The glyph is rendered without any padding or
249 centering in the X direction, and aligned normally in the Y direction.
250 This function returns the new surface, or NULL if there was an error.
251*/
252extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Solid(TTF_Font *font,
253 Uint16 ch, SDL_Color fg);
254extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph32_Solid(TTF_Font *font,
255 Uint32 ch, SDL_Color fg);
256
257/* Create an 8-bit palettized surface and render the given text at
258 high quality with the given font and colors. The 0 pixel is background,
259 while other pixels have varying degrees of the foreground color.
260 This function returns the new surface, or NULL if there was an error.
261*/
262extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font,
263 const char *text, SDL_Color fg, SDL_Color bg);
264extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Shaded(TTF_Font *font,
265 const char *text, SDL_Color fg, SDL_Color bg);
266extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Shaded(TTF_Font *font,
267 const Uint16 *text, SDL_Color fg, SDL_Color bg);
268
269/* Create an 8-bit palettized surface and render the given text at
270 high quality with the given font and colors. The 0 pixel is background,
271 while other pixels have varying degrees of the foreground color.
272 Text is wrapped to multiple lines on line endings and on word boundaries
273 if it extends beyond wrapLength in pixels.
274 If wrapLength is 0, only wrap on new lines.
275 This function returns the new surface, or NULL if there was an error.
276*/
277extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded_Wrapped(TTF_Font *font,
278 const char *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength);
279extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Shaded_Wrapped(TTF_Font *font,
280 const char *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength);
281extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Shaded_Wrapped(TTF_Font *font,
282 const Uint16 *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength);
283
284/* Create an 8-bit palettized surface and render the given glyph at
285 high quality with the given font and colors. The 0 pixel is background,
286 while other pixels have varying degrees of the foreground color.
287 The glyph is rendered without any padding or centering in the X
288 direction, and aligned normally in the Y direction.
289 This function returns the new surface, or NULL if there was an error.
290*/
291extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Shaded(TTF_Font *font,
292 Uint16 ch, SDL_Color fg, SDL_Color bg);
293extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph32_Shaded(TTF_Font *font,
294 Uint32 ch, SDL_Color fg, SDL_Color bg);
295
296/* Create a 32-bit ARGB surface and render the given text at high quality,
297 using alpha blending to dither the font with the given color.
298 This function returns the new surface, or NULL if there was an error.
299*/
300extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font,
301 const char *text, SDL_Color fg);
302extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended(TTF_Font *font,
303 const char *text, SDL_Color fg);
304extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended(TTF_Font *font,
305 const Uint16 *text, SDL_Color fg);
306
307
308/* Create a 32-bit ARGB surface and render the given text at high quality,
309 using alpha blending to dither the font with the given color.
310 Text is wrapped to multiple lines on line endings and on word boundaries
311 if it extends beyond wrapLength in pixels.
312 If wrapLength is 0, only wrap on new lines.
313 This function returns the new surface, or NULL if there was an error.
314*/
315extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended_Wrapped(TTF_Font *font,
316 const char *text, SDL_Color fg, Uint32 wrapLength);
317extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended_Wrapped(TTF_Font *font,
318 const char *text, SDL_Color fg, Uint32 wrapLength);
319extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended_Wrapped(TTF_Font *font,
320 const Uint16 *text, SDL_Color fg, Uint32 wrapLength);
321
322/* Create a 32-bit ARGB surface and render the given glyph at high quality,
323 using alpha blending to dither the font with the given color.
324 The glyph is rendered without any padding or centering in the X
325 direction, and aligned normally in the Y direction.
326 This function returns the new surface, or NULL if there was an error.
327*/
328extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Blended(TTF_Font *font,
329 Uint16 ch, SDL_Color fg);
330extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph32_Blended(TTF_Font *font,
331 Uint32 ch, SDL_Color fg);
332
333/* For compatibility with previous versions, here are the old functions */
334#define TTF_RenderText(font, text, fg, bg) \
335 TTF_RenderText_Shaded(font, text, fg, bg)
336#define TTF_RenderUTF8(font, text, fg, bg) \
337 TTF_RenderUTF8_Shaded(font, text, fg, bg)
338#define TTF_RenderUNICODE(font, text, fg, bg) \
339 TTF_RenderUNICODE_Shaded(font, text, fg, bg)
340
341/* Set Direction and Script to be used for text shaping.
342 - direction is of type hb_direction_t
343 - script is of type hb_script_t
344
345 This functions returns always 0, or -1 if SDL_ttf is not compiled with HarfBuzz
346*/
347extern DECLSPEC int SDLCALL TTF_SetDirection(int direction); /* hb_direction_t */
348extern DECLSPEC int SDLCALL TTF_SetScript(int script); /* hb_script_t */
349
350/* Close an opened font file */
351extern DECLSPEC void SDLCALL TTF_CloseFont(TTF_Font *font);
352
353/* De-initialize the TTF engine */
354extern DECLSPEC void SDLCALL TTF_Quit(void);
355
356/* Check if the TTF engine is initialized */
357extern DECLSPEC int SDLCALL TTF_WasInit(void);
358
359/* Get the kerning size of two glyphs indices */
360/* DEPRECATED: this function requires FreeType font indexes, not glyphs,
361 by accident, which we don't expose through this API, so it could give
362 wildly incorrect results, especially with non-ASCII values.
363 Going forward, please use TTF_GetFontKerningSizeGlyphs() instead, which
364 does what you probably expected this function to do. */
365extern DECLSPEC int TTF_GetFontKerningSize(TTF_Font *font, int prev_index, int index) SDL_DEPRECATED;
366
367/* Get the kerning size of two glyphs */
368extern DECLSPEC int TTF_GetFontKerningSizeGlyphs(TTF_Font *font, Uint16 previous_ch, Uint16 ch);
369extern DECLSPEC int TTF_GetFontKerningSizeGlyphs32(TTF_Font *font, Uint32 previous_ch, Uint32 ch);
370
371/* Enable Signed Distance Field rendering (with the Blended APIs) */
372extern DECLSPEC int TTF_SetFontSDF(TTF_Font *font, SDL_bool on_off);
373extern DECLSPEC SDL_bool TTF_GetFontSDF(const TTF_Font *font);
374
375/* We'll use SDL for reporting errors */
376#define TTF_SetError SDL_SetError
377#define TTF_GetError SDL_GetError
378
379/* Ends C function definitions when using C++ */
380#ifdef __cplusplus
381}
382#endif
383#include "close_code.h"
384
385#endif /* SDL_TTF_H_ */
386
387/* vi: set ts=4 sw=4 expandtab: */