[GDI32_APITEST] Add GetTextMetrics tests to gdi32_apitest (#307)
[reactos.git] / modules / rostests / apitests / gdi32 / GetTextMetrics.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Test for GetTextMetrics and GetTextExtentPoint32
5 * COPYRIGHT: Copyright 2018 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8 #include "precomp.h"
9
10 /* #define EMIT_TESTCASES */
11
12 typedef struct TEST_ENTRY
13 {
14 int line;
15 LONG lfHeight;
16 LONG lfWidth;
17 LONG cxText;
18 LONG cyText;
19 LONG tmHeight;
20 LONG tmAscent;
21 LONG tmDescent;
22 LONG tmInternalLeading;
23 LONG tmExternalLeading;
24 } TEST_ENTRY;
25
26 #ifdef EMIT_TESTCASES
27 static const TEST_ENTRY g_test_entries[] =
28 {
29 { __LINE__, 400, 0 },
30 { __LINE__, 300, 0 },
31 { __LINE__, 200, 0 },
32 { __LINE__, 100, 0 },
33 { __LINE__, 64, 0 },
34 { __LINE__, 32, 0 },
35 { __LINE__, 16, 0 },
36 { __LINE__, 15, 0 },
37 { __LINE__, 14, 0 },
38 { __LINE__, 13, 0 },
39 { __LINE__, 12, 0 },
40 { __LINE__, 11, 0 },
41 { __LINE__, 10, 0 },
42 { __LINE__, 9, 0 },
43 { __LINE__, 8, 0 },
44 { __LINE__, 7, 0 },
45 { __LINE__, 6, 0 },
46 { __LINE__, 5, 0 },
47 { __LINE__, 4, 0 },
48 { __LINE__, 3, 0 },
49 { __LINE__, 2, 0 },
50 { __LINE__, 1, 0 },
51 { __LINE__, 0, 0 },
52 { __LINE__, -1, 0 },
53 { __LINE__, -2, 0 },
54 { __LINE__, -3, 0 },
55 { __LINE__, -4, 0 },
56 { __LINE__, -5, 0 },
57 { __LINE__, -6, 0 },
58 { __LINE__, -7, 0 },
59 { __LINE__, -8, 0 },
60 { __LINE__, -9, 0 },
61 { __LINE__, -10, 0 },
62 { __LINE__, -11, 0 },
63 { __LINE__, -12, 0 },
64 { __LINE__, -13, 0 },
65 { __LINE__, -14, 0 },
66 { __LINE__, -15, 0 },
67 { __LINE__, -16, 0 },
68 { __LINE__, -32, 0 },
69 { __LINE__, -64, 0 },
70 { __LINE__, -100, 0 },
71 { __LINE__, -200, 0 },
72 { __LINE__, -300, 0 },
73 { __LINE__, -400, 0 },
74 };
75 #define g_test_entry_count _countof(g_test_entries)
76 #else
77 static const TEST_ENTRY g_FREEMONO[] =
78 {
79 { __LINE__, 400, 0, 3600, 400, 400, 320, 80, 0, 0 },
80 { __LINE__, 300, 0, 2700, 300, 300, 240, 60, 0, 0 },
81 { __LINE__, 200, 0, 1800, 200, 200, 160, 40, 0, 0 },
82 { __LINE__, 100, 0, 900, 100, 100, 80, 20, 0, 0 },
83 { __LINE__, 64, 0, 570, 64, 64, 51, 13, 0, 0 },
84 { __LINE__, 32, 0, 285, 32, 32, 26, 6, 0, 0 },
85 { __LINE__, 16, 0, 150, 16, 16, 13, 3, 0, 0 },
86 { __LINE__, 15, 0, 135, 15, 15, 12, 3, 0, 0 },
87 { __LINE__, 14, 0, 120, 14, 14, 11, 3, 0, 0 },
88 { __LINE__, 13, 0, 120, 13, 13, 10, 3, 0, 0 },
89 { __LINE__, 12, 0, 105, 12, 12, 10, 2, 0, 0 },
90 { __LINE__, 11, 0, 105, 11, 11, 9, 2, 0, 0 },
91 { __LINE__, 10, 0, 90, 10, 10, 8, 2, 0, 0 },
92 { __LINE__, 9, 0, 77, 9, 9, 7, 2, 0, 0 },
93 { __LINE__, 8, 0, 75, 8, 8, 6, 2, 0, 0 },
94 { __LINE__, 7, 0, 60, 7, 7, 6, 1, 0, 0 },
95 { __LINE__, 6, 0, 60, 6, 6, 5, 1, 0, 0 },
96 { __LINE__, 5, 0, 45, 5, 5, 4, 1, 0, 0 },
97 { __LINE__, 4, 0, 30, 4, 4, 3, 1, 0, 0 },
98 { __LINE__, 3, 0, 30, 3, 3, 2, 1, 0, 0 },
99 { __LINE__, 2, 0, 15, 2, 2, 2, 0, 0, 0 },
100 { __LINE__, 1, 0, 15, 2, 2, 2, 0, 0, 0 },
101 { __LINE__, 0, 0, -165, -18, -18, -14, -4, 0, 0 },
102 { __LINE__, -1, 0, 15, 2, 2, 2, 0, 0, 0 },
103 { __LINE__, -2, 0, 15, 2, 2, 2, 0, 0, 0 },
104 { __LINE__, -3, 0, 30, 3, 3, 2, 1, 0, 0 },
105 { __LINE__, -4, 0, 30, 4, 4, 3, 1, 0, 0 },
106 { __LINE__, -5, 0, 45, 5, 5, 4, 1, 0, 0 },
107 { __LINE__, -6, 0, 60, 6, 6, 5, 1, 0, 0 },
108 { __LINE__, -7, 0, 60, 7, 7, 6, 1, 0, 0 },
109 { __LINE__, -8, 0, 75, 8, 8, 6, 2, 0, 0 },
110 { __LINE__, -9, 0, 77, 9, 9, 7, 2, 0, 0 },
111 { __LINE__, -10, 0, 90, 10, 10, 8, 2, 0, 0 },
112 { __LINE__, -11, 0, 105, 11, 11, 9, 2, 0, 0 },
113 { __LINE__, -12, 0, 105, 12, 12, 10, 2, 0, 0 },
114 { __LINE__, -13, 0, 120, 13, 13, 10, 3, 0, 0 },
115 { __LINE__, -14, 0, 120, 14, 14, 11, 3, 0, 0 },
116 { __LINE__, -15, 0, 135, 15, 15, 12, 3, 0, 0 },
117 { __LINE__, -16, 0, 150, 16, 16, 13, 3, 0, 0 },
118 { __LINE__, -32, 0, 285, 32, 32, 26, 6, 0, 0 },
119 { __LINE__, -64, 0, 570, 64, 64, 51, 13, 0, 0 },
120 { __LINE__, -100, 0, 900, 100, 100, 80, 20, 0, 0 },
121 { __LINE__, -200, 0, 1800, 200, 200, 160, 40, 0, 0 },
122 { __LINE__, -300, 0, 2700, 300, 300, 240, 60, 0, 0 },
123 { __LINE__, -400, 0, 3600, 400, 400, 320, 80, 0, 0 },
124 };
125 #define g_FREEMONO_count _countof(g_FREEMONO)
126
127 static const TEST_ENTRY g_DEJAVUSERIF[] =
128 {
129 { __LINE__, 400, 0, 2323, 400, 400, 319, 81, 56, 0 },
130 { __LINE__, 300, 0, 1743, 300, 300, 239, 61, 42, 0 },
131 { __LINE__, 200, 0, 1162, 200, 200, 159, 41, 28, 0 },
132 { __LINE__, 100, 0, 580, 100, 100, 80, 20, 14, 0 },
133 { __LINE__, 64, 0, 370, 64, 64, 51, 13, 9, 0 },
134 { __LINE__, 32, 0, 190, 32, 32, 26, 6, 4, 0 },
135 { __LINE__, 16, 0, 91, 16, 16, 13, 3, 2, 0 },
136 { __LINE__, 15, 0, 84, 15, 15, 12, 3, 2, 0 },
137 { __LINE__, 14, 0, 82, 14, 14, 11, 3, 2, 0 },
138 { __LINE__, 13, 0, 77, 13, 13, 10, 3, 2, 0 },
139 { __LINE__, 12, 0, 66, 12, 12, 10, 2, 2, 0 },
140 { __LINE__, 11, 0, 63, 11, 11, 9, 2, 2, 0 },
141 { __LINE__, 10, 0, 63, 10, 10, 8, 2, 1, 0 },
142 { __LINE__, 9, 0, 56, 9, 9, 7, 2, 1, 0 },
143 { __LINE__, 8, 0, 49, 8, 8, 6, 2, 1, 0 },
144 { __LINE__, 7, 0, 42, 7, 7, 6, 1, 1, 0 },
145 { __LINE__, 6, 0, 36, 6, 6, 5, 1, 1, 0 },
146 { __LINE__, 5, 0, 26, 5, 5, 4, 1, 1, 0 },
147 { __LINE__, 4, 0, 22, 4, 4, 3, 1, 1, 0 },
148 { __LINE__, 3, 0, 22, 3, 3, 2, 1, 0, 0 },
149 { __LINE__, 2, 0, 15, 2, 2, 2, 0, 0, 0 },
150 { __LINE__, 1, 0, 15, 2, 2, 2, 0, 0, 0 },
151 { __LINE__, 0, 0, -125, -21, -21, -17, -4, -3, 0 },
152 { __LINE__, -1, 0, 15, 2, 2, 2, 0, 0, 0 },
153 { __LINE__, -2, 0, 15, 2, 2, 2, 0, 0, 0 },
154 { __LINE__, -3, 0, 22, 4, 4, 3, 1, 1, 0 },
155 { __LINE__, -4, 0, 26, 5, 5, 4, 1, 1, 0 },
156 { __LINE__, -5, 0, 36, 6, 6, 5, 1, 1, 0 },
157 { __LINE__, -6, 0, 42, 7, 7, 6, 1, 1, 0 },
158 { __LINE__, -7, 0, 49, 8, 8, 6, 2, 1, 0 },
159 { __LINE__, -8, 0, 56, 9, 9, 7, 2, 1, 0 },
160 { __LINE__, -9, 0, 63, 10, 10, 8, 2, 1, 0 },
161 { __LINE__, -10, 0, 66, 11, 11, 9, 2, 1, 0 },
162 { __LINE__, -11, 0, 77, 13, 13, 10, 3, 2, 0 },
163 { __LINE__, -12, 0, 82, 14, 14, 11, 3, 2, 0 },
164 { __LINE__, -13, 0, 84, 15, 15, 12, 3, 2, 0 },
165 { __LINE__, -14, 0, 91, 16, 16, 13, 3, 2, 0 },
166 { __LINE__, -15, 0, 103, 18, 18, 14, 4, 3, 0 },
167 { __LINE__, -16, 0, 114, 19, 19, 15, 4, 3, 0 },
168 { __LINE__, -32, 0, 214, 38, 38, 30, 8, 6, 0 },
169 { __LINE__, -64, 0, 431, 74, 74, 59, 15, 10, 0 },
170 { __LINE__, -100, 0, 674, 117, 117, 93, 24, 17, 0 },
171 { __LINE__, -200, 0, 1352, 233, 233, 186, 47, 33, 0 },
172 { __LINE__, -300, 0, 2026, 349, 349, 278, 71, 49, 0 },
173 { __LINE__, -400, 0, 2702, 465, 465, 371, 94, 65, 0 },
174 };
175 #define g_DEJAVUSERIF_count _countof(g_DEJAVUSERIF)
176
177 static const TEST_ENTRY g_DEJAVUSANS[] =
178 {
179 { __LINE__, 400, 0, 2286, 400, 400, 319, 81, 56, 0 },
180 { __LINE__, 300, 0, 1715, 300, 300, 239, 61, 42, 0 },
181 { __LINE__, 200, 0, 1145, 200, 200, 159, 41, 28, 0 },
182 { __LINE__, 100, 0, 573, 100, 100, 80, 20, 14, 0 },
183 { __LINE__, 64, 0, 366, 64, 64, 51, 13, 9, 0 },
184 { __LINE__, 32, 0, 188, 32, 32, 26, 6, 4, 0 },
185 { __LINE__, 16, 0, 91, 16, 16, 13, 3, 2, 0 },
186 { __LINE__, 15, 0, 84, 15, 15, 12, 3, 2, 0 },
187 { __LINE__, 14, 0, 84, 14, 14, 11, 3, 2, 0 },
188 { __LINE__, 13, 0, 79, 13, 13, 10, 3, 2, 0 },
189 { __LINE__, 12, 0, 62, 12, 12, 10, 2, 2, 0 },
190 { __LINE__, 11, 0, 64, 11, 11, 9, 2, 2, 0 },
191 { __LINE__, 10, 0, 64, 10, 10, 8, 2, 1, 0 },
192 { __LINE__, 9, 0, 54, 9, 9, 7, 2, 1, 0 },
193 { __LINE__, 8, 0, 46, 8, 8, 6, 2, 1, 0 },
194 { __LINE__, 7, 0, 41, 7, 7, 6, 1, 1, 0 },
195 { __LINE__, 6, 0, 35, 6, 6, 5, 1, 1, 0 },
196 { __LINE__, 5, 0, 25, 5, 5, 4, 1, 1, 0 },
197 { __LINE__, 4, 0, 22, 4, 4, 3, 1, 1, 0 },
198 { __LINE__, 3, 0, 22, 3, 3, 2, 1, 0, 0 },
199 { __LINE__, 2, 0, 15, 2, 2, 2, 0, 0, 0 },
200 { __LINE__, 1, 0, 15, 2, 2, 2, 0, 0, 0 },
201 { __LINE__, 0, 0, -116, -21, -21, -17, -4, -3, 0 },
202 { __LINE__, -1, 0, 15, 2, 2, 2, 0, 0, 0 },
203 { __LINE__, -2, 0, 15, 2, 2, 2, 0, 0, 0 },
204 { __LINE__, -3, 0, 22, 4, 4, 3, 1, 1, 0 },
205 { __LINE__, -4, 0, 25, 5, 5, 4, 1, 1, 0 },
206 { __LINE__, -5, 0, 35, 6, 6, 5, 1, 1, 0 },
207 { __LINE__, -6, 0, 41, 7, 7, 6, 1, 1, 0 },
208 { __LINE__, -7, 0, 46, 8, 8, 6, 2, 1, 0 },
209 { __LINE__, -8, 0, 54, 9, 9, 7, 2, 1, 0 },
210 { __LINE__, -9, 0, 64, 10, 10, 8, 2, 1, 0 },
211 { __LINE__, -10, 0, 62, 11, 11, 9, 2, 1, 0 },
212 { __LINE__, -11, 0, 79, 13, 13, 10, 3, 2, 0 },
213 { __LINE__, -12, 0, 84, 14, 14, 11, 3, 2, 0 },
214 { __LINE__, -13, 0, 84, 15, 15, 12, 3, 2, 0 },
215 { __LINE__, -14, 0, 91, 16, 16, 13, 3, 2, 0 },
216 { __LINE__, -15, 0, 98, 18, 18, 14, 4, 3, 0 },
217 { __LINE__, -16, 0, 102, 19, 19, 15, 4, 3, 0 },
218 { __LINE__, -32, 0, 215, 38, 38, 30, 8, 6, 0 },
219 { __LINE__, -64, 0, 423, 74, 74, 59, 15, 10, 0 },
220 { __LINE__, -100, 0, 665, 117, 117, 93, 24, 17, 0 },
221 { __LINE__, -200, 0, 1331, 233, 233, 186, 47, 33, 0 },
222 { __LINE__, -300, 0, 1992, 349, 349, 278, 71, 49, 0 },
223 { __LINE__, -400, 0, 2657, 465, 465, 371, 94, 65, 0 },
224 };
225 #define g_DEJAVUSANS_count _countof(g_DEJAVUSANS)
226
227 static const TEST_ENTRY g_UBUNTUMONO[] =
228 {
229 { __LINE__, 400, 0, 3000, 400, 400, 332, 68, 0, 0 },
230 { __LINE__, 300, 0, 2250, 300, 300, 249, 51, 0, 0 },
231 { __LINE__, 200, 0, 1500, 200, 200, 166, 34, 1, 0 },
232 { __LINE__, 100, 0, 735, 100, 100, 83, 17, 2, 0 },
233 { __LINE__, 64, 0, 465, 63, 63, 53, 10, 2, 0 },
234 { __LINE__, 32, 0, 240, 31, 31, 26, 5, 0, 0 },
235 { __LINE__, 16, 0, 105, 16, 16, 13, 3, 3, 0 },
236 { __LINE__, 15, 0, 90, 15, 15, 12, 3, 4, 0 },
237 { __LINE__, 14, 0, 75, 14, 14, 11, 3, 5, 0 },
238 { __LINE__, 13, 0, 60, 13, 13, 10, 3, 5, 0 },
239 { __LINE__, 12, 0, 60, 12, 12, 10, 2, 5, 0 },
240 { __LINE__, 11, 0, 60, 11, 11, 9, 2, 4, 0 },
241 { __LINE__, 10, 0, 60, 10, 10, 8, 2, 3, 0 },
242 { __LINE__, 9, 0, 60, 9, 9, 7, 2, 2, 0 },
243 { __LINE__, 8, 0, 60, 8, 8, 7, 1, 1, 0 },
244 { __LINE__, 7, 0, 60, 7, 7, 6, 1, 0, 0 },
245 { __LINE__, 6, 0, 45, 6, 6, 5, 1, 0, 0 },
246 { __LINE__, 5, 0, 45, 5, 5, 4, 1, 0, 0 },
247 { __LINE__, 4, 0, 30, 4, 4, 3, 1, 0, 0 },
248 { __LINE__, 3, 0, 30, 3, 3, 2, 1, 0, 0 },
249 { __LINE__, 2, 0, 15, 2, 2, 2, 0, 0, 0 },
250 { __LINE__, 1, 0, 15, 2, 2, 2, 0, 0, 0 },
251 { __LINE__, 0, 0, -135, -19, -19, -16, -3, -1, 0 },
252 { __LINE__, -1, 0, 15, 2, 2, 2, 0, 0, 0 },
253 { __LINE__, -2, 0, 15, 2, 2, 2, 0, 0, 0 },
254 { __LINE__, -3, 0, 30, 3, 3, 2, 1, 0, 0 },
255 { __LINE__, -4, 0, 30, 4, 4, 3, 1, 0, 0 },
256 { __LINE__, -5, 0, 45, 5, 5, 4, 1, 0, 0 },
257 { __LINE__, -6, 0, 45, 6, 6, 5, 1, 0, 0 },
258 { __LINE__, -7, 0, 60, 7, 7, 6, 1, 0, 0 },
259 { __LINE__, -8, 0, 60, 13, 13, 10, 3, 5, 0 },
260 { __LINE__, -9, 0, 75, 14, 14, 11, 3, 5, 0 },
261 { __LINE__, -10, 0, 75, 14, 14, 11, 3, 4, 0 },
262 { __LINE__, -11, 0, 90, 15, 15, 12, 3, 4, 0 },
263 { __LINE__, -12, 0, 90, 15, 15, 12, 3, 3, 0 },
264 { __LINE__, -13, 0, 105, 16, 16, 13, 3, 3, 0 },
265 { __LINE__, -14, 0, 105, 17, 17, 14, 3, 3, 0 },
266 { __LINE__, -15, 0, 105, 17, 17, 14, 3, 2, 0 },
267 { __LINE__, -16, 0, 120, 18, 18, 15, 3, 2, 0 },
268 { __LINE__, -32, 0, 240, 33, 33, 28, 5, 1, 0 },
269 { __LINE__, -64, 0, 480, 66, 66, 55, 11, 2, 0 },
270 { __LINE__, -100, 0, 750, 101, 101, 84, 17, 1, 0 },
271 { __LINE__, -200, 0, 1500, 201, 201, 167, 34, 1, 0 },
272 { __LINE__, -300, 0, 2250, 300, 300, 249, 51, 0, 0 },
273 { __LINE__, -400, 0, 3000, 400, 400, 332, 68, 0, 0 },
274 };
275 #define g_UBUNTUMONO_count _countof(g_UBUNTUMONO)
276
277 static const TEST_ENTRY g_MSGOTHIC[] =
278 {
279 { __LINE__, 400, 0, 3000, 400, 400, 344, 56, 0, 0 },
280 { __LINE__, 300, 0, 2250, 300, 300, 258, 42, 0, 0 },
281 { __LINE__, 200, 0, 1500, 200, 200, 172, 28, 0, 0 },
282 { __LINE__, 100, 0, 750, 100, 100, 86, 14, 0, 0 },
283 { __LINE__, 64, 0, 480, 64, 64, 55, 9, 0, 0 },
284 { __LINE__, 32, 0, 240, 33, 33, 28, 5, 1, 0 },
285 { __LINE__, 16, 0, 120, 16, 16, 14, 2, 0, 0 },
286 { __LINE__, 15, 0, 120, 15, 15, 13, 2, 0, 0 },
287 { __LINE__, 14, 0, 105, 14, 14, 12, 2, 0, 0 },
288 { __LINE__, 13, 0, 105, 13, 13, 11, 2, 0, 0 },
289 { __LINE__, 12, 0, 90, 12, 12, 10, 2, 0, 0 },
290 { __LINE__, 11, 0, 90, 11, 11, 9, 2, 0, 0 },
291 { __LINE__, 10, 0, 75, 10, 10, 9, 1, 0, 0 },
292 { __LINE__, 9, 0, 75, 9, 9, 8, 1, 0, 0 },
293 { __LINE__, 8, 0, 60, 8, 8, 7, 1, 0, 0 },
294 { __LINE__, 7, 0, 60, 7, 7, 6, 1, 0, 0 },
295 { __LINE__, 6, 0, 45, 6, 6, 5, 1, 0, 0 },
296 { __LINE__, 5, 0, 45, 5, 5, 4, 1, 0, 0 },
297 { __LINE__, 4, 0, 30, 4, 4, 3, 1, 0, 0 },
298 { __LINE__, 3, 0, 30, 3, 3, 3, 0, 0, 0 },
299 { __LINE__, 2, 0, 15, 2, 2, 2, 0, 0, 0 },
300 { __LINE__, 1, 0, 15, 2, 2, 2, 0, 0, 0 },
301 { __LINE__, 0, 0, -135, -18, -18, -15, -3, 0, 0 },
302 { __LINE__, -1, 0, 15, 2, 2, 2, 0, 0, 0 },
303 { __LINE__, -2, 0, 15, 2, 2, 2, 0, 0, 0 },
304 { __LINE__, -3, 0, 30, 3, 3, 3, 0, 0, 0 },
305 { __LINE__, -4, 0, 30, 4, 4, 3, 1, 0, 0 },
306 { __LINE__, -5, 0, 45, 5, 5, 4, 1, 0, 0 },
307 { __LINE__, -6, 0, 45, 6, 6, 5, 1, 0, 0 },
308 { __LINE__, -7, 0, 60, 7, 7, 6, 1, 0, 0 },
309 { __LINE__, -8, 0, 60, 8, 8, 7, 1, 0, 0 },
310 { __LINE__, -9, 0, 75, 9, 9, 8, 1, 0, 0 },
311 { __LINE__, -10, 0, 75, 10, 10, 9, 1, 0, 0 },
312 { __LINE__, -11, 0, 90, 11, 11, 9, 2, 0, 0 },
313 { __LINE__, -12, 0, 90, 12, 12, 10, 2, 0, 0 },
314 { __LINE__, -13, 0, 105, 13, 13, 11, 2, 0, 0 },
315 { __LINE__, -14, 0, 105, 14, 14, 12, 2, 0, 0 },
316 { __LINE__, -15, 0, 120, 15, 15, 13, 2, 0, 0 },
317 { __LINE__, -16, 0, 120, 16, 16, 14, 2, 0, 0 },
318 { __LINE__, -32, 0, 240, 33, 33, 28, 5, 1, 0 },
319 { __LINE__, -64, 0, 480, 64, 64, 55, 9, 0, 0 },
320 { __LINE__, -100, 0, 750, 100, 100, 86, 14, 0, 0 },
321 { __LINE__, -200, 0, 1500, 200, 200, 172, 28, 0, 0 },
322 { __LINE__, -300, 0, 2250, 300, 300, 258, 42, 0, 0 },
323 { __LINE__, -400, 0, 3000, 400, 400, 344, 56, 0, 0 },
324 };
325 #define g_MSGOTHIC_count _countof(g_MSGOTHIC)
326
327 static const TEST_ENTRY g_MSMINCHO[] =
328 {
329 { __LINE__, 400, 0, 3000, 400, 400, 344, 56, 0, 0 },
330 { __LINE__, 300, 0, 2250, 300, 300, 258, 42, 0, 0 },
331 { __LINE__, 200, 0, 1500, 200, 200, 172, 28, 0, 0 },
332 { __LINE__, 100, 0, 750, 100, 100, 86, 14, 0, 0 },
333 { __LINE__, 64, 0, 480, 64, 64, 55, 9, 0, 0 },
334 { __LINE__, 32, 0, 240, 33, 33, 28, 5, 1, 0 },
335 { __LINE__, 16, 0, 120, 16, 16, 14, 2, 0, 0 },
336 { __LINE__, 15, 0, 120, 15, 15, 13, 2, 0, 0 },
337 { __LINE__, 14, 0, 105, 14, 14, 12, 2, 0, 0 },
338 { __LINE__, 13, 0, 105, 13, 13, 11, 2, 0, 0 },
339 { __LINE__, 12, 0, 90, 12, 12, 10, 2, 0, 0 },
340 { __LINE__, 11, 0, 90, 11, 11, 9, 2, 0, 0 },
341 { __LINE__, 10, 0, 75, 10, 10, 9, 1, 0, 0 },
342 { __LINE__, 9, 0, 75, 9, 9, 8, 1, 0, 0 },
343 { __LINE__, 8, 0, 60, 8, 8, 7, 1, 0, 0 },
344 { __LINE__, 7, 0, 60, 7, 7, 6, 1, 0, 0 },
345 { __LINE__, 6, 0, 45, 6, 6, 5, 1, 0, 0 },
346 { __LINE__, 5, 0, 45, 5, 5, 4, 1, 0, 0 },
347 { __LINE__, 4, 0, 30, 4, 4, 3, 1, 0, 0 },
348 { __LINE__, 3, 0, 30, 3, 3, 3, 0, 0, 0 },
349 { __LINE__, 2, 0, 15, 2, 2, 2, 0, 0, 0 },
350 { __LINE__, 1, 0, 15, 2, 2, 2, 0, 0, 0 },
351 { __LINE__, 0, 0, -135, -18, -18, -15, -3, 0, 0 },
352 { __LINE__, -1, 0, 15, 2, 2, 2, 0, 0, 0 },
353 { __LINE__, -2, 0, 15, 2, 2, 2, 0, 0, 0 },
354 { __LINE__, -3, 0, 30, 3, 3, 3, 0, 0, 0 },
355 { __LINE__, -4, 0, 30, 4, 4, 3, 1, 0, 0 },
356 { __LINE__, -5, 0, 45, 5, 5, 4, 1, 0, 0 },
357 { __LINE__, -6, 0, 45, 6, 6, 5, 1, 0, 0 },
358 { __LINE__, -7, 0, 60, 7, 7, 6, 1, 0, 0 },
359 { __LINE__, -8, 0, 60, 8, 8, 7, 1, 0, 0 },
360 { __LINE__, -9, 0, 75, 9, 9, 8, 1, 0, 0 },
361 { __LINE__, -10, 0, 75, 10, 10, 9, 1, 0, 0 },
362 { __LINE__, -11, 0, 90, 11, 11, 9, 2, 0, 0 },
363 { __LINE__, -12, 0, 90, 12, 12, 10, 2, 0, 0 },
364 { __LINE__, -13, 0, 105, 13, 13, 11, 2, 0, 0 },
365 { __LINE__, -14, 0, 105, 14, 14, 12, 2, 0, 0 },
366 { __LINE__, -15, 0, 120, 15, 15, 13, 2, 0, 0 },
367 { __LINE__, -16, 0, 120, 16, 16, 14, 2, 0, 0 },
368 { __LINE__, -32, 0, 240, 33, 33, 28, 5, 1, 0 },
369 { __LINE__, -64, 0, 480, 64, 64, 55, 9, 0, 0 },
370 { __LINE__, -100, 0, 750, 100, 100, 86, 14, 0, 0 },
371 { __LINE__, -200, 0, 1500, 200, 200, 172, 28, 0, 0 },
372 { __LINE__, -300, 0, 2250, 300, 300, 258, 42, 0, 0 },
373 { __LINE__, -400, 0, 3000, 400, 400, 344, 56, 0, 0 },
374 };
375 #define g_MSMINCHO_count _countof(g_MSMINCHO)
376 #endif
377
378 typedef struct FONT_ENTRY
379 {
380 const char *entry_name;
381 const char *font_name;
382 const char *font_file;
383 size_t test_count;
384 const TEST_ENTRY *tests;
385 } FONT_ENTRY;
386
387 static FONT_ENTRY g_font_entries[] =
388 {
389 #ifdef EMIT_TESTCASES
390 { "FREEMONO", "FreeMono", "FreeMono.ttf" },
391 { "DEJAVUSERIF", "DejaVu Serif", "DejaVuSerif.ttf" },
392 { "DEJAVUSANS", "DejaVu Sans", "DejaVuSans.ttf" },
393 { "UBUNTUMONO", "Ubuntu Mono", "UbuntuMono-R.ttf" },
394 { "MSGOTHIC", "MS Gothic", "msgothic.ttc" },
395 { "MSMINCHO", "MS Mincho", "msmincho.ttc" },
396 #else
397 { "FREEMONO", "FreeMono", "FreeMono.ttf", g_FREEMONO_count, g_FREEMONO },
398 { "DEJAVUSERIF", "DejaVu Serif", "DejaVuSerif.ttf", g_DEJAVUSERIF_count, g_DEJAVUSERIF },
399 { "DEJAVUSANS", "DejaVu Sans", "DejaVuSans.ttf", g_DEJAVUSANS_count, g_DEJAVUSANS },
400 { "UBUNTUMONO", "Ubuntu Mono", "UbuntuMono-R.ttf", g_UBUNTUMONO_count, g_UBUNTUMONO },
401 { "MSGOTHIC", "MS Gothic", "msgothic.ttc", g_MSGOTHIC_count, g_MSGOTHIC },
402 { "MSMINCHO", "MS Mincho", "msmincho.ttc", g_MSMINCHO_count, g_MSMINCHO },
403 #endif
404 };
405 static size_t g_font_entry_count = _countof(g_font_entries);
406
407 START_TEST(GetTextMetrics)
408 {
409 size_t i, k;
410 LOGFONTA lf;
411 HFONT hFont;
412 HDC hDC;
413 HGDIOBJ hFontOld;
414 SIZE siz;
415 TEXTMETRIC tm;
416 char szPath[MAX_PATH];
417 static const char *text = "This is a test.";
418
419 hDC = CreateCompatibleDC(NULL);
420 for (i = 0; i < g_font_entry_count; ++i)
421 {
422 FONT_ENTRY *font = &g_font_entries[i];
423 ZeroMemory(&lf, sizeof(lf));
424 lf.lfCharSet = DEFAULT_CHARSET;
425 lstrcpyA(lf.lfFaceName, font->font_name);
426
427 GetWindowsDirectoryA(szPath, MAX_PATH);
428 lstrcatA(szPath, "\\Fonts\\");
429 lstrcatA(szPath, font->font_file);
430 if (GetFileAttributesA(szPath) == 0xFFFFFFFF)
431 {
432 skip("Font file '%s' doesn't exists\n", font->font_file);
433 continue;
434 }
435
436 #ifdef EMIT_TESTCASES
437 printf("static const TEST_ENTRY g_%s[] =\n", font->entry_name);
438 printf("{\n");
439 for (k = 0; k < g_test_entry_count; ++k)
440 {
441 const TEST_ENTRY *test = &g_test_entries[k];
442
443 lf.lfHeight = test->lfHeight;
444 lf.lfWidth = test->lfWidth;
445
446 hFont = CreateFontIndirectA(&lf);
447 hFontOld = SelectObject(hDC, hFont);
448 {
449 GetTextExtentPoint32A(hDC, text, lstrlenA(text), &siz);
450 GetTextMetrics(hDC, &tm);
451 }
452 SelectObject(hDC, hFontOld);
453 DeleteObject(hFont);
454
455 printf(" { __LINE__, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld },\n",
456 lf.lfHeight, lf.lfWidth,
457 siz.cx, siz.cy,
458 tm.tmHeight, tm.tmAscent, tm.tmDescent, tm.tmInternalLeading, tm.tmExternalLeading);
459 }
460 printf("};\n");
461 printf("#define g_%s_count _countof(g_%s)\n\n", font->entry_name, font->entry_name);
462 #else
463 for (k = 0; k < font->test_count; ++k)
464 {
465 const TEST_ENTRY *test = &font->tests[k];
466
467 lf.lfHeight = test->lfHeight;
468 lf.lfWidth = test->lfWidth;
469
470 hFont = CreateFontIndirectA(&lf);
471 hFontOld = SelectObject(hDC, hFont);
472 {
473 GetTextExtentPoint32A(hDC, text, lstrlenA(text), &siz);
474 GetTextMetrics(hDC, &tm);
475 }
476 SelectObject(hDC, hFontOld);
477 DeleteObject(hFont);
478
479 if (test->cxText > 0)
480 {
481 ok_(__FILE__, test->line)(labs(test->cxText - siz.cx) <= 1, "%s (%ld): cxText: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->cxText, siz.cx);
482 ok_(__FILE__, test->line)(labs(test->cxText - siz.cx) == 0, "%s (%ld): cxText: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->cxText, siz.cx);
483 }
484 if (test->cyText > 0)
485 {
486 ok_(__FILE__, test->line)(labs(test->cyText - siz.cy) <= 1, "%s (%ld): cyText: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->cyText, siz.cy);
487 ok_(__FILE__, test->line)(labs(test->cyText - siz.cy) == 0, "%s (%ld): cyText: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->cyText, siz.cy);
488 }
489 if (test->tmHeight > 0)
490 {
491 ok_(__FILE__, test->line)(labs(test->tmHeight - tm.tmHeight) <= 1, "%s (%ld): tmHeight: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmHeight, tm.tmHeight);
492 ok_(__FILE__, test->line)(labs(test->tmHeight - tm.tmHeight) == 0, "%s (%ld): tmHeight: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmHeight, tm.tmHeight);
493 }
494 if (test->tmAscent > 0)
495 {
496 ok_(__FILE__, test->line)(labs(test->tmAscent - tm.tmAscent) <= 1, "%s (%ld): tmAscent: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmAscent, tm.tmAscent);
497 ok_(__FILE__, test->line)(labs(test->tmAscent - tm.tmAscent) == 0, "%s (%ld): tmAscent: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmAscent, tm.tmAscent);
498 }
499 if (test->tmDescent > 0)
500 {
501 ok_(__FILE__, test->line)(labs(test->tmDescent - tm.tmDescent) <= 1, "%s (%ld): tmDescent: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmDescent, tm.tmDescent);
502 ok_(__FILE__, test->line)(labs(test->tmDescent - tm.tmDescent) == 0, "%s (%ld): tmDescent: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmDescent, tm.tmDescent);
503 }
504 if (test->tmInternalLeading > 0)
505 {
506 ok_(__FILE__, test->line)(labs(test->tmInternalLeading - tm.tmInternalLeading) <= 1, "%s (%ld): tmInternalLeading: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmInternalLeading, tm.tmInternalLeading);
507 ok_(__FILE__, test->line)(labs(test->tmInternalLeading - tm.tmInternalLeading) == 0, "%s (%ld): tmInternalLeading: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmInternalLeading, tm.tmInternalLeading);
508 }
509 if (test->tmExternalLeading > 0)
510 {
511 ok_(__FILE__, test->line)(labs(test->tmExternalLeading - tm.tmExternalLeading) <= 1, "%s (%ld): tmExternalLeading: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmExternalLeading, tm.tmExternalLeading);
512 ok_(__FILE__, test->line)(labs(test->tmExternalLeading - tm.tmExternalLeading) == 0, "%s (%ld): tmExternalLeading: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmExternalLeading, tm.tmExternalLeading);
513 }
514 }
515 #endif
516 }
517 DeleteDC(hDC);
518 }