Esempio n. 1
0
static void test_fontfamily_properties (void)
{
    GpFontFamily* FontFamily = NULL;
    GpStatus stat;
    UINT16 result = 0;

    stat = GdipCreateFontFamilyFromName(arial, NULL, &FontFamily);
    if(stat == FontFamilyNotFound)
        skip("Arial not installed\n");
    else
    {
        stat = GdipGetLineSpacing(FontFamily, FontStyleRegular, &result);
        expect(Ok, stat);
        ok (result == 2355, "Expected 2355, got %d\n", result);
        result = 0;
        stat = GdipGetEmHeight(FontFamily, FontStyleRegular, &result);
        expect(Ok, stat);
        ok(result == 2048, "Expected 2048, got %d\n", result);
        result = 0;
        stat = GdipGetCellAscent(FontFamily, FontStyleRegular, &result);
        expect(Ok, stat);
        ok(result == 1854, "Expected 1854, got %d\n", result);
        result = 0;
        stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
        ok(result == 434, "Expected 434, got %d\n", result);
        GdipDeleteFontFamily(FontFamily);
    }

    stat = GdipCreateFontFamilyFromName(TimesNewRoman, NULL, &FontFamily);
    if(stat == FontFamilyNotFound)
        skip("Times New Roman not installed\n");
    else
    {
        result = 0;
        stat = GdipGetLineSpacing(FontFamily, FontStyleRegular, &result);
        expect(Ok, stat);
        ok(result == 2355, "Expected 2355, got %d\n", result);
        result = 0;
        stat = GdipGetEmHeight(FontFamily, FontStyleRegular, &result);
        expect(Ok, stat);
        ok(result == 2048, "Expected 2048, got %d\n", result);
        result = 0;
        stat = GdipGetCellAscent(FontFamily, FontStyleRegular, &result);
        expect(Ok, stat);
        ok(result == 1825, "Expected 1825, got %d\n", result);
        result = 0;
        stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
        ok(result == 443, "Expected 443 got %d\n", result);
        GdipDeleteFontFamily(FontFamily);
    }
}
Esempio n. 2
0
File: font.c Progetto: Dietr1ch/wine
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);
}
Esempio n. 3
0
static GF_Err gdip_get_font_info(GF_FontReader *dr, char **font_name, s32 *em_size, s32 *ascent, s32 *descent, s32 *underline, s32 *line_spacing, s32 *max_advance_h, s32 *max_advance_v)
{
	UINT16 val, em;
	FontPriv *ctx = (FontPriv *)dr->udta;

	*font_name = NULL;
	*em_size = *ascent = *descent = *line_spacing = *max_advance_h = *max_advance_v = 0;
	if (!ctx->font) return GF_BAD_PARAM;

	GdipGetEmHeight(ctx->font, ctx->font_style, &em);
	*em_size = (s32) em;
	GdipGetCellAscent(ctx->font, ctx->font_style, &val);
	ctx->ascent = (Float) val;
	*ascent = (s32) val;
	GdipGetCellDescent(ctx->font, ctx->font_style, &val);
	*descent = (s32) val; *descent *= -1;
	ctx->descent = -1 * (Float) val;
	*underline = *descent / 2;
	GdipGetLineSpacing(ctx->font, ctx->font_style, &val);
	*line_spacing = (s32) val;
	*max_advance_v = *ascent - *descent;


	unsigned short test_str[4];
	Fixed w, h, w2;
	ctx->em_size = (Float) *em_size;
	test_str[0] = (unsigned short) '_';
	test_str[1] = (unsigned short) '\0';
	gdip_get_text_size(dr, test_str, &w, &h);
	ctx->underscore_width = FIX2FLT(w);

	test_str[0] = (unsigned short) '_';
	test_str[1] = (unsigned short) ' ';
	test_str[2] = (unsigned short) '_';
	test_str[3] = (unsigned short) '\0';
	gdip_get_text_size(dr, test_str, &w2, &h);
	ctx->whitespace_width = FIX2FLT(w2 - 2*w);

	*max_advance_h = (s32) MAX(ctx->underscore_width, ctx->whitespace_width);
	return GF_OK;
}
Esempio n. 4
0
static M4Err gdip_get_font_metrics(FontRaster *dr, Float *ascent, Float *descent, Float *lineSpacing)
{
	UINT16 val, em;
	FontPriv *ctx = (FontPriv *)dr->priv;

	*ascent = *descent = *lineSpacing = 0.0;
	if (!ctx->font) return M4BadParam;


	GdipGetEmHeight(ctx->font, ctx->font_style, &em);
	GdipGetCellAscent(ctx->font, ctx->font_style, &val);
	*ascent = ctx->font_size * val;
	*ascent /= em;

	GdipGetCellDescent(ctx->font, ctx->font_style, &val);
	*descent = ctx->font_size * val;
	*descent /= em;

	GdipGetLineSpacing(ctx->font, ctx->font_style, &val);
	*lineSpacing = ctx->font_size * val;
	*lineSpacing /= em;
	return M4OK;
}