Exemple #1
0
static void test_returns(void)
{
    IFont *pFont;
    FONTDESC fontdesc;
    HRESULT hr;

    fontdesc.cbSizeofstruct = sizeof(fontdesc);
    fontdesc.lpstrName = MSSansSerif_font;
    fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */
    fontdesc.sWeight = FW_NORMAL;
    fontdesc.sCharset = 0;
    fontdesc.fItalic = FALSE;
    fontdesc.fUnderline = FALSE;
    fontdesc.fStrikethrough = FALSE;

    hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&pFont);
    EXPECT_HR(hr, S_OK);

    hr = IFont_put_Name(pFont, NULL);
    EXPECT_HR(hr, CTL_E_INVALIDPROPERTYVALUE);

    hr = IFont_get_Name(pFont, NULL);
    EXPECT_HR(hr, E_POINTER);

    hr = IFont_get_Size(pFont, NULL);
    EXPECT_HR(hr, E_POINTER);

    hr = IFont_get_Bold(pFont, NULL);
    EXPECT_HR(hr, E_POINTER);

    IFont_Release(pFont);
}
Exemple #2
0
/* Various checks along the way.                         */
static void test_ifont_size(LONG lo_size, LONG hi_size,
	LONG ratio_logical, LONG ratio_himetric,
	LONG hfont_height, const char * test_name)
{
	FONTDESC fd;
	LPVOID pvObj = NULL;
	IFont* ifnt = NULL;
	HFONT hfont;
	LOGFONTA lf;
	CY psize;
	HRESULT hres;
        DWORD rtnval;

	fd.cbSizeofstruct = sizeof(FONTDESC);
	fd.lpstrName      = arial_font; /* using scalable instead of bitmap font reduces errors due to font realization */
	S(fd.cySize).Lo   = lo_size;
	S(fd.cySize).Hi   = hi_size;
	fd.sWeight        = 0;
	fd.sCharset       = 0;
        fd.fItalic        = FALSE;
        fd.fUnderline     = FALSE;
        fd.fStrikethrough = FALSE;

	/* Create font, test that it worked. */
	hres = pOleCreateFontIndirect(&fd, &IID_IFont, &pvObj);
	ifnt = pvObj;
	ok(hres == S_OK,"%s: OCFI returns 0x%08x instead of S_OK.\n",
		test_name, hres);
	ok(pvObj != NULL,"%s: OCFI returns NULL.\n", test_name);

        /* Change the scaling ratio */
        hres = IFont_SetRatio(ifnt, ratio_logical, ratio_himetric);
        ok((ratio_logical && ratio_himetric) ? hres == S_OK : hres == E_FAIL,
           "%s: IFont_SetRatio unexpectedly returned 0x%08x.\n", test_name, hres);

	/* Read back size. */
	hres = IFont_get_Size(ifnt, &psize);
	ok(hres == S_OK,"%s: IFont_get_size returns 0x%08x instead of S_OK.\n",
		test_name, hres);

        /* Check returned size - allow for errors due to rounding & font realization. */
	ok((abs(S(psize).Lo - lo_size) < 10000) && S(psize).Hi == hi_size,
		"%s: IFont_get_Size: Lo=%d, Hi=%d; expected Lo=%d, Hi=%d.\n",
		test_name, S(psize).Lo, S(psize).Hi, lo_size, hi_size);

	/* Check hFont size. */
	hres = IFont_get_hFont (ifnt, &hfont);
	ok(hres == S_OK, "%s: IFont_get_hFont returns 0x%08x instead of S_OK.\n",
		test_name, hres);
	rtnval = GetObjectA(hfont, sizeof(LOGFONTA), &lf);
        ok(rtnval > 0, "GetObject(hfont) failed\n");

        /* Since font scaling may encounter rounding errors, allow 1 pixel deviation. */
	ok(abs(lf.lfHeight - hfont_height) <= 1,
		"%s: hFont has lf.lfHeight=%d, expected %d.\n",
		test_name, lf.lfHeight, hfont_height);

	/* Free IFont. */
	IFont_Release(ifnt);
}
Exemple #3
0
static void test_ifont_sizes(LONG lo_size, LONG hi_size,
                             LONG ratio_logical, LONG ratio_himetric,
                             LONG hfont_height, const char * test_name)
{
    FONTDESC fd;
    LPVOID pvObj = NULL;
    IFont* ifnt = NULL;
    HFONT hfont;
    LOGFONT lf;
    CY psize;
    HRESULT hres;

    fd.cbSizeofstruct = sizeof(FONTDESC);
    fd.lpstrName      = system_font;
    S(fd.cySize).Lo   = lo_size;
    S(fd.cySize).Hi   = hi_size;
    fd.sWeight        = 0;
    fd.sCharset       = 0;
    fd.fItalic        = 0;
    fd.fUnderline     = 0;
    fd.fStrikethrough = 0;

    /* Create font, test that it worked. */
    hres = pOleCreateFontIndirect(&fd, &IID_IFont, &pvObj);
    ifnt = pvObj;
    ok(hres == S_OK,"%s: OCFI returns 0x%08x instead of S_OK.\n",
       test_name, hres);
    ok(pvObj != NULL,"%s: OCFI returns NULL.\n", test_name);

    /* Read back size.  Hi part was ignored. */
    hres = IFont_get_Size(ifnt, &psize);
    ok(hres == S_OK,"%s: IFont_get_size returns 0x%08x instead of S_OK.\n",
       test_name, hres);
    ok(S(psize).Lo == lo_size && S(psize).Hi == 0,
       "%s: get_Size: Lo=%d, Hi=%d; expected Lo=%d, Hi=0.\n",
       test_name, S(psize).Lo, S(psize).Hi, lo_size);

    /* Change ratio, check size unchanged.  Standard is 72, 2540. */
    hres = IFont_SetRatio(ifnt, ratio_logical, ratio_himetric);
    ok(hres == S_OK,"%s: IFont_SR returns 0x%08x instead of S_OK.\n",
       test_name, hres);
    hres = IFont_get_Size(ifnt, &psize);
    ok(hres == S_OK,"%s: IFont_get_size returns 0x%08x instead of S_OK.\n",
       test_name, hres);
    ok(S(psize).Lo == lo_size && S(psize).Hi == 0,
       "%s: gS after SR: Lo=%d, Hi=%d; expected Lo=%d, Hi=0.\n",
       test_name, S(psize).Lo, S(psize).Hi, lo_size);

    /* Check hFont size with this ratio.  This tests an important 	*/
    /* conversion for which MSDN is very wrong.			*/
    hres = IFont_get_hFont (ifnt, &hfont);
    ok(hres == S_OK, "%s: IFont_get_hFont returns 0x%08x instead of S_OK.\n",
       test_name, hres);
    hres = GetObject (hfont, sizeof(LOGFONT), &lf);
    ok(lf.lfHeight == hfont_height,
       "%s: hFont has lf.lfHeight=%d, expected %d.\n",
       test_name, lf.lfHeight, hfont_height);

    /* Free IFont. */
    IFont_Release(ifnt);
}