~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/gdiplus/tests/font.c

Version: ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Unit test suite for fonts
  3  *
  4  * Copyright (C) 2007 Google (Evan Stade)
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "windows.h"
 22 #include "gdiplus.h"
 23 #include "wine/test.h"
 24 
 25 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 26 
 27 static const WCHAR arial[] = {'A','r','i','a','l','\0'};
 28 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'};
 29 static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
 30 static const WCHAR MicrosoftSansSerif[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
 31 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
 32 static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
 33 
 34 static const char *debugstr_w(LPCWSTR str)
 35 {
 36    static char buf[1024];
 37    WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
 38    return buf;
 39 }
 40 
 41 
 42 static void test_createfont(void)
 43 {
 44     GpFontFamily* fontfamily = NULL;
 45     GpFont* font = NULL;
 46     GpStatus stat;
 47     Unit unit;
 48     UINT i;
 49     REAL size;
 50 
 51     stat = GdipCreateFontFamilyFromName(nonexistent, NULL, &fontfamily);
 52     expect (FontFamilyNotFound, stat);
 53     stat = GdipDeleteFont(font);
 54     expect (InvalidParameter, stat);
 55     stat = GdipCreateFontFamilyFromName(arial, NULL, &fontfamily);
 56     if(stat == FontFamilyNotFound)
 57     {
 58         skip("Arial not installed\n");
 59         return;
 60     }
 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);
 67 
 68     /* Test to see if returned size is based on unit (its not) */
 69     GdipGetFontSize(font, &size);
 70     ok (size == 12, "Expected 12, got %f\n", size);
 71     GdipDeleteFont(font);
 72 
 73     /* Make sure everything is converted correctly for all Units */
 74     for (i = UnitWorld; i <=UnitMillimeter; i++)
 75     {
 76         if (i == UnitDisplay) continue; /* Crashes WindowsXP, wtf? */
 77         GdipCreateFont(fontfamily, 24, FontStyleRegular, i, &font);
 78         GdipGetFontSize (font, &size);
 79         ok (size == 24, "Expected 24, got %f (with unit: %d)\n", size, i);
 80         GdipGetFontUnit (font, &unit);
 81         expect (i, unit);
 82         GdipDeleteFont(font);
 83     }
 84 
 85     GdipDeleteFontFamily(fontfamily);
 86 }
 87 
 88 static void test_logfont(void)
 89 {
 90     LOGFONTW lfw, lfw2;
 91     GpFont *font;
 92     GpStatus stat;
 93     GpGraphics *graphics;
 94     HDC hdc = GetDC(0);
 95 
 96     GdipCreateFromHDC(hdc, &graphics);
 97     memset(&lfw, 0, sizeof(LOGFONTW));
 98     memset(&lfw2, 0xff, sizeof(LOGFONTW));
 99 
100     /* empty FaceName */
101     lfw.lfFaceName[0] = 0;
102     stat = GdipCreateFontFromLogfontW(hdc, &lfw, &font);
103 
104 todo_wine {
105     expect(NotTrueTypeFont, stat);
106 }
107 
108     memcpy(&lfw.lfFaceName, arial, 6 * sizeof(WCHAR));
109 
110     stat = GdipCreateFontFromLogfontW(hdc, &lfw, &font);
111     if (stat == FileNotFound)
112     {
113         skip("Arial not installed.\n");
114         return;
115     }
116     expect(Ok, stat);
117     stat = GdipGetLogFontW(font, graphics, &lfw2);
118     expect(Ok, stat);
119 
120     ok(lfw2.lfHeight < 0, "Expected negative height\n");
121     expect(0, lfw2.lfWidth);
122     expect(0, lfw2.lfEscapement);
123     expect(0, lfw2.lfOrientation);
124     ok((lfw2.lfWeight >= 100) && (lfw2.lfWeight <= 900), "Expected weight to be set\n");
125     expect(0, lfw2.lfItalic);
126     expect(0, lfw2.lfUnderline);
127     expect(0, lfw2.lfStrikeOut);
128     expect(0, lfw2.lfCharSet);
129     expect(0, lfw2.lfOutPrecision);
130     expect(0, lfw2.lfClipPrecision);
131     expect(0, lfw2.lfQuality);
132     expect(0, lfw2.lfPitchAndFamily);
133 
134     GdipDeleteFont(font);
135 
136     memset(&lfw, 0, sizeof(LOGFONTW));
137     lfw.lfHeight = 25;
138     lfw.lfWidth = 25;
139     lfw.lfEscapement = lfw.lfOrientation = 50;
140     lfw.lfItalic = lfw.lfUnderline = lfw.lfStrikeOut = TRUE;
141 
142     memset(&lfw2, 0xff, sizeof(LOGFONTW));
143     memcpy(&lfw.lfFaceName, arial, 6 * sizeof(WCHAR));
144 
145     stat = GdipCreateFontFromLogfontW(hdc, &lfw, &font);
146     expect(Ok, stat);
147     stat = GdipGetLogFontW(font, graphics, &lfw2);
148     expect(Ok, stat);
149 
150     ok(lfw2.lfHeight < 0, "Expected negative height\n");
151     expect(0, lfw2.lfWidth);
152     expect(0, lfw2.lfEscapement);
153     expect(0, lfw2.lfOrientation);
154     ok((lfw2.lfWeight >= 100) && (lfw2.lfWeight <= 900), "Expected weight to be set\n");
155     expect(TRUE, lfw2.lfItalic);
156     expect(TRUE, lfw2.lfUnderline);
157     expect(TRUE, lfw2.lfStrikeOut);
158     expect(0, lfw2.lfCharSet);
159     expect(0, lfw2.lfOutPrecision);
160     expect(0, lfw2.lfClipPrecision);
161     expect(0, lfw2.lfQuality);
162     expect(0, lfw2.lfPitchAndFamily);
163 
164     GdipDeleteFont(font);
165 
166     GdipDeleteGraphics(graphics);
167     ReleaseDC(0, hdc);
168 }
169 
170 static void test_fontfamily (void)
171 {
172     GpFontFamily *family, *clonedFontFamily;
173     WCHAR itsName[LF_FACESIZE];
174     GpStatus stat;
175 
176     /* FontFamily cannot be NULL */
177     stat = GdipCreateFontFamilyFromName (arial , NULL, NULL);
178     expect (InvalidParameter, stat);
179 
180     /* FontFamily must be able to actually find the family.
181      * If it can't, any subsequent calls should fail.
182      */
183     stat = GdipCreateFontFamilyFromName (nonexistent, NULL, &family);
184     expect (FontFamilyNotFound, stat);
185 
186     /* Bitmap fonts are not found */
187 todo_wine
188 {
189     stat = GdipCreateFontFamilyFromName (MSSansSerif, NULL, &family);
190     expect (FontFamilyNotFound, stat);
191 }
192 
193     stat = GdipCreateFontFamilyFromName (arial, NULL, &family);
194     if(stat == FontFamilyNotFound)
195     {
196         skip("Arial not installed\n");
197         return;
198     }
199     expect (Ok, stat);
200 
201     stat = GdipGetFamilyName (family, itsName, LANG_NEUTRAL);
202     expect (Ok, stat);
203     expect (0, lstrcmpiW(itsName, arial));
204 
205     if (0)
206     {
207         /* Crashes on Windows XP SP2, Vista, and so Wine as well */
208         stat = GdipGetFamilyName (family, NULL, LANG_NEUTRAL);
209         expect (Ok, stat);
210     }
211 
212     /* Make sure we don't read old data */
213     ZeroMemory (itsName, sizeof(itsName));
214     stat = GdipCloneFontFamily(family, &clonedFontFamily);
215     expect (Ok, stat);
216     GdipDeleteFontFamily(family);
217     stat = GdipGetFamilyName(clonedFontFamily, itsName, LANG_NEUTRAL);
218     expect(Ok, stat);
219     expect(0, lstrcmpiW(itsName, arial));
220 
221     GdipDeleteFontFamily(clonedFontFamily);
222 }
223 
224 static void test_fontfamily_properties (void)
225 {
226     GpFontFamily* FontFamily = NULL;
227     GpStatus stat;
228     UINT16 result = 0;
229 
230     stat = GdipCreateFontFamilyFromName(arial, NULL, &FontFamily);
231     if(stat == FontFamilyNotFound)
232         skip("Arial not installed\n");
233     else
234     {
235 todo_wine
236 {
237         stat = GdipGetLineSpacing(FontFamily, FontStyleRegular, &result);
238         expect(Ok, stat);
239         ok (result == 2355, "Expected 2355, got %d\n", result);
240 }
241         result = 0;
242         stat = GdipGetEmHeight(FontFamily, FontStyleRegular, &result);
243         expect(Ok, stat);
244         ok(result == 2048, "Expected 2048, got %d\n", result);
245         result = 0;
246         stat = GdipGetCellAscent(FontFamily, FontStyleRegular, &result);
247         expect(Ok, stat);
248         ok(result == 1854, "Expected 1854, got %d\n", result);
249         result = 0;
250         stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
251         ok(result == 434, "Expected 434, got %d\n", result);
252         GdipDeleteFontFamily(FontFamily);
253     }
254 
255     stat = GdipCreateFontFamilyFromName(TimesNewRoman, NULL, &FontFamily);
256     if(stat == FontFamilyNotFound)
257         skip("Times New Roman not installed\n");
258     else
259     {
260         result = 0;
261 todo_wine
262 {
263         stat = GdipGetLineSpacing(FontFamily, FontStyleRegular, &result);
264         expect(Ok, stat);
265         ok(result == 2355, "Expected 2355, got %d\n", result);
266 }
267         result = 0;
268         stat = GdipGetEmHeight(FontFamily, FontStyleRegular, &result);
269         expect(Ok, stat);
270         ok(result == 2048, "Expected 2048, got %d\n", result);
271         result = 0;
272         stat = GdipGetCellAscent(FontFamily, FontStyleRegular, &result);
273         expect(Ok, stat);
274         ok(result == 1825, "Expected 1825, got %d\n", result);
275         result = 0;
276         stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
277         ok(result == 443, "Expected 443 got %d\n", result);
278         GdipDeleteFontFamily(FontFamily);
279     }
280 }
281 
282 static void test_getgenerics (void)
283 {
284     GpStatus stat;
285     GpFontFamily* family;
286     WCHAR familyName[LF_FACESIZE];
287     ZeroMemory(familyName, sizeof(familyName)/sizeof(WCHAR));
288 
289     stat = GdipGetGenericFontFamilySansSerif (&family);
290     if (stat == FontFamilyNotFound)
291     {
292         skip("Microsoft Sans Serif not installed\n");
293         goto serif;
294     }
295     expect (Ok, stat);
296     stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
297     expect (Ok, stat);
298     ok ((lstrcmpiW(familyName, MicrosoftSansSerif) == 0) ||
299         (lstrcmpiW(familyName,MSSansSerif) == 0),
300         "Expected Microsoft Sans Serif or MS Sans Serif, got %s\n",
301         debugstr_w(familyName));
302     stat = GdipDeleteFontFamily (family);
303     expect (Ok, stat);
304 
305 serif:
306     stat = GdipGetGenericFontFamilySerif (&family);
307     if (stat == FontFamilyNotFound)
308     {
309         skip("Times New Roman not installed\n");
310         goto monospace;
311     }
312     expect (Ok, stat);
313     stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
314     expect (Ok, stat);
315     ok (lstrcmpiW(familyName, TimesNewRoman) == 0,
316         "Expected Times New Roman, got %s\n", debugstr_w(familyName));
317     stat = GdipDeleteFontFamily (family);
318     expect (Ok, stat);
319 
320 monospace:
321     stat = GdipGetGenericFontFamilyMonospace (&family);
322     if (stat == FontFamilyNotFound)
323     {
324         skip("Courier New not installed\n");
325         return;
326     }
327     expect (Ok, stat);
328     stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
329     expect (Ok, stat);
330     ok (lstrcmpiW(familyName, CourierNew) == 0,
331         "Expected Courier New, got %s\n", debugstr_w(familyName));
332     stat = GdipDeleteFontFamily (family);
333     expect (Ok, stat);
334 }
335 
336 START_TEST(font)
337 {
338     struct GdiplusStartupInput gdiplusStartupInput;
339     ULONG_PTR gdiplusToken;
340 
341     gdiplusStartupInput.GdiplusVersion              = 1;
342     gdiplusStartupInput.DebugEventCallback          = NULL;
343     gdiplusStartupInput.SuppressBackgroundThread    = 0;
344     gdiplusStartupInput.SuppressExternalCodecs      = 0;
345 
346     GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
347 
348     test_createfont();
349     test_logfont();
350     test_fontfamily();
351     test_fontfamily_properties();
352     test_getgenerics();
353 
354     GdiplusShutdown(gdiplusToken);
355 }
356 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.