static void test_createfont(void) { GpFontFamily* fontfamily = NULL, *fontfamily2; GpFont* font = NULL; GpStatus stat; Unit unit; UINT i; REAL size; WCHAR familyname[LF_FACESIZE]; stat = GdipCreateFontFamilyFromName(nonexistent, NULL, &fontfamily); expect (FontFamilyNotFound, stat); stat = GdipDeleteFont(font); expect (InvalidParameter, stat); stat = GdipCreateFontFamilyFromName(arial, NULL, &fontfamily); if(stat == FontFamilyNotFound) { skip("Arial not installed\n"); return; } expect (Ok, stat); stat = GdipCreateFont(fontfamily, 12, FontStyleRegular, UnitPoint, &font); expect (Ok, stat); stat = GdipGetFontUnit (font, &unit); expect (Ok, stat); expect (UnitPoint, unit); stat = GdipGetFamily(font, &fontfamily2); expect(Ok, stat); stat = GdipGetFamilyName(fontfamily2, familyname, 0); expect(Ok, stat); ok (lstrcmpiW(arial, familyname) == 0, "Expected arial, got %s\n", debugstr_w(familyname)); stat = GdipDeleteFontFamily(fontfamily2); expect(Ok, stat); /* Test to see if returned size is based on unit (its not) */ GdipGetFontSize(font, &size); ok (size == 12, "Expected 12, got %f\n", size); GdipDeleteFont(font); /* Make sure everything is converted correctly for all Units */ for (i = UnitWorld; i <=UnitMillimeter; i++) { if (i == UnitDisplay) continue; /* Crashes WindowsXP, wtf? */ GdipCreateFont(fontfamily, 24, FontStyleRegular, i, &font); GdipGetFontSize (font, &size); ok (size == 24, "Expected 24, got %f (with unit: %d)\n", size, i); GdipGetFontUnit (font, &unit); expect (i, unit); GdipDeleteFont(font); } GdipDeleteFontFamily(fontfamily); }
static void gdip_get_font_metrics(GpFont *font, struct font_metrics *fm) { INT style; GpFontFamily *family; GpStatus stat; stat = GdipGetFontStyle(font, &style); expect(Ok, stat); stat = GdipGetFontHeight(font, NULL, &fm->font_height); expect(Ok, stat); stat = GdipGetFontSize(font, &fm->font_size); expect(Ok, stat); fm->lfHeight = (INT)(fm->font_size * -1.0); stat = GdipGetFamily(font, &family); expect(Ok, stat); stat = GdipGetEmHeight(family, style, &fm->em_height); expect(Ok, stat); stat = GdipGetLineSpacing(family, style, &fm->line_spacing); expect(Ok, stat); stat = GdipGetCellAscent(family, style, &fm->ascent); expect(Ok, stat); stat = GdipGetCellDescent(family, style, &fm->descent); expect(Ok, stat); GdipDeleteFontFamily(family); }
static void test_createfont(void) { GpFontFamily* fontfamily = NULL; GpFont* font = NULL; GpStatus stat; Unit unit; UINT i; REAL size; stat = GdipCreateFontFamilyFromName(nonexistant, NULL, &fontfamily); expect (FontFamilyNotFound, stat); stat = GdipDeleteFont(font); expect (InvalidParameter, stat); stat = GdipCreateFontFamilyFromName(arial, NULL, &fontfamily); expect (Ok, stat); stat = GdipCreateFont(fontfamily, 12, FontStyleRegular, UnitPoint, &font); expect (Ok, stat); stat = GdipGetFontUnit (font, &unit); expect (Ok, stat); expect (UnitPoint, unit); /* Test to see if returned size is based on unit (its not) */ GdipGetFontSize(font, &size); ok (size == 12, "Expected 12, got %f\n", size); GdipDeleteFont(font); /* Make sure everything is converted correctly for all Units */ for (i = UnitWorld; i <=UnitMillimeter; i++) { if (i == UnitDisplay) continue; /* Crashes WindowsXP, wtf? */ GdipCreateFont(fontfamily, 24, FontStyleRegular, i, &font); GdipGetFontSize (font, &size); ok (size == 24, "Expected 24, got %f (with unit: %d)\n", size, i); GdipGetFontUnit (font, &unit); expect (i, unit); GdipDeleteFont(font); } }
static void test_logfont(void) { LOGFONTA lfa, lfa2; GpFont *font; GpFontFamily *family; GpStatus stat; GpGraphics *graphics; HDC hdc = GetDC(0); INT style; REAL rval; UINT16 em_height, line_spacing; Unit unit; GdipCreateFromHDC(hdc, &graphics); memset(&lfa, 0, sizeof(LOGFONTA)); memset(&lfa2, 0xff, sizeof(LOGFONTA)); lstrcpyA(lfa.lfFaceName, "Tahoma"); stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font); expect(Ok, stat); stat = GdipGetLogFontA(font, graphics, &lfa2); expect(Ok, stat); ok(lfa2.lfHeight < 0, "Expected negative height\n"); expect(0, lfa2.lfWidth); expect(0, lfa2.lfEscapement); expect(0, lfa2.lfOrientation); ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n"); expect(0, lfa2.lfItalic); expect(0, lfa2.lfUnderline); expect(0, lfa2.lfStrikeOut); ok(lfa2.lfCharSet == GetTextCharset(hdc) || lfa2.lfCharSet == ANSI_CHARSET, "Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet); expect(0, lfa2.lfOutPrecision); expect(0, lfa2.lfClipPrecision); expect(0, lfa2.lfQuality); expect(0, lfa2.lfPitchAndFamily); GdipDeleteFont(font); memset(&lfa, 0, sizeof(LOGFONTA)); lfa.lfHeight = 25; lfa.lfWidth = 25; lfa.lfEscapement = lfa.lfOrientation = 50; lfa.lfItalic = lfa.lfUnderline = lfa.lfStrikeOut = TRUE; memset(&lfa2, 0xff, sizeof(LOGFONTA)); lstrcpyA(lfa.lfFaceName, "Tahoma"); stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font); expect(Ok, stat); stat = GdipGetLogFontA(font, graphics, &lfa2); expect(Ok, stat); ok(lfa2.lfHeight < 0, "Expected negative height\n"); expect(0, lfa2.lfWidth); expect(0, lfa2.lfEscapement); expect(0, lfa2.lfOrientation); ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n"); expect(TRUE, lfa2.lfItalic); expect(TRUE, lfa2.lfUnderline); expect(TRUE, lfa2.lfStrikeOut); ok(lfa2.lfCharSet == GetTextCharset(hdc) || lfa2.lfCharSet == ANSI_CHARSET, "Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet); expect(0, lfa2.lfOutPrecision); expect(0, lfa2.lfClipPrecision); expect(0, lfa2.lfQuality); expect(0, lfa2.lfPitchAndFamily); stat = GdipGetFontStyle(font, &style); expect(Ok, stat); ok (style == (FontStyleItalic | FontStyleUnderline | FontStyleStrikeout), "Expected , got %d\n", style); stat = GdipGetFontUnit(font, &unit); expect(Ok, stat); expect(UnitWorld, unit); stat = GdipGetFontHeight(font, graphics, &rval); expect(Ok, stat); expectf(25.347656, rval); stat = GdipGetFontSize(font, &rval); expect(Ok, stat); expectf(21.0, rval); stat = GdipGetFamily(font, &family); expect(Ok, stat); stat = GdipGetEmHeight(family, FontStyleRegular, &em_height); expect(Ok, stat); expect(2048, em_height); stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing); expect(Ok, stat); expect(2472, line_spacing); GdipDeleteFontFamily(family); GdipDeleteFont(font); memset(&lfa, 0, sizeof(lfa)); lfa.lfHeight = -25; lstrcpyA(lfa.lfFaceName, "Tahoma"); stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font); expect(Ok, stat); memset(&lfa2, 0xff, sizeof(lfa2)); stat = GdipGetLogFontA(font, graphics, &lfa2); expect(Ok, stat); expect(lfa.lfHeight, lfa2.lfHeight); stat = GdipGetFontUnit(font, &unit); expect(Ok, stat); expect(UnitWorld, unit); stat = GdipGetFontHeight(font, graphics, &rval); expect(Ok, stat); expectf(30.175781, rval); stat = GdipGetFontSize(font, &rval); expect(Ok, stat); expectf(25.0, rval); stat = GdipGetFamily(font, &family); expect(Ok, stat); stat = GdipGetEmHeight(family, FontStyleRegular, &em_height); expect(Ok, stat); expect(2048, em_height); stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing); expect(Ok, stat); expect(2472, line_spacing); GdipDeleteFontFamily(family); GdipDeleteFont(font); GdipDeleteGraphics(graphics); ReleaseDC(0, hdc); }