ScummVM API documentation
alfont.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef AGS_LIB_ALFONT_H
23#define AGS_LIB_ALFONT_H
24
25#include "ags/lib/allegro/surface.h"
26
27namespace AGS3 {
28
29/* common define */
30
31#define ALFONT_MAJOR_VERSION 1
32#define ALFONT_MINOR_VERSION 9
33#define ALFONT_SUB_VERSION 1
34#define ALFONT_VERSION_STR "1.9.1"
35#define ALFONT_DATE_STR "24/11/2002"
36#define ALFONT_DATE 20021124 /* yyyymmdd */
37
38/* error codes */
39
40#define ALFONT_OK 0
41#define ALFONT_ERROR -1
42
43/* font adjustment flags (AGS compatibility hacks) */
44
45// Force reupdate the font even if the face size matches the request
46#define ALFONT_FLG_FORCE_RESIZE 0x01
47// Make ascender equal to formal font height
48#define ALFONT_FLG_ASCENDER_EQ_HEIGHT 0x02
49// When resizing a font, select the first result even if the actual
50// pixel height is different from the requested size;
51// otherwise will search for the point size which results in pixel
52// height closest to the requested size.
53#define ALFONT_FLG_SELECT_NOMINAL_SZ 0x04
54// Precalculate maximal glyph control box, that is maximal graphical
55// extent of any glyph in the font (which may exceed font's height).
56// Note that this requires FreeType to load each glyph one by one.
57#define ALFONT_FLG_PRECALC_MAX_CBOX 0x08
58
59/* structs */
60typedef struct ALFONT_FONT ALFONT_FONT;
61
62/* API */
63#define ALFONT_DLL_DECLSPEC
64
65ALFONT_DLL_DECLSPEC const char *alfont_get_name(ALFONT_FONT *f);
66
67ALFONT_DLL_DECLSPEC int alfont_init(void);
68ALFONT_DLL_DECLSPEC void alfont_exit(void);
69
70ALFONT_DLL_DECLSPEC ALFONT_FONT *alfont_load_font(const char *filepathname);
71ALFONT_DLL_DECLSPEC ALFONT_FONT *alfont_load_font_from_mem(const char *data, int data_len);
72ALFONT_DLL_DECLSPEC void alfont_destroy_font(ALFONT_FONT *f);
73
74ALFONT_DLL_DECLSPEC int alfont_set_font_size(ALFONT_FONT *f, int h);
75ALFONT_DLL_DECLSPEC int alfont_set_font_size_ex(ALFONT_FONT *f, int h, int flags);
76ALFONT_DLL_DECLSPEC int alfont_get_font_height(ALFONT_FONT *f);
77/* Returns the real font graphical height */
78ALFONT_DLL_DECLSPEC int alfont_get_font_real_height(ALFONT_FONT *f);
79/* Returns the real font graphical extent (top, bottom) */
80ALFONT_DLL_DECLSPEC void alfont_get_font_real_vextent(ALFONT_FONT *f, int *top, int *bottom);
81
82ALFONT_DLL_DECLSPEC int alfont_text_mode(int mode);
83
84ALFONT_DLL_DECLSPEC void alfont_textout_aa(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color);
85ALFONT_DLL_DECLSPEC void alfont_textout(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color);
86ALFONT_DLL_DECLSPEC void alfont_textout_aa_ex(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color, int bg);
87ALFONT_DLL_DECLSPEC void alfont_textout_ex(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color, int bg);
88
89ALFONT_DLL_DECLSPEC void alfont_textout_centre_aa(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color);
90ALFONT_DLL_DECLSPEC void alfont_textout_centre(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color);
91ALFONT_DLL_DECLSPEC void alfont_textout_centre_aa_ex(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color, int bg);
92ALFONT_DLL_DECLSPEC void alfont_textout_centre_ex(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color, int bg);
93
94ALFONT_DLL_DECLSPEC void alfont_textout_right_aa(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color);
95ALFONT_DLL_DECLSPEC void alfont_textout_right(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color);
96ALFONT_DLL_DECLSPEC void alfont_textout_right_aa_ex(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color, int bg);
97ALFONT_DLL_DECLSPEC void alfont_textout_right_ex(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int y, int color, int bg);
98
99ALFONT_DLL_DECLSPEC void alfont_textprintf(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, const char *format, ...);
100ALFONT_DLL_DECLSPEC void alfont_textprintf_aa(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, const char *format, ...);
101ALFONT_DLL_DECLSPEC void alfont_textprintf_ex(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, int bg, const char *format, ...);
102ALFONT_DLL_DECLSPEC void alfont_textprintf_aa_ex(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, int bg, const char *format, ...);
103
104ALFONT_DLL_DECLSPEC void alfont_textprintf_centre(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, const char *format, ...);
105ALFONT_DLL_DECLSPEC void alfont_textprintf_centre_aa(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, const char *format, ...);
106ALFONT_DLL_DECLSPEC void alfont_textprintf_centre_ex(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, int bg, const char *format, ...);
107ALFONT_DLL_DECLSPEC void alfont_textprintf_centre_aa_ex(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, int bg, const char *format, ...);
108
109ALFONT_DLL_DECLSPEC void alfont_textprintf_right(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, const char *format, ...);
110ALFONT_DLL_DECLSPEC void alfont_textprintf_right_aa(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, const char *format, ...);
111ALFONT_DLL_DECLSPEC void alfont_textprintf_right_ex(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, int bg, const char *format, ...);
112ALFONT_DLL_DECLSPEC void alfont_textprintf_right_aa_ex(BITMAP *bmp, ALFONT_FONT *f, int x, int y, int color, int bg, const char *format, ...);
113
114ALFONT_DLL_DECLSPEC int alfont_text_height(ALFONT_FONT *f);
115ALFONT_DLL_DECLSPEC int alfont_text_length(ALFONT_FONT *f, const char *str);
116
117ALFONT_DLL_DECLSPEC int alfont_is_fixed_font(ALFONT_FONT *f);
118ALFONT_DLL_DECLSPEC int alfont_is_scalable_font(ALFONT_FONT *f);
119
120ALFONT_DLL_DECLSPEC const int *alfont_get_available_fixed_sizes(ALFONT_FONT *f);
121ALFONT_DLL_DECLSPEC int alfont_get_nof_available_fixed_sizes(ALFONT_FONT *f);
122
123ALFONT_DLL_DECLSPEC int alfont_get_char_extra_spacing(ALFONT_FONT *f);
124ALFONT_DLL_DECLSPEC void alfont_set_char_extra_spacing(ALFONT_FONT *f, int spacing);
125
126} // namespace AGS3
127
128#endif