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