452383c88f5ebf39e674cb85ff87a90c548033e1
[reactos.git] / rostests / winetests / gdiplus / font.c
1 /*
2 * Unit test suite for fonts
3 *
4 * Copyright (C) 2007 Google (Evan Stade)
5 * Copyright (C) 2012 Dmitry Timoshkov
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library 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 GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include <math.h>
23
24 #define WIN32_NO_STATUS
25 #define _INC_WINDOWS
26 #define COM_NO_WINDOWS_H
27
28 //#include "windows.h"
29 #include <wine/test.h>
30 #include <wingdi.h>
31 #include <winnls.h>
32 #include <objbase.h>
33 #include <gdiplus.h>
34
35 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
36 #define expect_(expected, got, precision) ok(abs((expected) - (got)) <= (precision), "Expected %d, got %d\n", (expected), (got))
37 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
38 #define expectf(expected, got) expectf_((expected), (got), 0.001)
39
40 static const WCHAR nonexistent[] = {'T','h','i','s','F','o','n','t','s','h','o','u','l','d','N','o','t','E','x','i','s','t','\0'};
41 static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
42 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
43 static const WCHAR Tahoma[] = {'T','a','h','o','m','a',0};
44
45 static void set_rect_empty(RectF *rc)
46 {
47 rc->X = 0.0;
48 rc->Y = 0.0;
49 rc->Width = 0.0;
50 rc->Height = 0.0;
51 }
52
53 static void test_createfont(void)
54 {
55 GpFontFamily* fontfamily = NULL, *fontfamily2;
56 GpFont* font = NULL;
57 GpStatus stat;
58 Unit unit;
59 UINT i;
60 REAL size;
61 WCHAR familyname[LF_FACESIZE];
62
63 stat = GdipCreateFontFamilyFromName(nonexistent, NULL, &fontfamily);
64 expect (FontFamilyNotFound, stat);
65 stat = GdipDeleteFont(font);
66 expect (InvalidParameter, stat);
67 stat = GdipCreateFontFamilyFromName(Tahoma, NULL, &fontfamily);
68 expect (Ok, stat);
69 stat = GdipCreateFont(fontfamily, 12, FontStyleRegular, UnitPoint, &font);
70 expect (Ok, stat);
71 stat = GdipGetFontUnit (font, &unit);
72 expect (Ok, stat);
73 expect (UnitPoint, unit);
74
75 stat = GdipGetFamily(font, &fontfamily2);
76 expect(Ok, stat);
77 stat = GdipGetFamilyName(fontfamily2, familyname, 0);
78 expect(Ok, stat);
79 ok (lstrcmpiW(Tahoma, familyname) == 0, "Expected Tahoma, got %s\n",
80 wine_dbgstr_w(familyname));
81 stat = GdipDeleteFontFamily(fontfamily2);
82 expect(Ok, stat);
83
84 /* Test to see if returned size is based on unit (its not) */
85 GdipGetFontSize(font, &size);
86 ok (size == 12, "Expected 12, got %f\n", size);
87 GdipDeleteFont(font);
88
89 /* Make sure everything is converted correctly for all Units */
90 for (i = UnitWorld; i <=UnitMillimeter; i++)
91 {
92 if (i == UnitDisplay) continue; /* Crashes WindowsXP, wtf? */
93 GdipCreateFont(fontfamily, 24, FontStyleRegular, i, &font);
94 GdipGetFontSize (font, &size);
95 ok (size == 24, "Expected 24, got %f (with unit: %d)\n", size, i);
96 GdipGetFontUnit (font, &unit);
97 expect (i, unit);
98 GdipDeleteFont(font);
99 }
100
101 GdipDeleteFontFamily(fontfamily);
102 }
103
104 static void test_logfont(void)
105 {
106 LOGFONTA lfa, lfa2;
107 GpFont *font;
108 GpFontFamily *family;
109 GpStatus stat;
110 GpGraphics *graphics;
111 HDC hdc = GetDC(0);
112 INT style;
113 REAL rval;
114 UINT16 em_height, line_spacing;
115 Unit unit;
116
117 GdipCreateFromHDC(hdc, &graphics);
118
119 memset(&lfa, 0, sizeof(LOGFONTA));
120 memset(&lfa2, 0xff, sizeof(LOGFONTA));
121 lstrcpyA(lfa.lfFaceName, "Tahoma");
122
123 stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
124 expect(Ok, stat);
125 stat = GdipGetLogFontA(font, graphics, &lfa2);
126 expect(Ok, stat);
127
128 ok(lfa2.lfHeight < 0, "Expected negative height\n");
129 expect(0, lfa2.lfWidth);
130 expect(0, lfa2.lfEscapement);
131 expect(0, lfa2.lfOrientation);
132 ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n");
133 expect(0, lfa2.lfItalic);
134 expect(0, lfa2.lfUnderline);
135 expect(0, lfa2.lfStrikeOut);
136 ok(lfa2.lfCharSet == GetTextCharset(hdc) || lfa2.lfCharSet == ANSI_CHARSET,
137 "Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet);
138 expect(0, lfa2.lfOutPrecision);
139 expect(0, lfa2.lfClipPrecision);
140 expect(0, lfa2.lfQuality);
141 expect(0, lfa2.lfPitchAndFamily);
142
143 GdipDeleteFont(font);
144
145 memset(&lfa, 0, sizeof(LOGFONTA));
146 lfa.lfHeight = 25;
147 lfa.lfWidth = 25;
148 lfa.lfEscapement = lfa.lfOrientation = 50;
149 lfa.lfItalic = lfa.lfUnderline = lfa.lfStrikeOut = TRUE;
150
151 memset(&lfa2, 0xff, sizeof(LOGFONTA));
152 lstrcpyA(lfa.lfFaceName, "Tahoma");
153
154 stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
155 expect(Ok, stat);
156 stat = GdipGetLogFontA(font, graphics, &lfa2);
157 expect(Ok, stat);
158
159 ok(lfa2.lfHeight < 0, "Expected negative height\n");
160 expect(0, lfa2.lfWidth);
161 expect(0, lfa2.lfEscapement);
162 expect(0, lfa2.lfOrientation);
163 ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n");
164 expect(TRUE, lfa2.lfItalic);
165 expect(TRUE, lfa2.lfUnderline);
166 expect(TRUE, lfa2.lfStrikeOut);
167 ok(lfa2.lfCharSet == GetTextCharset(hdc) || lfa2.lfCharSet == ANSI_CHARSET,
168 "Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet);
169 expect(0, lfa2.lfOutPrecision);
170 expect(0, lfa2.lfClipPrecision);
171 expect(0, lfa2.lfQuality);
172 expect(0, lfa2.lfPitchAndFamily);
173
174 stat = GdipGetFontStyle(font, &style);
175 expect(Ok, stat);
176 ok (style == (FontStyleItalic | FontStyleUnderline | FontStyleStrikeout),
177 "Expected , got %d\n", style);
178
179 stat = GdipGetFontUnit(font, &unit);
180 expect(Ok, stat);
181 expect(UnitWorld, unit);
182
183 stat = GdipGetFontHeight(font, graphics, &rval);
184 expect(Ok, stat);
185 expectf(25.347656, rval);
186 stat = GdipGetFontSize(font, &rval);
187 expect(Ok, stat);
188 expectf(21.0, rval);
189
190 stat = GdipGetFamily(font, &family);
191 expect(Ok, stat);
192 stat = GdipGetEmHeight(family, FontStyleRegular, &em_height);
193 expect(Ok, stat);
194 expect(2048, em_height);
195 stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing);
196 expect(Ok, stat);
197 expect(2472, line_spacing);
198 GdipDeleteFontFamily(family);
199
200 GdipDeleteFont(font);
201
202 memset(&lfa, 0, sizeof(lfa));
203 lfa.lfHeight = -25;
204 lstrcpyA(lfa.lfFaceName, "Tahoma");
205 stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
206 expect(Ok, stat);
207 memset(&lfa2, 0xff, sizeof(lfa2));
208 stat = GdipGetLogFontA(font, graphics, &lfa2);
209 expect(Ok, stat);
210 expect(lfa.lfHeight, lfa2.lfHeight);
211
212 stat = GdipGetFontUnit(font, &unit);
213 expect(Ok, stat);
214 expect(UnitWorld, unit);
215
216 stat = GdipGetFontHeight(font, graphics, &rval);
217 expect(Ok, stat);
218 expectf(30.175781, rval);
219 stat = GdipGetFontSize(font, &rval);
220 expect(Ok, stat);
221 expectf(25.0, rval);
222
223 stat = GdipGetFamily(font, &family);
224 expect(Ok, stat);
225 stat = GdipGetEmHeight(family, FontStyleRegular, &em_height);
226 expect(Ok, stat);
227 expect(2048, em_height);
228 stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing);
229 expect(Ok, stat);
230 expect(2472, line_spacing);
231 GdipDeleteFontFamily(family);
232
233 GdipDeleteFont(font);
234
235 GdipDeleteGraphics(graphics);
236 ReleaseDC(0, hdc);
237 }
238
239 static void test_fontfamily (void)
240 {
241 GpFontFamily *family, *clonedFontFamily;
242 WCHAR itsName[LF_FACESIZE];
243 GpStatus stat;
244
245 /* FontFamily cannot be NULL */
246 stat = GdipCreateFontFamilyFromName (Tahoma , NULL, NULL);
247 expect (InvalidParameter, stat);
248
249 /* FontFamily must be able to actually find the family.
250 * If it can't, any subsequent calls should fail.
251 */
252 stat = GdipCreateFontFamilyFromName (nonexistent, NULL, &family);
253 expect (FontFamilyNotFound, stat);
254
255 /* Bitmap fonts are not found */
256 stat = GdipCreateFontFamilyFromName (MSSansSerif, NULL, &family);
257 expect (FontFamilyNotFound, stat);
258 if(stat == Ok) GdipDeleteFontFamily(family);
259
260 stat = GdipCreateFontFamilyFromName (Tahoma, NULL, &family);
261 expect (Ok, stat);
262
263 stat = GdipGetFamilyName (family, itsName, LANG_NEUTRAL);
264 expect (Ok, stat);
265 expect (0, lstrcmpiW(itsName, Tahoma));
266
267 if (0)
268 {
269 /* Crashes on Windows XP SP2, Vista, and so Wine as well */
270 stat = GdipGetFamilyName (family, NULL, LANG_NEUTRAL);
271 expect (Ok, stat);
272 }
273
274 /* Make sure we don't read old data */
275 ZeroMemory (itsName, sizeof(itsName));
276 stat = GdipCloneFontFamily(family, &clonedFontFamily);
277 expect (Ok, stat);
278 GdipDeleteFontFamily(family);
279 stat = GdipGetFamilyName(clonedFontFamily, itsName, LANG_NEUTRAL);
280 expect(Ok, stat);
281 expect(0, lstrcmpiW(itsName, Tahoma));
282
283 GdipDeleteFontFamily(clonedFontFamily);
284 }
285
286 static void test_fontfamily_properties (void)
287 {
288 GpFontFamily* FontFamily = NULL;
289 GpStatus stat;
290 UINT16 result = 0;
291
292 stat = GdipCreateFontFamilyFromName(Tahoma, NULL, &FontFamily);
293 expect(Ok, stat);
294
295 stat = GdipGetLineSpacing(FontFamily, FontStyleRegular, &result);
296 expect(Ok, stat);
297 ok (result == 2472, "Expected 2472, got %d\n", result);
298 result = 0;
299 stat = GdipGetEmHeight(FontFamily, FontStyleRegular, &result);
300 expect(Ok, stat);
301 ok(result == 2048, "Expected 2048, got %d\n", result);
302 result = 0;
303 stat = GdipGetCellAscent(FontFamily, FontStyleRegular, &result);
304 expect(Ok, stat);
305 ok(result == 2049, "Expected 2049, got %d\n", result);
306 result = 0;
307 stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
308 expect(Ok, stat);
309 ok(result == 423, "Expected 423, got %d\n", result);
310 GdipDeleteFontFamily(FontFamily);
311
312 stat = GdipCreateFontFamilyFromName(TimesNewRoman, NULL, &FontFamily);
313 if(stat == FontFamilyNotFound)
314 skip("Times New Roman not installed\n");
315 else
316 {
317 result = 0;
318 stat = GdipGetLineSpacing(FontFamily, FontStyleRegular, &result);
319 expect(Ok, stat);
320 ok(result == 2355, "Expected 2355, got %d\n", result);
321 result = 0;
322 stat = GdipGetEmHeight(FontFamily, FontStyleRegular, &result);
323 expect(Ok, stat);
324 ok(result == 2048, "Expected 2048, got %d\n", result);
325 result = 0;
326 stat = GdipGetCellAscent(FontFamily, FontStyleRegular, &result);
327 expect(Ok, stat);
328 ok(result == 1825, "Expected 1825, got %d\n", result);
329 result = 0;
330 stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
331 expect(Ok, stat);
332 ok(result == 443, "Expected 443 got %d\n", result);
333 GdipDeleteFontFamily(FontFamily);
334 }
335 }
336
337 static void check_family(const char* context, GpFontFamily *family, WCHAR *name)
338 {
339 GpStatus stat;
340 GpFont* font;
341
342 *name = 0;
343 stat = GdipGetFamilyName(family, name, LANG_NEUTRAL);
344 ok(stat == Ok, "could not get the %s family name: %.8x\n", context, stat);
345
346 stat = GdipCreateFont(family, 12, FontStyleRegular, UnitPixel, &font);
347 ok(stat == Ok, "could not create a font for the %s family: %.8x\n", context, stat);
348 if (stat == Ok)
349 {
350 stat = GdipDeleteFont(font);
351 ok(stat == Ok, "could not delete the %s family font: %.8x\n", context, stat);
352 }
353
354 stat = GdipDeleteFontFamily(family);
355 ok(stat == Ok, "could not delete the %s family: %.8x\n", context, stat);
356 }
357
358 static void test_getgenerics (void)
359 {
360 GpStatus stat;
361 GpFontFamily *family;
362 WCHAR sansname[LF_FACESIZE], serifname[LF_FACESIZE], mononame[LF_FACESIZE];
363 int missingfonts = 0;
364
365 stat = GdipGetGenericFontFamilySansSerif(&family);
366 expect (Ok, stat);
367 if (stat == FontFamilyNotFound)
368 missingfonts = 1;
369 else
370 check_family("Sans Serif", family, sansname);
371
372 stat = GdipGetGenericFontFamilySerif(&family);
373 expect (Ok, stat);
374 if (stat == FontFamilyNotFound)
375 missingfonts = 1;
376 else
377 check_family("Serif", family, serifname);
378
379 stat = GdipGetGenericFontFamilyMonospace(&family);
380 expect (Ok, stat);
381 if (stat == FontFamilyNotFound)
382 missingfonts = 1;
383 else
384 check_family("Monospace", family, mononame);
385
386 if (missingfonts && strcmp(winetest_platform, "wine") == 0)
387 trace("You may need to install either the Microsoft Web Fonts or the Liberation Fonts\n");
388
389 /* Check that the family names are all different */
390 ok(lstrcmpiW(sansname, serifname) != 0, "Sans Serif and Serif families should be different: %s\n", wine_dbgstr_w(sansname));
391 ok(lstrcmpiW(sansname, mononame) != 0, "Sans Serif and Monospace families should be different: %s\n", wine_dbgstr_w(sansname));
392 ok(lstrcmpiW(serifname, mononame) != 0, "Serif and Monospace families should be different: %s\n", wine_dbgstr_w(serifname));
393 }
394
395 static void test_installedfonts (void)
396 {
397 GpStatus stat;
398 GpFontCollection* collection=NULL;
399
400 stat = GdipNewInstalledFontCollection(NULL);
401 expect (InvalidParameter, stat);
402
403 stat = GdipNewInstalledFontCollection(&collection);
404 expect (Ok, stat);
405 ok (collection != NULL, "got NULL font collection\n");
406 }
407
408 static void test_heightgivendpi(void)
409 {
410 GpStatus stat;
411 GpFont* font = NULL;
412 GpFontFamily* fontfamily = NULL;
413 REAL height;
414 Unit unit;
415
416 stat = GdipCreateFontFamilyFromName(Tahoma, NULL, &fontfamily);
417 expect(Ok, stat);
418
419 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPixel, &font);
420 expect(Ok, stat);
421
422 stat = GdipGetFontHeightGivenDPI(NULL, 96, &height);
423 expect(InvalidParameter, stat);
424
425 stat = GdipGetFontHeightGivenDPI(font, 96, NULL);
426 expect(InvalidParameter, stat);
427
428 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
429 expect(Ok, stat);
430 expectf(36.210938, height);
431 GdipDeleteFont(font);
432
433 height = 12345;
434 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitWorld, &font);
435 expect(Ok, stat);
436
437 stat = GdipGetFontUnit(font, &unit);
438 expect(Ok, stat);
439 expect(UnitWorld, unit);
440
441 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
442 expect(Ok, stat);
443 expectf(36.210938, height);
444 GdipDeleteFont(font);
445
446 height = 12345;
447 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPoint, &font);
448 expect(Ok, stat);
449 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
450 expect(Ok, stat);
451 expectf(48.281250, height);
452 GdipDeleteFont(font);
453
454 height = 12345;
455 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitInch, &font);
456 expect(Ok, stat);
457
458 stat = GdipGetFontUnit(font, &unit);
459 expect(Ok, stat);
460 expect(UnitInch, unit);
461
462 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
463 expect(Ok, stat);
464 expectf(3476.250000, height);
465 GdipDeleteFont(font);
466
467 height = 12345;
468 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitDocument, &font);
469 expect(Ok, stat);
470
471 stat = GdipGetFontUnit(font, &unit);
472 expect(Ok, stat);
473 expect(UnitDocument, unit);
474
475 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
476 expect(Ok, stat);
477 expectf(11.587500, height);
478 GdipDeleteFont(font);
479
480 height = 12345;
481 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitMillimeter, &font);
482 expect(Ok, stat);
483
484 stat = GdipGetFontUnit(font, &unit);
485 expect(Ok, stat);
486 expect(UnitMillimeter, unit);
487
488 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
489 expect(Ok, stat);
490 expectf(136.860245, height);
491 GdipDeleteFont(font);
492
493 GdipDeleteFontFamily(fontfamily);
494 }
495
496 static int CALLBACK font_enum_proc(const LOGFONTW *lfe, const TEXTMETRICW *ntme,
497 DWORD type, LPARAM lparam)
498 {
499 NEWTEXTMETRICW *ntm = (NEWTEXTMETRICW *)lparam;
500
501 if (type != TRUETYPE_FONTTYPE) return 1;
502
503 *ntm = *(NEWTEXTMETRICW *)ntme;
504 return 0;
505 }
506
507 struct font_metrics
508 {
509 UINT16 em_height, line_spacing, ascent, descent;
510 REAL font_height, font_size;
511 INT lfHeight;
512 };
513
514 static void gdi_get_font_metrics(LOGFONTW *lf, struct font_metrics *fm)
515 {
516 HDC hdc;
517 HFONT hfont;
518 NEWTEXTMETRICW ntm;
519 OUTLINETEXTMETRICW otm;
520 int ret;
521
522 hdc = CreateCompatibleDC(0);
523
524 /* it's the only way to get extended NEWTEXTMETRIC fields */
525 ret = EnumFontFamiliesExW(hdc, lf, font_enum_proc, (LPARAM)&ntm, 0);
526 ok(!ret, "EnumFontFamiliesExW failed to find %s\n", wine_dbgstr_w(lf->lfFaceName));
527
528 hfont = CreateFontIndirectW(lf);
529 SelectObject(hdc, hfont);
530
531 otm.otmSize = sizeof(otm);
532 ret = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm);
533 ok(ret, "GetOutlineTextMetrics failed\n");
534
535 DeleteDC(hdc);
536 DeleteObject(hfont);
537
538 fm->lfHeight = -otm.otmTextMetrics.tmAscent;
539 fm->line_spacing = ntm.ntmCellHeight;
540 fm->font_size = (REAL)otm.otmTextMetrics.tmAscent;
541 fm->font_height = (REAL)fm->line_spacing * fm->font_size / (REAL)ntm.ntmSizeEM;
542 fm->em_height = ntm.ntmSizeEM;
543 fm->ascent = ntm.ntmSizeEM;
544 fm->descent = ntm.ntmCellHeight - ntm.ntmSizeEM;
545 }
546
547 static void gdip_get_font_metrics(GpFont *font, struct font_metrics *fm)
548 {
549 INT style;
550 GpFontFamily *family;
551 GpStatus stat;
552
553 stat = GdipGetFontStyle(font, &style);
554 expect(Ok, stat);
555
556 stat = GdipGetFontHeight(font, NULL, &fm->font_height);
557 expect(Ok, stat);
558 stat = GdipGetFontSize(font, &fm->font_size);
559 expect(Ok, stat);
560
561 fm->lfHeight = (INT)(fm->font_size * -1.0);
562
563 stat = GdipGetFamily(font, &family);
564 expect(Ok, stat);
565
566 stat = GdipGetEmHeight(family, style, &fm->em_height);
567 expect(Ok, stat);
568 stat = GdipGetLineSpacing(family, style, &fm->line_spacing);
569 expect(Ok, stat);
570 stat = GdipGetCellAscent(family, style, &fm->ascent);
571 expect(Ok, stat);
572 stat = GdipGetCellDescent(family, style, &fm->descent);
573 expect(Ok, stat);
574
575 GdipDeleteFontFamily(family);
576 }
577
578 static void cmp_font_metrics(struct font_metrics *fm1, struct font_metrics *fm2, int line)
579 {
580 ok_(__FILE__, line)(fm1->lfHeight == fm2->lfHeight, "lfHeight %d != %d\n", fm1->lfHeight, fm2->lfHeight);
581 ok_(__FILE__, line)(fm1->em_height == fm2->em_height, "em_height %u != %u\n", fm1->em_height, fm2->em_height);
582 ok_(__FILE__, line)(fm1->line_spacing == fm2->line_spacing, "line_spacing %u != %u\n", fm1->line_spacing, fm2->line_spacing);
583 ok_(__FILE__, line)(abs(fm1->ascent - fm2->ascent) <= 1, "ascent %u != %u\n", fm1->ascent, fm2->ascent);
584 ok_(__FILE__, line)(abs(fm1->descent - fm2->descent) <= 1, "descent %u != %u\n", fm1->descent, fm2->descent);
585 ok(fm1->font_height > 0.0, "fm1->font_height should be positive, got %f\n", fm1->font_height);
586 ok(fm2->font_height > 0.0, "fm2->font_height should be positive, got %f\n", fm2->font_height);
587 ok_(__FILE__, line)(fm1->font_height == fm2->font_height, "font_height %f != %f\n", fm1->font_height, fm2->font_height);
588 ok(fm1->font_size > 0.0, "fm1->font_size should be positive, got %f\n", fm1->font_size);
589 ok(fm2->font_size > 0.0, "fm2->font_size should be positive, got %f\n", fm2->font_size);
590 ok_(__FILE__, line)(fm1->font_size == fm2->font_size, "font_size %f != %f\n", fm1->font_size, fm2->font_size);
591 }
592
593 static void test_font_metrics(void)
594 {
595 LOGFONTW lf;
596 GpFont *font;
597 GpFontFamily *family;
598 GpGraphics *graphics;
599 GpStatus stat;
600 Unit unit;
601 struct font_metrics fm_gdi, fm_gdip;
602 HDC hdc;
603
604 hdc = CreateCompatibleDC(0);
605 stat = GdipCreateFromHDC(hdc, &graphics);
606 expect(Ok, stat);
607
608 memset(&lf, 0, sizeof(lf));
609
610 /* Tahoma,-13 */
611 lstrcpyW(lf.lfFaceName, Tahoma);
612 lf.lfHeight = -13;
613 stat = GdipCreateFontFromLogfontW(hdc, &lf, &font);
614 expect(Ok, stat);
615
616 stat = GdipGetFontUnit(font, &unit);
617 expect(Ok, stat);
618 expect(UnitWorld, unit);
619
620 gdip_get_font_metrics(font, &fm_gdip);
621 trace("gdiplus:\n");
622 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
623 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
624 fm_gdip.em_height, fm_gdip.line_spacing, fm_gdip.ascent, fm_gdip.descent,
625 fm_gdip.font_height, fm_gdip.font_size);
626
627 gdi_get_font_metrics(&lf, &fm_gdi);
628 trace("gdi:\n");
629 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
630 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
631 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
632 fm_gdi.font_height, fm_gdi.font_size);
633
634 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
635
636 stat = GdipGetLogFontW(font, graphics, &lf);
637 expect(Ok, stat);
638 ok(lf.lfHeight < 0, "lf.lfHeight should be negative, got %d\n", lf.lfHeight);
639 gdi_get_font_metrics(&lf, &fm_gdi);
640 trace("gdi:\n");
641 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
642 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
643 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
644 fm_gdi.font_height, fm_gdi.font_size);
645 ok((REAL)lf.lfHeight * -1.0 == fm_gdi.font_size, "expected %f, got %f\n", (REAL)lf.lfHeight * -1.0, fm_gdi.font_size);
646
647 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
648
649 GdipDeleteFont(font);
650
651 /* Tahoma,13 */
652 lstrcpyW(lf.lfFaceName, Tahoma);
653 lf.lfHeight = 13;
654 stat = GdipCreateFontFromLogfontW(hdc, &lf, &font);
655 expect(Ok, stat);
656
657 stat = GdipGetFontUnit(font, &unit);
658 expect(Ok, stat);
659 expect(UnitWorld, unit);
660
661 gdip_get_font_metrics(font, &fm_gdip);
662 trace("gdiplus:\n");
663 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
664 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
665 fm_gdip.em_height, fm_gdip.line_spacing, fm_gdip.ascent, fm_gdip.descent,
666 fm_gdip.font_height, fm_gdip.font_size);
667
668 gdi_get_font_metrics(&lf, &fm_gdi);
669 trace("gdi:\n");
670 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
671 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
672 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
673 fm_gdi.font_height, fm_gdi.font_size);
674
675 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
676
677 stat = GdipGetLogFontW(font, graphics, &lf);
678 expect(Ok, stat);
679 ok(lf.lfHeight < 0, "lf.lfHeight should be negative, got %d\n", lf.lfHeight);
680 gdi_get_font_metrics(&lf, &fm_gdi);
681 trace("gdi:\n");
682 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
683 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
684 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
685 fm_gdi.font_height, fm_gdi.font_size);
686 ok((REAL)lf.lfHeight * -1.0 == fm_gdi.font_size, "expected %f, got %f\n", (REAL)lf.lfHeight * -1.0, fm_gdi.font_size);
687
688 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
689
690 GdipDeleteFont(font);
691
692 stat = GdipCreateFontFamilyFromName(Tahoma, NULL, &family);
693 expect(Ok, stat);
694
695 /* Tahoma,13 */
696 stat = GdipCreateFont(family, 13.0, FontStyleRegular, UnitPixel, &font);
697 expect(Ok, stat);
698
699 gdip_get_font_metrics(font, &fm_gdip);
700 trace("gdiplus:\n");
701 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
702 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
703 fm_gdip.em_height, fm_gdip.line_spacing, fm_gdip.ascent, fm_gdip.descent,
704 fm_gdip.font_height, fm_gdip.font_size);
705
706 stat = GdipGetLogFontW(font, graphics, &lf);
707 expect(Ok, stat);
708 ok(lf.lfHeight < 0, "lf.lfHeight should be negative, got %d\n", lf.lfHeight);
709 gdi_get_font_metrics(&lf, &fm_gdi);
710 trace("gdi:\n");
711 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
712 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
713 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
714 fm_gdi.font_height, fm_gdi.font_size);
715 ok((REAL)lf.lfHeight * -1.0 == fm_gdi.font_size, "expected %f, got %f\n", (REAL)lf.lfHeight * -1.0, fm_gdi.font_size);
716
717 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
718
719 stat = GdipGetLogFontW(font, NULL, &lf);
720 expect(InvalidParameter, stat);
721
722 GdipDeleteFont(font);
723
724 stat = GdipCreateFont(family, -13.0, FontStyleRegular, UnitPixel, &font);
725 expect(InvalidParameter, stat);
726
727 GdipDeleteFontFamily(family);
728
729 GdipDeleteGraphics(graphics);
730 DeleteDC(hdc);
731 }
732
733 static void test_font_substitution(void)
734 {
735 WCHAR ms_shell_dlg[LF_FACESIZE];
736 HDC hdc;
737 HFONT hfont;
738 LOGFONTA lf;
739 GpStatus status;
740 GpGraphics *graphics;
741 GpFont *font;
742 GpFontFamily *family;
743 int ret;
744
745 hdc = CreateCompatibleDC(0);
746 status = GdipCreateFromHDC(hdc, &graphics);
747 expect(Ok, status);
748
749 hfont = GetStockObject(DEFAULT_GUI_FONT);
750 ok(hfont != 0, "GetStockObject(DEFAULT_GUI_FONT) failed\n");
751
752 memset(&lf, 0xfe, sizeof(lf));
753 ret = GetObjectA(hfont, sizeof(lf), &lf);
754 ok(ret == sizeof(lf), "GetObject failed\n");
755 ok(!lstrcmpA(lf.lfFaceName, "MS Shell Dlg"), "wrong face name %s\n", lf.lfFaceName);
756 MultiByteToWideChar(CP_ACP, 0, lf.lfFaceName, -1, ms_shell_dlg, LF_FACESIZE);
757
758 status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
759 expect(Ok, status);
760 memset(&lf, 0xfe, sizeof(lf));
761 status = GdipGetLogFontA(font, graphics, &lf);
762 expect(Ok, status);
763 ok(!lstrcmpA(lf.lfFaceName, "Microsoft Sans Serif") ||
764 !lstrcmpA(lf.lfFaceName, "Tahoma"), "wrong face name %s\n", lf.lfFaceName);
765 GdipDeleteFont(font);
766
767 status = GdipCreateFontFamilyFromName(ms_shell_dlg, NULL, &family);
768 expect(Ok, status);
769 status = GdipCreateFont(family, 12, FontStyleRegular, UnitPoint, &font);
770 expect(Ok, status);
771 memset(&lf, 0xfe, sizeof(lf));
772 status = GdipGetLogFontA(font, graphics, &lf);
773 expect(Ok, status);
774 ok(!lstrcmpA(lf.lfFaceName, "Microsoft Sans Serif") ||
775 !lstrcmpA(lf.lfFaceName, "Tahoma"), "wrong face name %s\n", lf.lfFaceName);
776 GdipDeleteFont(font);
777 GdipDeleteFontFamily(family);
778
779 status = GdipCreateFontFamilyFromName(nonexistent, NULL, &family);
780 ok(status == FontFamilyNotFound, "expected FontFamilyNotFound, got %d\n", status);
781
782 lstrcpyA(lf.lfFaceName, "ThisFontShouldNotExist");
783 status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
784 expect(Ok, status);
785 memset(&lf, 0xfe, sizeof(lf));
786 status = GdipGetLogFontA(font, graphics, &lf);
787 expect(Ok, status);
788 ok(!lstrcmpA(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName);
789 GdipDeleteFont(font);
790
791 /* empty FaceName */
792 lf.lfFaceName[0] = 0;
793 status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
794 expect(Ok, status);
795 memset(&lf, 0xfe, sizeof(lf));
796 status = GdipGetLogFontA(font, graphics, &lf);
797 expect(Ok, status);
798 ok(!lstrcmpA(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName);
799 GdipDeleteFont(font);
800
801 /* zeroing out lfWeight and lfCharSet leads to font creation failure */
802 lf.lfWeight = 0;
803 lf.lfCharSet = 0;
804 lstrcpyA(lf.lfFaceName, "ThisFontShouldNotExist");
805 font = NULL;
806 status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
807 todo_wine
808 ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
809 "expected NotTrueTypeFont, got %d\n", status);
810 /* FIXME: remove when wine is fixed */
811 if (font) GdipDeleteFont(font);
812
813 /* empty FaceName */
814 lf.lfFaceName[0] = 0;
815 font = NULL;
816 status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
817 todo_wine
818 ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
819 "expected NotTrueTypeFont, got %d\n", status);
820 /* FIXME: remove when wine is fixed */
821 if (font) GdipDeleteFont(font);
822
823 GdipDeleteGraphics(graphics);
824 DeleteDC(hdc);
825 }
826
827 static void test_font_transform(void)
828 {
829 static const WCHAR string[] = { 'A',0 };
830 GpStatus status;
831 HDC hdc;
832 LOGFONTA lf;
833 GpFont *font;
834 GpGraphics *graphics;
835 GpMatrix *matrix;
836 GpStringFormat *format, *typographic;
837 PointF pos[1] = { { 0,0 } };
838 REAL height, margin_y;
839 RectF bounds, rect;
840
841 hdc = CreateCompatibleDC(0);
842 status = GdipCreateFromHDC(hdc, &graphics);
843 expect(Ok, status);
844
845 status = GdipSetPageUnit(graphics, UnitPixel);
846 expect(Ok, status);
847
848 status = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
849 expect(Ok, status);
850 status = GdipStringFormatGetGenericTypographic(&typographic);
851 expect(Ok, status);
852
853 memset(&lf, 0, sizeof(lf));
854 lstrcpyA(lf.lfFaceName, "Tahoma");
855 lf.lfHeight = -100;
856 lf.lfWidth = 100;
857 status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
858 expect(Ok, status);
859
860 margin_y = 100.0 / 8.0;
861
862 /* identity matrix */
863 status = GdipCreateMatrix(&matrix);
864 expect(Ok, status);
865 status = GdipSetWorldTransform(graphics, matrix);
866 expect(Ok, status);
867 status = GdipGetLogFontA(font, graphics, &lf);
868 expect(Ok, status);
869 expect(-100, lf.lfHeight);
870 expect(0, lf.lfWidth);
871 expect(0, lf.lfEscapement);
872 expect(0, lf.lfOrientation);
873 status = GdipGetFontHeight(font, graphics, &height);
874 expect(Ok, status);
875 expectf(120.703125, height);
876 set_rect_empty(&rect);
877 set_rect_empty(&bounds);
878 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
879 expect(Ok, status);
880 expectf(0.0, bounds.X);
881 expectf(0.0, bounds.Y);
882 todo_wine
883 expectf(height + margin_y, bounds.Height);
884 set_rect_empty(&rect);
885 set_rect_empty(&bounds);
886 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
887 expect(Ok, status);
888 expectf(0.0, bounds.X);
889 expectf(0.0, bounds.Y);
890 expectf_(height, bounds.Height, 1.0);
891 set_rect_empty(&bounds);
892 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
893 DriverStringOptionsCmapLookup, NULL, &bounds);
894 expect(Ok, status);
895 expectf(0.0, bounds.X);
896 expectf_(-100.0, bounds.Y, 0.05);
897 expectf_(height, bounds.Height, 0.5);
898 set_rect_empty(&bounds);
899 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
900 DriverStringOptionsCmapLookup, matrix, &bounds);
901 expect(Ok, status);
902 expectf(0.0, bounds.X);
903 expectf_(-100.0, bounds.Y, 0.05);
904 expectf_(height, bounds.Height, 0.5);
905
906 /* scale matrix */
907 status = GdipScaleMatrix(matrix, 2.0, 3.0, MatrixOrderAppend);
908 expect(Ok, status);
909 status = GdipSetWorldTransform(graphics, matrix);
910 expect(Ok, status);
911 status = GdipGetLogFontA(font, graphics, &lf);
912 expect(Ok, status);
913 expect(-300, lf.lfHeight);
914 expect(0, lf.lfWidth);
915 expect(0, lf.lfEscapement);
916 expect(0, lf.lfOrientation);
917 status = GdipGetFontHeight(font, graphics, &height);
918 expect(Ok, status);
919 expectf(120.703125, height);
920 set_rect_empty(&rect);
921 set_rect_empty(&bounds);
922 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
923 expect(Ok, status);
924 expectf(0.0, bounds.X);
925 expectf(0.0, bounds.Y);
926 todo_wine
927 expectf(height + margin_y, bounds.Height);
928 set_rect_empty(&rect);
929 set_rect_empty(&bounds);
930 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
931 expect(Ok, status);
932 expectf(0.0, bounds.X);
933 expectf(0.0, bounds.Y);
934 expectf_(height, bounds.Height, 0.05);
935 set_rect_empty(&bounds);
936 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
937 DriverStringOptionsCmapLookup, NULL, &bounds);
938 expect(Ok, status);
939 expectf(0.0, bounds.X);
940 expectf_(-100.0, bounds.Y, 0.05);
941 expectf_(height, bounds.Height, 0.2);
942 set_rect_empty(&bounds);
943 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
944 DriverStringOptionsCmapLookup, matrix, &bounds);
945 expect(Ok, status);
946 expectf(0.0, bounds.X);
947 todo_wine
948 expectf_(-300.0, bounds.Y, 0.15);
949 todo_wine
950 expectf(height * 3.0, bounds.Height);
951
952 /* scale + ratate matrix */
953 status = GdipRotateMatrix(matrix, 45.0, MatrixOrderAppend);
954 expect(Ok, status);
955 status = GdipSetWorldTransform(graphics, matrix);
956 expect(Ok, status);
957 status = GdipGetLogFontA(font, graphics, &lf);
958 expect(Ok, status);
959 expect(-300, lf.lfHeight);
960 expect(0, lf.lfWidth);
961 expect_(3151, lf.lfEscapement, 1);
962 expect_(3151, lf.lfOrientation, 1);
963 status = GdipGetFontHeight(font, graphics, &height);
964 expect(Ok, status);
965 expectf(120.703125, height);
966 set_rect_empty(&rect);
967 set_rect_empty(&bounds);
968 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
969 expect(Ok, status);
970 expectf(0.0, bounds.X);
971 expectf(0.0, bounds.Y);
972 todo_wine
973 expectf(height + margin_y, bounds.Height);
974 set_rect_empty(&rect);
975 set_rect_empty(&bounds);
976 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
977 expect(Ok, status);
978 expectf(0.0, bounds.X);
979 expectf(0.0, bounds.Y);
980 expectf_(height, bounds.Height, 0.05);
981 set_rect_empty(&bounds);
982 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
983 DriverStringOptionsCmapLookup, NULL, &bounds);
984 expect(Ok, status);
985 expectf(0.0, bounds.X);
986 expectf_(-100.0, bounds.Y, 0.05);
987 expectf_(height, bounds.Height, 0.2);
988 set_rect_empty(&bounds);
989 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
990 DriverStringOptionsCmapLookup, matrix, &bounds);
991 expect(Ok, status);
992 todo_wine
993 expectf_(-43.814377, bounds.X, 0.05);
994 todo_wine
995 expectf_(-212.235611, bounds.Y, 0.05);
996 todo_wine
997 expectf_(340.847534, bounds.Height, 0.05);
998
999 /* scale + ratate + shear matrix */
1000 status = GdipShearMatrix(matrix, 4.0, 5.0, MatrixOrderAppend);
1001 expect(Ok, status);
1002 status = GdipSetWorldTransform(graphics, matrix);
1003 expect(Ok, status);
1004 status = GdipGetLogFontA(font, graphics, &lf);
1005 expect(Ok, status);
1006 todo_wine
1007 expect(1032, lf.lfHeight);
1008 expect(0, lf.lfWidth);
1009 expect_(3099, lf.lfEscapement, 1);
1010 expect_(3099, lf.lfOrientation, 1);
1011 status = GdipGetFontHeight(font, graphics, &height);
1012 expect(Ok, status);
1013 expectf(120.703125, height);
1014 set_rect_empty(&rect);
1015 set_rect_empty(&bounds);
1016 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
1017 expect(Ok, status);
1018 expectf(0.0, bounds.X);
1019 expectf(0.0, bounds.Y);
1020 todo_wine
1021 expectf(height + margin_y, bounds.Height);
1022 set_rect_empty(&rect);
1023 set_rect_empty(&bounds);
1024 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
1025 expect(Ok, status);
1026 expectf(0.0, bounds.X);
1027 expectf(0.0, bounds.Y);
1028 expectf_(height, bounds.Height, 0.2);
1029 set_rect_empty(&bounds);
1030 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1031 DriverStringOptionsCmapLookup, NULL, &bounds);
1032 expect(Ok, status);
1033 expectf(0.0, bounds.X);
1034 expectf_(-100.0, bounds.Y, 0.2);
1035 expectf_(height, bounds.Height, 0.2);
1036 set_rect_empty(&bounds);
1037 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1038 DriverStringOptionsCmapLookup, matrix, &bounds);
1039 expect(Ok, status);
1040 todo_wine
1041 expectf_(-636.706848, bounds.X, 0.05);
1042 todo_wine
1043 expectf_(-175.257523, bounds.Y, 0.05);
1044 todo_wine
1045 expectf_(1532.984985, bounds.Height, 0.05);
1046
1047 /* scale + ratate + shear + translate matrix */
1048 status = GdipTranslateMatrix(matrix, 10.0, 20.0, MatrixOrderAppend);
1049 expect(Ok, status);
1050 status = GdipSetWorldTransform(graphics, matrix);
1051 expect(Ok, status);
1052 status = GdipGetLogFontA(font, graphics, &lf);
1053 expect(Ok, status);
1054 todo_wine
1055 expect(1032, lf.lfHeight);
1056 expect(0, lf.lfWidth);
1057 expect_(3099, lf.lfEscapement, 1);
1058 expect_(3099, lf.lfOrientation, 1);
1059 status = GdipGetFontHeight(font, graphics, &height);
1060 expect(Ok, status);
1061 expectf(120.703125, height);
1062 set_rect_empty(&rect);
1063 set_rect_empty(&bounds);
1064 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
1065 expect(Ok, status);
1066 expectf(0.0, bounds.X);
1067 expectf(0.0, bounds.Y);
1068 todo_wine
1069 expectf(height + margin_y, bounds.Height);
1070 set_rect_empty(&rect);
1071 set_rect_empty(&bounds);
1072 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
1073 expect(Ok, status);
1074 expectf(0.0, bounds.X);
1075 expectf(0.0, bounds.Y);
1076 expectf_(height, bounds.Height, 0.1);
1077 set_rect_empty(&bounds);
1078 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1079 DriverStringOptionsCmapLookup, NULL, &bounds);
1080 expect(Ok, status);
1081 expectf(0.0, bounds.X);
1082 expectf_(-100.0, bounds.Y, 0.2);
1083 expectf_(height, bounds.Height, 0.2);
1084 set_rect_empty(&bounds);
1085 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1086 DriverStringOptionsCmapLookup, matrix, &bounds);
1087 expect(Ok, status);
1088 todo_wine
1089 expectf_(-626.706848, bounds.X, 0.05);
1090 todo_wine
1091 expectf_(-155.257523, bounds.Y, 0.05);
1092 todo_wine
1093 expectf_(1532.984985, bounds.Height, 0.05);
1094
1095 GdipDeleteMatrix(matrix);
1096 GdipDeleteFont(font);
1097 GdipDeleteGraphics(graphics);
1098 GdipDeleteStringFormat(typographic);
1099 GdipDeleteStringFormat(format);
1100 DeleteDC(hdc);
1101 }
1102
1103 START_TEST(font)
1104 {
1105 struct GdiplusStartupInput gdiplusStartupInput;
1106 ULONG_PTR gdiplusToken;
1107
1108 gdiplusStartupInput.GdiplusVersion = 1;
1109 gdiplusStartupInput.DebugEventCallback = NULL;
1110 gdiplusStartupInput.SuppressBackgroundThread = 0;
1111 gdiplusStartupInput.SuppressExternalCodecs = 0;
1112
1113 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
1114
1115 test_font_transform();
1116 if (!winetest_interactive)
1117 skip("ROSTESTS-154: Skipping test_font_substitution because of improper error handling\n");
1118 else
1119 test_font_substitution();
1120 test_font_metrics();
1121 test_createfont();
1122 test_logfont();
1123 test_fontfamily();
1124 test_fontfamily_properties();
1125 test_getgenerics();
1126 test_installedfonts();
1127 test_heightgivendpi();
1128
1129 GdiplusShutdown(gdiplusToken);
1130 }