ReactOS  0.4.15-dev-1171-gab82533
GetTextMetrics.c
Go to the documentation of this file.
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;
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 
377 static const TEST_ENTRY g_TAHOMA[] =
378 {
379  { __LINE__, 400, 0, 1953, 400, 400, 332, 68, 0, 0 },
380  { __LINE__, 300, 0, 1466, 300, 300, 249, 51, 0, 0 },
381  { __LINE__, 200, 0, 980, 200, 200, 166, 34, 0, 0 },
382  { __LINE__, 100, 0, 490, 100, 100, 83, 17, 0, 0 },
383  { __LINE__, 64, 0, 316, 64, 64, 53, 11, 0, 0 },
384  { __LINE__, 32, 0, 156, 32, 32, 27, 5, 6, 0 },
385  { __LINE__, 16, 0, 77, 16, 16, 13, 3, 0, 0 },
386  { __LINE__, 15, 0, 73, 15, 15, 12, 3, 0, 0 },
387  { __LINE__, 14, 0, 73, 14, 14, 12, 2, 0, 0 },
388  { __LINE__, 13, 0, 64, 13, 13, 11, 2, 0, 0 },
389  { __LINE__, 12, 0, 56, 12, 12, 10, 2, 0, 0 },
390  { __LINE__, 11, 0, 55, 11, 11, 9, 2, 0, 0 },
391  { __LINE__, 10, 0, 50, 10, 10, 8, 2, 0, 0 },
392  { __LINE__, 9, 0, 41, 9, 9, 7, 2, 0, 0 },
393  { __LINE__, 8, 0, 41, 8, 8, 7, 1, 0, 0 },
394  { __LINE__, 7, 0, 36, 7, 7, 6, 1, 0, 0 },
395  { __LINE__, 6, 0, 32, 6, 6, 5, 1, 0, 0 },
396  { __LINE__, 5, 0, 22, 5, 5, 4, 1, 0, 0 },
397  { __LINE__, 4, 0, 19, 4, 4, 3, 1, 0, 0 },
398  { __LINE__, 3, 0, 13, 4, 4, 3, 0, 0, 0 },
399  { __LINE__, 2, 0, 13, 2, 2, 2, 0, 0, 0 },
400  { __LINE__, 1, 0, 13, 2, 2, 2, 0, 0, 0 },
401  { __LINE__, 0, 0, -135, -18, -18, -15, -3, 0, 0 },
402  { __LINE__, -1, 0, 13, 2, 2, 2, 0, 0, 0 },
403  { __LINE__, -2, 0, 13, 2, 2, 2, 0, 0, 0 },
404  { __LINE__, -3, 0, 19, 4, 4, 3, 0, 0, 0 },
405  { __LINE__, -4, 0, 22, 5, 5, 4, 1, 0, 0 },
406  { __LINE__, -5, 0, 32, 6, 6, 5, 1, 0, 0 },
407  { __LINE__, -6, 0, 36, 7, 7, 6, 1, 0, 0 },
408  { __LINE__, -7, 0, 41, 8, 8, 7, 1, 0, 0 },
409  { __LINE__, -8, 0, 50, 10, 10, 8, 2, 0, 0 },
410  { __LINE__, -9, 0, 55, 11, 11, 9, 2, 0, 0 },
411  { __LINE__, -10, 0, 56, 12, 12, 10, 2, 0, 0 },
412  { __LINE__, -11, 0, 64, 13, 13, 11, 2, 0, 0 },
413  { __LINE__, -12, 0, 73, 14, 14, 12, 2, 0, 0 },
414  { __LINE__, -13, 0, 77, 16, 16, 13, 3, 0, 0 },
415  { __LINE__, -14, 0, 78, 17, 17, 14, 3, 0, 0 },
416  { __LINE__, -15, 0, 89, 18, 18, 15, 3, 0, 0 },
417  { __LINE__, -16, 0, 94, 19, 19, 16, 3, 0, 0 },
418  { __LINE__, -32, 0, 189, 39, 39, 32, 7, 7, 0 },
419  { __LINE__, -64, 0, 379, 77, 77, 64, 13, 0, 0 },
420  { __LINE__, -100, 0, 589, 121, 121, 100, 21, 0, 0 },
421  { __LINE__, -200, 0, 1182, 241, 241, 200, 41, 0, 0 },
422  { __LINE__, -300, 0, 1770, 362, 362, 300, 62, 0, 0 },
423  { __LINE__, -400, 0, 2361, 483, 483, 400, 83, 0, 0 },
424 };
425 #define g_TAHOMA_count _countof(g_TAHOMA)
426 
427 #endif
428 
429 typedef struct FONT_ENTRY
430 {
431  const char *entry_name;
432  const char *font_name;
433  const char *font_file;
434  size_t test_count;
436 } FONT_ENTRY;
437 
439 {
440 #ifdef EMIT_TESTCASES
441  { "FREEMONO", "FreeMono", "FreeMono.ttf" },
442  { "DEJAVUSERIF", "DejaVu Serif", "DejaVuSerif.ttf" },
443  { "DEJAVUSANS", "DejaVu Sans", "DejaVuSans.ttf" },
444  { "UBUNTUMONO", "Ubuntu Mono", "UbuntuMono-R.ttf" },
445  { "MSGOTHIC", "MS Gothic", "msgothic.ttc" },
446  { "MSMINCHO", "MS Mincho", "msmincho.ttc" },
447  { "TAHOMA", "Tahoma", "tahoma.ttf" },
448 #else
449  { "FREEMONO", "FreeMono", "FreeMono.ttf", g_FREEMONO_count, g_FREEMONO },
450  { "DEJAVUSERIF", "DejaVu Serif", "DejaVuSerif.ttf", g_DEJAVUSERIF_count, g_DEJAVUSERIF },
451  { "DEJAVUSANS", "DejaVu Sans", "DejaVuSans.ttf", g_DEJAVUSANS_count, g_DEJAVUSANS },
452  { "UBUNTUMONO", "Ubuntu Mono", "UbuntuMono-R.ttf", g_UBUNTUMONO_count, g_UBUNTUMONO },
453  { "MSGOTHIC", "MS Gothic", "msgothic.ttc", g_MSGOTHIC_count, g_MSGOTHIC },
454  { "MSMINCHO", "MS Mincho", "msmincho.ttc", g_MSMINCHO_count, g_MSMINCHO },
455  { "TAHOMA", "Tahoma", "Tahoma.ttf", g_TAHOMA_count, g_TAHOMA },
456 #endif
457 };
459 
461 {
462  size_t i, k;
463  LOGFONTA lf;
464  HFONT hFont;
465  HDC hDC;
466  HGDIOBJ hFontOld;
467  SIZE siz;
468  TEXTMETRIC tm;
469  char szPath[MAX_PATH];
470  static const char *text = "This is a test.";
471 
473  for (i = 0; i < g_font_entry_count; ++i)
474  {
476  ZeroMemory(&lf, sizeof(lf));
478  lstrcpyA(lf.lfFaceName, font->font_name);
479 
481  lstrcatA(szPath, "\\Fonts\\");
482  lstrcatA(szPath, font->font_file);
483  if (GetFileAttributesA(szPath) == 0xFFFFFFFF)
484  {
485  skip("Font file '%s' doesn't exists\n", font->font_file);
486  continue;
487  }
488 
489  trace("Testing '%s'.\n", font->font_file);
490 
491 #ifdef EMIT_TESTCASES
492  printf("static const TEST_ENTRY g_%s[] =\n", font->entry_name);
493  printf("{\n");
494  for (k = 0; k < g_test_entry_count; ++k)
495  {
496  const TEST_ENTRY *test = &g_test_entries[k];
497 
498  lf.lfHeight = test->lfHeight;
499  lf.lfWidth = test->lfWidth;
500 
501  hFont = CreateFontIndirectA(&lf);
502  hFontOld = SelectObject(hDC, hFont);
503  {
505  GetTextMetrics(hDC, &tm);
506  }
507  SelectObject(hDC, hFontOld);
509 
510  printf(" { __LINE__, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld },\n",
511  lf.lfHeight, lf.lfWidth,
512  siz.cx, siz.cy,
513  tm.tmHeight, tm.tmAscent, tm.tmDescent, tm.tmInternalLeading, tm.tmExternalLeading);
514  }
515  printf("};\n");
516  printf("#define g_%s_count _countof(g_%s)\n\n", font->entry_name, font->entry_name);
517 #else
518  for (k = 0; k < font->test_count; ++k)
519  {
520  const TEST_ENTRY *test = &font->tests[k];
521 
522  lf.lfHeight = test->lfHeight;
523  lf.lfWidth = test->lfWidth;
524 
525  hFont = CreateFontIndirectA(&lf);
526  hFontOld = SelectObject(hDC, hFont);
527  {
529  GetTextMetrics(hDC, &tm);
530  }
531  SelectObject(hDC, hFontOld);
533 
534  if (test->cxText > 0)
535  {
536  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);
537  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);
538  }
539  if (test->cyText > 0)
540  {
541  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);
542  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);
543  }
544  if (test->tmHeight > 0)
545  {
546  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);
547  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);
548  }
549  if (test->tmAscent > 0)
550  {
551  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);
552  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);
553  }
554  if (test->tmDescent > 0)
555  {
556  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);
557  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);
558  }
559  if (test->tmInternalLeading > 0)
560  {
561  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);
562  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);
563  }
564  if (test->tmExternalLeading > 0)
565  {
566  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);
567  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);
568  }
569  }
570 #endif
571  }
572  DeleteDC(hDC);
573 }
LONG cxText
LONG cyText
static const TEST_ENTRY g_MSGOTHIC[]
#define g_DEJAVUSERIF_count
#define g_TAHOMA_count
Definition: mk_font.cpp:20
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
static const TEST_ENTRY g_TAHOMA[]
const WCHAR * text
Definition: package.c:1827
#define g_UBUNTUMONO_count
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BYTE lfCharSet
Definition: dimm.idl:50
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define test
Definition: rosglue.h:37
#define GetTextMetrics
Definition: wingdi.h:4473
#define DEFAULT_CHARSET
Definition: wingdi.h:383
HFONT hFont
Definition: main.c:53
static size_t g_font_entry_count
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const TEST_ENTRY g_DEJAVUSERIF[]
#define g_MSMINCHO_count
long LONG
Definition: pedump.c:60
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
LONG lfHeight
Definition: dimm.idl:42
LONG tmDescent
#define g_FREEMONO_count
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
LONG tmHeight
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define trace
Definition: atltest.h:70
const char * entry_name
#define _countof(array)
Definition: sndvol32.h:68
#define g_DEJAVUSANS_count
#define MAX_PATH
Definition: compat.h:34
size_t test_count
LONG lfWidth
Definition: dimm.idl:43
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
BOOL WINAPI GetTextExtentPoint32A(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
Definition: cmd.c:12
Definition: time.h:76
int line
static const TEST_ENTRY g_MSMINCHO[]
LONG lfWidth
static HDC hDC
Definition: 3dtext.c:33
static const TEST_ENTRY g_UBUNTUMONO[]
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
BOOL WINAPI DeleteDC(_In_ HDC)
#define g_MSGOTHIC_count
LPCWSTR szPath
Definition: env.c:35
const TEST_ENTRY * tests
LONG lfHeight
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
LONG tmInternalLeading
LONG tmExternalLeading
const char * font_name
LONG tmAscent
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define skip(...)
Definition: atltest.h:64
const char * font_file
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
static FONT_ENTRY g_font_entries[]
_Check_return_ long __cdecl labs(_In_ long x)
struct FONT_ENTRY FONT_ENTRY
static const TEST_ENTRY g_FREEMONO[]
static const TEST_ENTRY g_DEJAVUSANS[]
START_TEST(GetTextMetrics)
LONG cy
Definition: windef.h:335
int k
Definition: mpi.c:3369
struct TEST_ENTRY TEST_ENTRY
#define ok_(x1, x2)
Definition: atltest.h:61
#define printf
Definition: config.h:203