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