2 * Unit test suite for fonts
4 * Copyright (C) 2007 Google (Evan Stade)
5 * Copyright (C) 2012 Dmitry Timoshkov
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.
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.
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
26 #include "wine/test.h"
28 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
29 #define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %f, got %f\n", expected, got)
31 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'};
32 static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
33 static const WCHAR MicrosoftSansSerif[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
34 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
35 static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
36 static const WCHAR Tahoma[] = {'T','a','h','o','m','a',0};
37 static const WCHAR LiberationSerif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f',0};
39 static void test_createfont(void)
41 GpFontFamily* fontfamily = NULL, *fontfamily2;
47 WCHAR familyname[LF_FACESIZE];
49 stat = GdipCreateFontFamilyFromName(nonexistent, NULL, &fontfamily);
50 expect (FontFamilyNotFound, stat);
51 stat = GdipDeleteFont(font);
52 expect (InvalidParameter, stat);
53 stat = GdipCreateFontFamilyFromName(Tahoma, NULL, &fontfamily);
55 stat = GdipCreateFont(fontfamily, 12, FontStyleRegular, UnitPoint, &font);
57 stat = GdipGetFontUnit (font, &unit);
59 expect (UnitPoint, unit);
61 stat = GdipGetFamily(font, &fontfamily2);
63 stat = GdipGetFamilyName(fontfamily2, familyname, 0);
65 ok (lstrcmpiW(Tahoma, familyname) == 0, "Expected Tahoma, got %s\n",
66 wine_dbgstr_w(familyname));
67 stat = GdipDeleteFontFamily(fontfamily2);
70 /* Test to see if returned size is based on unit (its not) */
71 GdipGetFontSize(font, &size);
72 ok (size == 12, "Expected 12, got %f\n", size);
75 /* Make sure everything is converted correctly for all Units */
76 for (i = UnitWorld; i <=UnitMillimeter; i++)
78 if (i == UnitDisplay) continue; /* Crashes WindowsXP, wtf? */
79 GdipCreateFont(fontfamily, 24, FontStyleRegular, i, &font);
80 GdipGetFontSize (font, &size);
81 ok (size == 24, "Expected 24, got %f (with unit: %d)\n", size, i);
82 GdipGetFontUnit (font, &unit);
87 GdipDeleteFontFamily(fontfamily);
90 static void test_logfont(void)
100 UINT16 em_height, line_spacing;
103 GdipCreateFromHDC(hdc, &graphics);
105 memset(&lfa, 0, sizeof(LOGFONTA));
106 memset(&lfa2, 0xff, sizeof(LOGFONTA));
108 lstrcpyA(lfa.lfFaceName, "Nonexistent font");
109 stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
110 ok(stat == NotTrueTypeFont || broken(stat == FileNotFound), /* before XP */
111 "expected NotTrueTypeFont, got %d\n", stat);
114 lfa.lfFaceName[0] = 0;
115 stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
116 expect(NotTrueTypeFont, stat);
118 lstrcpyA(lfa.lfFaceName, "Tahoma");
120 stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
122 stat = GdipGetLogFontA(font, graphics, &lfa2);
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);
140 GdipDeleteFont(font);
142 memset(&lfa, 0, sizeof(LOGFONTA));
145 lfa.lfEscapement = lfa.lfOrientation = 50;
146 lfa.lfItalic = lfa.lfUnderline = lfa.lfStrikeOut = TRUE;
148 memset(&lfa2, 0xff, sizeof(LOGFONTA));
149 lstrcpyA(lfa.lfFaceName, "Tahoma");
151 stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
153 stat = GdipGetLogFontA(font, graphics, &lfa2);
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);
171 stat = GdipGetFontStyle(font, &style);
173 ok (style == (FontStyleItalic | FontStyleUnderline | FontStyleStrikeout),
174 "Expected , got %d\n", style);
176 stat = GdipGetFontUnit(font, &unit);
178 expect(UnitWorld, unit);
180 stat = GdipGetFontHeight(font, graphics, &rval);
182 expectf(25.347656, rval);
183 stat = GdipGetFontSize(font, &rval);
187 stat = GdipGetFamily(font, &family);
189 stat = GdipGetEmHeight(family, FontStyleRegular, &em_height);
191 expect(2048, em_height);
192 stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing);
194 expect(2472, line_spacing);
195 GdipDeleteFontFamily(family);
197 GdipDeleteFont(font);
199 memset(&lfa, 0, sizeof(lfa));
201 lstrcpyA(lfa.lfFaceName, "Tahoma");
202 stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
204 memset(&lfa2, 0xff, sizeof(lfa2));
205 stat = GdipGetLogFontA(font, graphics, &lfa2);
207 expect(lfa.lfHeight, lfa2.lfHeight);
209 stat = GdipGetFontUnit(font, &unit);
211 expect(UnitWorld, unit);
213 stat = GdipGetFontHeight(font, graphics, &rval);
215 expectf(30.175781, rval);
216 stat = GdipGetFontSize(font, &rval);
220 stat = GdipGetFamily(font, &family);
222 stat = GdipGetEmHeight(family, FontStyleRegular, &em_height);
224 expect(2048, em_height);
225 stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing);
227 expect(2472, line_spacing);
228 GdipDeleteFontFamily(family);
230 GdipDeleteFont(font);
232 GdipDeleteGraphics(graphics);
236 static void test_fontfamily (void)
238 GpFontFamily *family, *clonedFontFamily;
239 WCHAR itsName[LF_FACESIZE];
242 /* FontFamily cannot be NULL */
243 stat = GdipCreateFontFamilyFromName (Tahoma , NULL, NULL);
244 expect (InvalidParameter, stat);
246 /* FontFamily must be able to actually find the family.
247 * If it can't, any subsequent calls should fail.
249 stat = GdipCreateFontFamilyFromName (nonexistent, NULL, &family);
250 expect (FontFamilyNotFound, stat);
252 /* Bitmap fonts are not found */
253 stat = GdipCreateFontFamilyFromName (MSSansSerif, NULL, &family);
254 expect (FontFamilyNotFound, stat);
255 if(stat == Ok) GdipDeleteFontFamily(family);
257 stat = GdipCreateFontFamilyFromName (Tahoma, NULL, &family);
260 stat = GdipGetFamilyName (family, itsName, LANG_NEUTRAL);
262 expect (0, lstrcmpiW(itsName, Tahoma));
266 /* Crashes on Windows XP SP2, Vista, and so Wine as well */
267 stat = GdipGetFamilyName (family, NULL, LANG_NEUTRAL);
271 /* Make sure we don't read old data */
272 ZeroMemory (itsName, sizeof(itsName));
273 stat = GdipCloneFontFamily(family, &clonedFontFamily);
275 GdipDeleteFontFamily(family);
276 stat = GdipGetFamilyName(clonedFontFamily, itsName, LANG_NEUTRAL);
278 expect(0, lstrcmpiW(itsName, Tahoma));
280 GdipDeleteFontFamily(clonedFontFamily);
283 static void test_fontfamily_properties (void)
285 GpFontFamily* FontFamily = NULL;
289 stat = GdipCreateFontFamilyFromName(Tahoma, NULL, &FontFamily);
292 stat = GdipGetLineSpacing(FontFamily, FontStyleRegular, &result);
294 ok (result == 2472, "Expected 2472, got %d\n", result);
296 stat = GdipGetEmHeight(FontFamily, FontStyleRegular, &result);
298 ok(result == 2048, "Expected 2048, got %d\n", result);
300 stat = GdipGetCellAscent(FontFamily, FontStyleRegular, &result);
302 ok(result == 2049, "Expected 2049, got %d\n", result);
304 stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
306 ok(result == 423, "Expected 423, got %d\n", result);
307 GdipDeleteFontFamily(FontFamily);
309 stat = GdipCreateFontFamilyFromName(TimesNewRoman, NULL, &FontFamily);
310 if(stat == FontFamilyNotFound)
311 skip("Times New Roman not installed\n");
315 stat = GdipGetLineSpacing(FontFamily, FontStyleRegular, &result);
317 ok(result == 2355, "Expected 2355, got %d\n", result);
319 stat = GdipGetEmHeight(FontFamily, FontStyleRegular, &result);
321 ok(result == 2048, "Expected 2048, got %d\n", result);
323 stat = GdipGetCellAscent(FontFamily, FontStyleRegular, &result);
325 ok(result == 1825, "Expected 1825, got %d\n", result);
327 stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
329 ok(result == 443, "Expected 443 got %d\n", result);
330 GdipDeleteFontFamily(FontFamily);
334 static void check_family(const char* context, GpFontFamily *family, WCHAR *name)
340 stat = GdipGetFamilyName(family, name, LANG_NEUTRAL);
341 ok(stat == Ok, "could not get the %s family name: %.8x\n", context, stat);
343 stat = GdipCreateFont(family, 12, FontStyleRegular, UnitPixel, &font);
344 ok(stat == Ok, "could not create a font for the %s family: %.8x\n", context, stat);
347 stat = GdipDeleteFont(font);
348 ok(stat == Ok, "could not delete the %s family font: %.8x\n", context, stat);
351 stat = GdipDeleteFontFamily(family);
352 ok(stat == Ok, "could not delete the %s family: %.8x\n", context, stat);
355 static void test_getgenerics (void)
358 GpFontFamily *family;
359 WCHAR sansname[LF_FACESIZE], serifname[LF_FACESIZE], mononame[LF_FACESIZE];
360 int missingfonts = 0;
362 stat = GdipGetGenericFontFamilySansSerif(&family);
364 if (stat == FontFamilyNotFound)
367 check_family("Sans Serif", family, sansname);
369 stat = GdipGetGenericFontFamilySerif(&family);
371 if (stat == FontFamilyNotFound)
374 check_family("Serif", family, serifname);
376 stat = GdipGetGenericFontFamilyMonospace(&family);
378 if (stat == FontFamilyNotFound)
381 check_family("Monospace", family, mononame);
383 if (missingfonts && strcmp(winetest_platform, "wine") == 0)
384 trace("You may need to install either the Microsoft Web Fonts or the Liberation Fonts\n");
386 /* Check that the family names are all different */
387 ok(lstrcmpiW(sansname, serifname) != 0, "Sans Serif and Serif families should be different: %s\n", wine_dbgstr_w(sansname));
388 ok(lstrcmpiW(sansname, mononame) != 0, "Sans Serif and Monospace families should be different: %s\n", wine_dbgstr_w(sansname));
389 ok(lstrcmpiW(serifname, mononame) != 0, "Serif and Monospace families should be different: %s\n", wine_dbgstr_w(serifname));
392 static void test_installedfonts (void)
395 GpFontCollection* collection=NULL;
397 stat = GdipNewInstalledFontCollection(NULL);
398 expect (InvalidParameter, stat);
400 stat = GdipNewInstalledFontCollection(&collection);
402 ok (collection != NULL, "got NULL font collection\n");
405 static void test_heightgivendpi(void)
409 GpFontFamily* fontfamily = NULL;
413 stat = GdipCreateFontFamilyFromName(Tahoma, NULL, &fontfamily);
416 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPixel, &font);
419 stat = GdipGetFontHeightGivenDPI(NULL, 96, &height);
420 expect(InvalidParameter, stat);
422 stat = GdipGetFontHeightGivenDPI(font, 96, NULL);
423 expect(InvalidParameter, stat);
425 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
427 expectf(36.210938, height);
428 GdipDeleteFont(font);
431 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitWorld, &font);
434 stat = GdipGetFontUnit(font, &unit);
436 expect(UnitWorld, unit);
438 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
440 expectf(36.210938, height);
441 GdipDeleteFont(font);
444 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPoint, &font);
446 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
448 expectf(48.281250, height);
449 GdipDeleteFont(font);
452 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitInch, &font);
455 stat = GdipGetFontUnit(font, &unit);
457 expect(UnitInch, unit);
459 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
461 expectf(3476.250000, height);
462 GdipDeleteFont(font);
465 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitDocument, &font);
468 stat = GdipGetFontUnit(font, &unit);
470 expect(UnitDocument, unit);
472 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
474 expectf(11.587500, height);
475 GdipDeleteFont(font);
478 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitMillimeter, &font);
481 stat = GdipGetFontUnit(font, &unit);
483 expect(UnitMillimeter, unit);
485 stat = GdipGetFontHeightGivenDPI(font, 96, &height);
487 expectf(136.860245, height);
488 GdipDeleteFont(font);
490 GdipDeleteFontFamily(fontfamily);
493 static int CALLBACK font_enum_proc(const LOGFONTW *lfe, const TEXTMETRICW *ntme,
494 DWORD type, LPARAM lparam)
496 NEWTEXTMETRICW *ntm = (NEWTEXTMETRICW *)lparam;
498 if (type != TRUETYPE_FONTTYPE) return 1;
500 *ntm = *(NEWTEXTMETRICW *)ntme;
506 UINT16 em_height, line_spacing, ascent, descent;
507 REAL font_height, font_size;
511 static void gdi_get_font_metrics(LOGFONTW *lf, struct font_metrics *fm)
516 OUTLINETEXTMETRICW otm;
519 hdc = CreateCompatibleDC(0);
521 /* it's the only way to get extended NEWTEXTMETRIC fields */
522 ret = EnumFontFamiliesExW(hdc, lf, font_enum_proc, (LPARAM)&ntm, 0);
523 ok(!ret, "EnumFontFamiliesExW failed to find %s\n", wine_dbgstr_w(lf->lfFaceName));
525 hfont = CreateFontIndirectW(lf);
526 SelectObject(hdc, hfont);
528 otm.otmSize = sizeof(otm);
529 ret = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm);
530 ok(ret, "GetOutlineTextMetrics failed\n");
535 fm->lfHeight = -otm.otmTextMetrics.tmAscent;
536 fm->line_spacing = ntm.ntmCellHeight;
537 fm->font_size = (REAL)otm.otmTextMetrics.tmAscent;
538 fm->font_height = (REAL)fm->line_spacing * fm->font_size / (REAL)ntm.ntmSizeEM;
539 fm->em_height = ntm.ntmSizeEM;
540 fm->ascent = ntm.ntmSizeEM;
541 fm->descent = ntm.ntmCellHeight - ntm.ntmSizeEM;
544 static void gdip_get_font_metrics(GpFont *font, struct font_metrics *fm)
547 GpFontFamily *family;
550 stat = GdipGetFontStyle(font, &style);
553 stat = GdipGetFontHeight(font, NULL, &fm->font_height);
555 stat = GdipGetFontSize(font, &fm->font_size);
558 fm->lfHeight = (INT)(fm->font_size * -1.0);
560 stat = GdipGetFamily(font, &family);
563 stat = GdipGetEmHeight(family, style, &fm->em_height);
565 stat = GdipGetLineSpacing(family, style, &fm->line_spacing);
567 stat = GdipGetCellAscent(family, style, &fm->ascent);
569 stat = GdipGetCellDescent(family, style, &fm->descent);
572 GdipDeleteFontFamily(family);
575 static void cmp_font_metrics(struct font_metrics *fm1, struct font_metrics *fm2, int line)
577 ok_(__FILE__, line)(fm1->lfHeight == fm2->lfHeight, "lfHeight %d != %d\n", fm1->lfHeight, fm2->lfHeight);
578 ok_(__FILE__, line)(fm1->em_height == fm2->em_height, "em_height %u != %u\n", fm1->em_height, fm2->em_height);
579 ok_(__FILE__, line)(fm1->line_spacing == fm2->line_spacing, "line_spacing %u != %u\n", fm1->line_spacing, fm2->line_spacing);
580 ok_(__FILE__, line)(abs(fm1->ascent - fm2->ascent) <= 1, "ascent %u != %u\n", fm1->ascent, fm2->ascent);
581 ok_(__FILE__, line)(abs(fm1->descent - fm2->descent) <= 1, "descent %u != %u\n", fm1->descent, fm2->descent);
582 ok(fm1->font_height > 0.0, "fm1->font_height should be positive, got %f\n", fm1->font_height);
583 ok(fm2->font_height > 0.0, "fm2->font_height should be positive, got %f\n", fm2->font_height);
584 ok_(__FILE__, line)(fm1->font_height == fm2->font_height, "font_height %f != %f\n", fm1->font_height, fm2->font_height);
585 ok(fm1->font_size > 0.0, "fm1->font_size should be positive, got %f\n", fm1->font_size);
586 ok(fm2->font_size > 0.0, "fm2->font_size should be positive, got %f\n", fm2->font_size);
587 ok_(__FILE__, line)(fm1->font_size == fm2->font_size, "font_size %f != %f\n", fm1->font_size, fm2->font_size);
590 static void test_font_metrics(void)
594 GpFontFamily *family;
595 GpGraphics *graphics;
598 struct font_metrics fm_gdi, fm_gdip;
601 hdc = CreateCompatibleDC(0);
602 stat = GdipCreateFromHDC(hdc, &graphics);
605 memset(&lf, 0, sizeof(lf));
608 lstrcpyW(lf.lfFaceName, Tahoma);
610 stat = GdipCreateFontFromLogfontW(hdc, &lf, &font);
613 stat = GdipGetFontUnit(font, &unit);
615 expect(UnitWorld, unit);
617 gdip_get_font_metrics(font, &fm_gdip);
619 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
620 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
621 fm_gdip.em_height, fm_gdip.line_spacing, fm_gdip.ascent, fm_gdip.descent,
622 fm_gdip.font_height, fm_gdip.font_size);
624 gdi_get_font_metrics(&lf, &fm_gdi);
626 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
627 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
628 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
629 fm_gdi.font_height, fm_gdi.font_size);
631 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
633 stat = GdipGetLogFontW(font, graphics, &lf);
635 ok(lf.lfHeight < 0, "lf.lfHeight should be negative, got %d\n", lf.lfHeight);
636 gdi_get_font_metrics(&lf, &fm_gdi);
638 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
639 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
640 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
641 fm_gdi.font_height, fm_gdi.font_size);
642 ok((REAL)lf.lfHeight * -1.0 == fm_gdi.font_size, "expected %f, got %f\n", (REAL)lf.lfHeight * -1.0, fm_gdi.font_size);
644 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
646 GdipDeleteFont(font);
649 lstrcpyW(lf.lfFaceName, Tahoma);
651 stat = GdipCreateFontFromLogfontW(hdc, &lf, &font);
654 stat = GdipGetFontUnit(font, &unit);
656 expect(UnitWorld, unit);
658 gdip_get_font_metrics(font, &fm_gdip);
660 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
661 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
662 fm_gdip.em_height, fm_gdip.line_spacing, fm_gdip.ascent, fm_gdip.descent,
663 fm_gdip.font_height, fm_gdip.font_size);
665 gdi_get_font_metrics(&lf, &fm_gdi);
667 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
668 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
669 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
670 fm_gdi.font_height, fm_gdi.font_size);
672 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
674 stat = GdipGetLogFontW(font, graphics, &lf);
676 ok(lf.lfHeight < 0, "lf.lfHeight should be negative, got %d\n", lf.lfHeight);
677 gdi_get_font_metrics(&lf, &fm_gdi);
679 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
680 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
681 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
682 fm_gdi.font_height, fm_gdi.font_size);
683 ok((REAL)lf.lfHeight * -1.0 == fm_gdi.font_size, "expected %f, got %f\n", (REAL)lf.lfHeight * -1.0, fm_gdi.font_size);
685 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
687 GdipDeleteFont(font);
689 stat = GdipCreateFontFamilyFromName(Tahoma, NULL, &family);
693 stat = GdipCreateFont(family, 13.0, FontStyleRegular, UnitPixel, &font);
696 gdip_get_font_metrics(font, &fm_gdip);
698 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
699 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
700 fm_gdip.em_height, fm_gdip.line_spacing, fm_gdip.ascent, fm_gdip.descent,
701 fm_gdip.font_height, fm_gdip.font_size);
703 stat = GdipGetLogFontW(font, graphics, &lf);
705 ok(lf.lfHeight < 0, "lf.lfHeight should be negative, got %d\n", lf.lfHeight);
706 gdi_get_font_metrics(&lf, &fm_gdi);
708 trace("%s,%d: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
709 wine_dbgstr_w(lf.lfFaceName), lf.lfHeight,
710 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
711 fm_gdi.font_height, fm_gdi.font_size);
712 ok((REAL)lf.lfHeight * -1.0 == fm_gdi.font_size, "expected %f, got %f\n", (REAL)lf.lfHeight * -1.0, fm_gdi.font_size);
714 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
716 stat = GdipGetLogFontW(font, NULL, &lf);
717 expect(InvalidParameter, stat);
719 GdipDeleteFont(font);
721 stat = GdipCreateFont(family, -13.0, FontStyleRegular, UnitPixel, &font);
722 expect(InvalidParameter, stat);
724 GdipDeleteFontFamily(family);
726 GdipDeleteGraphics(graphics);
732 struct GdiplusStartupInput gdiplusStartupInput;
733 ULONG_PTR gdiplusToken;
735 gdiplusStartupInput.GdiplusVersion = 1;
736 gdiplusStartupInput.DebugEventCallback = NULL;
737 gdiplusStartupInput.SuppressBackgroundThread = 0;
738 gdiplusStartupInput.SuppressExternalCodecs = 0;
740 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
746 test_fontfamily_properties();
748 test_installedfonts();
749 test_heightgivendpi();
751 GdiplusShutdown(gdiplusToken);