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