1 /* ScummVM - Graphic Adventure Engine
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.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #include "graphics/font.h"
30 static const byte guifont
[] = {
33 // Character width table
34 4, 8, 6, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
35 8, 2, 1, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36 4, 3, 7, 8, 7, 7, 8, 4, 5, 5, 8, 7, 4, 7, 3, 8,
37 7, 7, 7, 7, 8, 7, 7, 7, 7, 7, 3, 4, 7, 5, 7, 7,
38 8, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 8, 7, 7,
39 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 5, 8, 5, 8, 8,
40 7, 7, 7, 6, 7, 7, 7, 7, 7, 5, 6, 7, 5, 8, 7, 7,
41 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 5, 3, 5, 7, 8,
42 7, 7, 7, 7, 7, 7, 0, 6, 7, 7, 7, 5, 5, 5, 7, 0,
43 6, 8, 8, 7, 7, 7, 7, 7, 0, 7, 7, 0, 0, 0, 0, 0,
44 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50 0, 0, 0, 0, 0, 0, 0, 0, // 0
51 1, 3, 6, 12, 24, 62, 3, 0, // 1
52 128, 192, 96, 48, 24, 124, 192, 0, // 2
53 0, 3, 62, 24, 12, 6, 3, 1, // 3
54 0, 192, 124, 24, 48, 96, 192, 128, // 4
55 0, 0, 0, 0, 0, 0, 0, 0, // 5
56 0, 0, 0, 0, 0, 0, 0, 0, // 6
57 0, 0, 0, 0, 0, 0, 0, 0, // 7
58 0, 0, 0, 0, 0, 0, 0, 0, // 8
59 0, 0, 0, 0, 0, 0, 0, 0, // 9
60 0, 0, 0, 0, 0, 0, 0, 0, // 10
61 0, 0, 0, 0, 0, 0, 0, 0, // 11
62 0, 0, 0, 0, 0, 0, 0, 0, // 12
63 0, 0, 0, 0, 0, 0, 0, 0, // 13
64 0, 0, 0, 0, 0, 0, 0, 0, // 14
65 0, 0, 0, 0, 0, 0, 0, 0, // 15
66 237, 74, 72, 0, 0, 0, 0, 0, // 16
67 128, 128, 128, 0, 0, 0, 0, 0, // 17
68 0, 0, 0, 0, 0, 0, 0, 0, // 18
69 60, 66, 153, 161, 161, 153, 66, 60, // 19
70 0, 0, 0, 0, 0, 0, 0, 0, // 20
71 0, 0, 0, 0, 0, 0, 0, 0, // 21
72 0, 0, 0, 0, 0, 0, 0, 0, // 22
73 0, 0, 0, 0, 0, 0, 0, 0, // 23
74 0, 0, 0, 0, 0, 0, 0, 0, // 24
75 0, 0, 0, 0, 0, 0, 0, 0, // 25
76 0, 0, 0, 0, 0, 0, 0, 0, // 26
77 0, 0, 0, 0, 0, 0, 0, 0, // 27
78 0, 0, 0, 0, 0, 0, 0, 0, // 28
79 0, 0, 0, 0, 0, 0, 0, 0, // 29
80 0, 0, 0, 0, 0, 0, 0, 0, // 30
81 0, 0, 0, 0, 0, 0, 0, 0, // 31
82 0, 0, 0, 0, 0, 0, 0, 0, // 32
83 96, 96, 96, 96, 0, 0, 96, 0, // 33
84 102, 102, 102, 0, 0, 0, 0, 0, // 34
85 102, 102, 255, 102, 255, 102, 102, 0, // 35
86 24, 62, 96, 60, 6, 124, 24, 0, // 36
87 98, 102, 12, 24, 48, 102, 70, 0, // 37
88 60, 102, 60, 56, 103, 102, 63, 0, // 38
89 96, 48, 16, 0, 0, 0, 0, 0, // 39
90 24, 48, 96, 96, 96, 48, 24, 0, // 40
91 96, 48, 24, 24, 24, 48, 96, 0, // 41
92 0, 102, 60, 255, 60, 102, 0, 0, // 42
93 0, 24, 24, 126, 24, 24, 0, 0, // 43
94 0, 0, 0, 0, 0, 48, 48, 96, // 44
95 0, 0, 0, 126, 0, 0, 0, 0, // 45
96 0, 0, 0, 0, 0, 96, 96, 0, // 46
97 0, 3, 6, 12, 24, 48, 96, 0, // 47
98 60, 102, 102, 102, 102, 102, 60, 0, // 48
99 24, 24, 56, 24, 24, 24, 126, 0, // 49
100 60, 102, 6, 12, 48, 96, 126, 0, // 50
101 60, 102, 6, 28, 6, 102, 60, 0, // 51
102 6, 14, 30, 102, 127, 6, 6, 0, // 52
103 126, 96, 124, 6, 6, 102, 60, 0, // 53
104 60, 102, 96, 124, 102, 102, 60, 0, // 54
105 126, 102, 12, 24, 24, 24, 24, 0, // 55
106 60, 102, 102, 60, 102, 102, 60, 0, // 56
107 60, 102, 102, 62, 6, 102, 60, 0, // 57
108 0, 0, 96, 0, 0, 96, 0, 0, // 58
109 0, 0, 48, 0, 0, 48, 48, 96, // 59
110 14, 24, 48, 96, 48, 24, 14, 0, // 60
111 0, 0, 120, 0, 120, 0, 0, 0, // 61
112 112, 24, 12, 6, 12, 24, 112, 0, // 62
113 60, 102, 6, 12, 24, 0, 24, 0, // 63
114 0, 0, 0, 255, 255, 0, 0, 0, // 64
115 24, 60, 102, 126, 102, 102, 102, 0, // 65
116 124, 102, 102, 124, 102, 102, 124, 0, // 66
117 60, 102, 96, 96, 96, 102, 60, 0, // 67
118 120, 108, 102, 102, 102, 108, 120, 0, // 68
119 126, 96, 96, 120, 96, 96, 126, 0, // 69
120 126, 96, 96, 120, 96, 96, 96, 0, // 70
121 60, 102, 96, 110, 102, 102, 60, 0, // 71
122 102, 102, 102, 126, 102, 102, 102, 0, // 72
123 120, 48, 48, 48, 48, 48, 120, 0, // 73
124 30, 12, 12, 12, 12, 108, 56, 0, // 74
125 102, 108, 120, 112, 120, 108, 102, 0, // 75
126 96, 96, 96, 96, 96, 96, 126, 0, // 76
127 99, 119, 127, 107, 99, 99, 99, 0, // 77
128 102, 118, 126, 126, 110, 102, 102, 0, // 78
129 60, 102, 102, 102, 102, 102, 60, 0, // 79
130 124, 102, 102, 124, 96, 96, 96, 0, // 80
131 60, 102, 102, 102, 102, 60, 14, 0, // 81
132 124, 102, 102, 124, 120, 108, 102, 0, // 82
133 60, 102, 96, 60, 6, 102, 60, 0, // 83
134 126, 24, 24, 24, 24, 24, 24, 0, // 84
135 102, 102, 102, 102, 102, 102, 60, 0, // 85
136 102, 102, 102, 102, 102, 60, 24, 0, // 86
137 99, 99, 99, 107, 127, 119, 99, 0, // 87
138 102, 102, 60, 24, 60, 102, 102, 0, // 88
139 102, 102, 102, 60, 24, 24, 24, 0, // 89
140 126, 6, 12, 24, 48, 96, 126, 0, // 90
141 120, 96, 96, 96, 96, 96, 120, 0, // 91
142 3, 6, 12, 24, 48, 96, 192, 0, // 92
143 120, 24, 24, 24, 24, 24, 120, 0, // 93
144 0, 0, 0, 0, 0, 219, 219, 0, // 94
145 0, 0, 0, 0, 0, 0, 0, 255, // 95
146 102, 102, 102, 0, 0, 0, 0, 0, // 96
147 0, 0, 60, 6, 62, 102, 62, 0, // 97
148 0, 96, 96, 124, 102, 102, 124, 0, // 98
149 0, 0, 60, 96, 96, 96, 60, 0, // 99
150 0, 6, 6, 62, 102, 102, 62, 0, // 100
151 0, 0, 60, 102, 126, 96, 60, 0, // 101
152 0, 14, 24, 62, 24, 24, 24, 0, // 102
153 0, 0, 62, 102, 102, 62, 6, 124, // 103
154 0, 96, 96, 124, 102, 102, 102, 0, // 104
155 0, 48, 0, 112, 48, 48, 120, 0, // 105
156 0, 12, 0, 12, 12, 12, 12, 120, // 106
157 0, 96, 96, 108, 120, 108, 102, 0, // 107
158 0, 112, 48, 48, 48, 48, 120, 0, // 108
159 0, 0, 102, 127, 127, 107, 99, 0, // 109
160 0, 0, 124, 102, 102, 102, 102, 0, // 110
161 0, 0, 60, 102, 102, 102, 60, 0, // 111
162 0, 0, 124, 102, 102, 124, 96, 96, // 112
163 0, 0, 62, 102, 102, 62, 6, 6, // 113
164 0, 0, 124, 102, 96, 96, 96, 0, // 114
165 0, 0, 62, 96, 60, 6, 124, 0, // 115
166 0, 24, 126, 24, 24, 24, 14, 0, // 116
167 0, 0, 102, 102, 102, 102, 62, 0, // 117
168 0, 0, 102, 102, 102, 60, 24, 0, // 118
169 0, 0, 99, 107, 127, 62, 54, 0, // 119
170 0, 0, 102, 60, 24, 60, 102, 0, // 120
171 0, 0, 102, 102, 102, 62, 12, 120, // 121
172 0, 0, 126, 12, 24, 48, 126, 0, // 122
173 24, 48, 48, 96, 48, 48, 24, 0, // 123
174 96, 96, 96, 0, 96, 96, 96, 0, // 124
175 96, 48, 48, 24, 48, 48, 96, 0, // 125
176 0, 0, 97, 153, 134, 0, 0, 0, // 126
177 8, 12, 14, 255, 255, 14, 12, 8, // 127
178 60, 102, 96, 96, 102, 60, 24, 56, // 128
179 102, 0, 102, 102, 102, 102, 62, 0, // 129
180 12, 24, 60, 102, 126, 96, 60, 0, // 130
181 24, 36, 60, 6, 62, 102, 62, 0, // 131
182 102, 0, 60, 6, 62, 102, 62, 0, // 132
183 48, 24, 60, 6, 62, 102, 62, 0, // 133
184 0, 0, 0, 0, 0, 0, 0, 0, // 134
185 0, 60, 96, 96, 96, 60, 24, 56, // 135
186 24, 36, 60, 102, 126, 96, 60, 0, // 136
187 102, 0, 60, 102, 126, 96, 60, 0, // 137
188 48, 24, 60, 102, 126, 96, 60, 0, // 138
189 0, 216, 0, 112, 48, 48, 120, 0, // 139
190 48, 72, 0, 112, 48, 48, 120, 0, // 140
191 96, 48, 0, 112, 48, 48, 120, 0, // 141
192 102, 24, 60, 102, 126, 102, 102, 0, // 142
193 0, 0, 0, 0, 0, 0, 0, 0, // 143
194 24, 48, 124, 96, 120, 96, 124, 0, // 144
195 0, 0, 108, 26, 126, 216, 110, 0, // 145
196 30, 40, 40, 126, 72, 136, 142, 0, // 146
197 24, 36, 60, 102, 102, 102, 60, 0, // 147
198 102, 0, 60, 102, 102, 102, 60, 0, // 148
199 48, 24, 60, 102, 102, 102, 60, 0, // 149
200 24, 36, 0, 102, 102, 102, 62, 0, // 150
201 48, 24, 102, 102, 102, 102, 62, 0, // 151
202 0, 0, 0, 0, 0, 0, 0, 0, // 152
203 102, 60, 102, 102, 102, 102, 60, 0, // 153
204 102, 0, 102, 102, 102, 102, 60, 0, // 154
205 0, 0, 0, 0, 0, 0, 0, 0, // 155
206 0, 0, 0, 0, 0, 0, 0, 0, // 156
207 0, 0, 0, 0, 0, 0, 0, 0, // 157
208 0, 0, 0, 0, 0, 0, 0, 0, // 158
209 0, 0, 0, 0, 0, 0, 0, 0, // 159
210 12, 24, 60, 6, 62, 102, 62, 0, // 160
211 0, 0, 0, 0, 0, 0, 0, 0, // 161
212 0, 0, 0, 0, 0, 0, 0, 0, // 162
213 0, 0, 0, 0, 0, 0, 0, 0, // 163
214 0, 0, 0, 0, 0, 0, 0, 0, // 164
215 0, 0, 0, 0, 0, 0, 0, 0, // 165
216 0, 0, 0, 0, 0, 0, 0, 0, // 166
217 0, 0, 0, 0, 0, 0, 0, 0, // 167
218 0, 0, 0, 0, 0, 0, 0, 0, // 168
219 0, 0, 0, 0, 0, 0, 0, 0, // 169
220 0, 0, 0, 0, 0, 0, 0, 0, // 170
221 0, 0, 0, 0, 0, 0, 0, 0, // 171
222 0, 0, 0, 0, 0, 0, 0, 0, // 172
223 0, 0, 0, 0, 0, 0, 0, 0, // 173
224 0, 0, 0, 0, 0, 0, 0, 0, // 174
225 0, 0, 0, 0, 0, 0, 0, 0, // 175
226 0, 0, 0, 0, 0, 0, 0, 0, // 176
227 0, 0, 0, 0, 0, 0, 0, 0, // 177
228 0, 0, 0, 0, 0, 0, 0, 0, // 178
229 0, 0, 0, 0, 0, 0, 0, 0, // 179
230 0, 0, 0, 0, 0, 0, 0, 0, // 180
231 0, 0, 0, 0, 0, 0, 0, 0, // 181
232 0, 0, 0, 0, 0, 0, 0, 0, // 182
233 0, 0, 0, 0, 0, 0, 0, 0, // 183
234 0, 0, 0, 0, 0, 0, 0, 0, // 184
235 0, 0, 0, 0, 0, 0, 0, 0, // 185
236 0, 0, 0, 0, 0, 0, 0, 0, // 186
237 0, 0, 0, 0, 0, 0, 0, 0, // 187
238 0, 0, 0, 0, 0, 0, 0, 0, // 188
239 0, 0, 0, 0, 0, 0, 0, 0, // 189
240 0, 0, 0, 0, 0, 0, 0, 0, // 190
241 0, 0, 0, 0, 0, 0, 0, 0, // 191
242 0, 0, 0, 0, 0, 0, 0, 0, // 192
243 0, 0, 0, 0, 0, 0, 0, 0, // 193
244 0, 0, 0, 0, 0, 0, 0, 0, // 194
245 0, 0, 0, 0, 0, 0, 0, 0, // 195
246 0, 0, 0, 0, 0, 0, 0, 0, // 196
247 0, 0, 0, 0, 0, 0, 0, 0, // 197
248 0, 0, 0, 0, 0, 0, 0, 0, // 198
249 0, 0, 0, 0, 0, 0, 0, 0, // 199
250 0, 0, 0, 0, 0, 0, 0, 0, // 200
251 0, 0, 0, 0, 0, 0, 0, 0, // 201
252 0, 0, 0, 0, 0, 0, 0, 0, // 202
253 0, 0, 0, 0, 0, 0, 0, 0, // 203
254 0, 0, 0, 0, 0, 0, 0, 0, // 204
255 0, 0, 0, 0, 0, 0, 0, 0, // 205
256 0, 0, 0, 0, 0, 0, 0, 0, // 206
257 0, 0, 0, 0, 0, 0, 0, 0, // 207
258 0, 0, 0, 0, 0, 0, 0, 0, // 208
259 0, 0, 0, 0, 0, 0, 0, 0, // 209
260 0, 0, 0, 0, 0, 0, 0, 0, // 210
261 0, 0, 0, 0, 0, 0, 0, 0, // 211
262 0, 0, 0, 0, 0, 0, 0, 0, // 212
263 0, 0, 0, 0, 0, 0, 0, 0, // 213
264 0, 0, 0, 0, 0, 0, 0, 0, // 214
265 0, 0, 0, 0, 0, 0, 0, 0, // 215
266 0, 0, 0, 0, 0, 0, 0, 0, // 216
267 0, 0, 0, 0, 0, 0, 0, 0, // 217
268 0, 0, 0, 0, 0, 0, 0, 0, // 218
269 0, 0, 0, 0, 0, 0, 0, 0, // 219
270 0, 0, 0, 0, 0, 0, 0, 0, // 220
271 0, 0, 0, 0, 0, 0, 0, 0, // 221
272 0, 0, 0, 0, 0, 0, 0, 0, // 222
273 0, 0, 0, 0, 0, 0, 0, 0, // 223
274 0, 0, 0, 0, 0, 0, 0, 0, // 224
275 28, 54, 54, 124, 102, 102, 124, 64, // 225
279 int ScummFont::getCharWidth(byte chr
) const {
280 return guifont
[chr
+6];
283 void ScummFont::drawChar(Surface
*dst
, byte chr
, int tx
, int ty
, uint32 color
) const {
285 byte
*ptr
= (byte
*)dst
->getBasePtr(tx
, ty
);
287 const byte
*tmp
= guifont
+ 6 + guifont
[4] + chr
* 8;
291 for (int y
= 0; y
< 8; y
++) {
292 if (ty
+ y
< 0 || ty
+ y
>= dst
->h
)
294 for (int x
= 0; x
< 8; x
++) {
295 if (tx
+ x
< 0 || tx
+ x
>= dst
->w
)
303 c
= ((buffer
& mask
) != 0);
305 if (dst
->bytesPerPixel
== 1)
307 else if (dst
->bytesPerPixel
== 2)
308 ((uint16
*)ptr
)[x
] = color
;
315 } // End of namespace Graphics