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