From 99c3b4ec5718c48dc76d3ca04f10aa94a7e76172 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Fri, 15 Apr 2011 20:03:44 +0000 Subject: [PATCH] [WIN32K] * Revert part of 37148. One FontGDI is used for fonts with different sizes. Do not cache font metrics then and instead calculate them every time when needed. It fixes spacing in menus if some application uses default GUI font with size other than 11. See issue #4106 for more details. svn path=/trunk/; revision=51356 --- .../win32/win32k/include/engobjects.h | 5 --- .../win32/win32k/objects/freetype.c | 40 ++----------------- 2 files changed, 4 insertions(+), 41 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/engobjects.h b/reactos/subsystems/win32/win32k/include/engobjects.h index afb09204874..d26e18eef15 100644 --- a/reactos/subsystems/win32/win32k/include/engobjects.h +++ b/reactos/subsystems/win32/win32k/include/engobjects.h @@ -88,9 +88,6 @@ typedef struct _FLOATGDI { ULONG Dummy; } FLOATGDI; - -#define FDM_TYPE_TEXT_METRIC 0x80000000 - typedef struct _FONTGDI { FONTOBJ FontObj; ULONG iUnique; @@ -99,13 +96,11 @@ typedef struct _FONTGDI { DHPDEV dhpdev; FT_Face face; }; - FLONG flRealizedType; LONG lMaxNegA; LONG lMaxNegC; LONG lMinWidthD; - TEXTMETRICW TextMetric; LPWSTR Filename; BYTE Underline; BYTE StrikeOut; diff --git a/reactos/subsystems/win32/win32k/objects/freetype.c b/reactos/subsystems/win32/win32k/objects/freetype.c index c7086fd39d4..994d513f32f 100644 --- a/reactos/subsystems/win32/win32k/objects/freetype.c +++ b/reactos/subsystems/win32/win32k/objects/freetype.c @@ -302,9 +302,6 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics) PSECTION_OBJECT SectionObject; ULONG ViewSize = 0; LARGE_INTEGER SectionSize; -#if 0 // Wine code - FT_Fixed XScale, YScale; -#endif UNICODE_STRING FontRegPath = RTL_CONSTANT_STRING(L"\\REGISTRY\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"); /* Open the font file */ @@ -396,22 +393,6 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics) FontGDI->Filename[FileName->Length / sizeof(WCHAR)] = L'\0'; FontGDI->face = Face; - /* FIXME: Complete text metrics */ -#if 0 /* This (Wine) code doesn't seem to work correctly for us */ - XScale = Face->size->metrics.x_scale; - YScale = Face->size->metrics.y_scale; - FontGDI->TextMetric.tmAscent = (FT_MulFix(Face->ascender, YScale) + 32) >> 6; - FontGDI->TextMetric.tmDescent = (FT_MulFix(Face->descender, YScale) + 32) >> 6; - FontGDI->TextMetric.tmHeight = (FT_MulFix(Face->ascender, YScale) - - FT_MulFix(Face->descender, YScale)) >> 6; -#else - FontGDI->TextMetric.tmAscent = (Face->size->metrics.ascender + 32) >> 6; /* units above baseline */ - FontGDI->TextMetric.tmDescent = (32 - Face->size->metrics.descender) >> 6; /* units below baseline */ - FontGDI->TextMetric.tmHeight = (Face->size->metrics.ascender - Face->size->metrics.descender) >> 6; -#endif - - - DPRINT("Font loaded: %s (%s)\n", Face->family_name, Face->style_name); DPRINT("Num glyphs: %u\n", Face->num_glyphs); @@ -856,14 +837,7 @@ IntGetOutlineTextMetrics(PFONTGDI FontGDI, Otm->otmSize = Needed; -// FillTM(&Otm->otmTextMetrics, FontGDI, pOS2, pHori, !Error ? &Win : 0); - if (!(FontGDI->flRealizedType & FDM_TYPE_TEXT_METRIC)) - { - FillTM(&FontGDI->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0); - FontGDI->flRealizedType |= FDM_TYPE_TEXT_METRIC; - } - - RtlCopyMemory(&Otm->otmTextMetrics, &FontGDI->TextMetric, sizeof(TEXTMETRICW)); + FillTM(&Otm->otmTextMetrics, FontGDI, pOS2, pHori, !Error ? &Win : 0); Otm->otmFiller = 0; RtlCopyMemory(&Otm->otmPanoseNumber, pOS2->panose, PANOSE_COUNT); @@ -882,8 +856,8 @@ IntGetOutlineTextMetrics(PFONTGDI FontGDI, Otm->otmrcFontBox.right = (FT_MulFix(FontGDI->face->bbox.xMax, XScale) + 32) >> 6; Otm->otmrcFontBox.top = (FT_MulFix(FontGDI->face->bbox.yMax, YScale) + 32) >> 6; Otm->otmrcFontBox.bottom = (FT_MulFix(FontGDI->face->bbox.yMin, YScale) + 32) >> 6; - Otm->otmMacAscent = FontGDI->TextMetric.tmAscent; - Otm->otmMacDescent = -FontGDI->TextMetric.tmDescent; + Otm->otmMacAscent = Otm->otmTextMetrics.tmAscent; + Otm->otmMacDescent = -Otm->otmTextMetrics.tmDescent; Otm->otmMacLineGap = Otm->otmLineGap; Otm->otmusMinimumPPEM = 0; /* TT Header */ Otm->otmptSubscriptSize.x = (FT_MulFix(pOS2->ySubscriptXSize, XScale) + 32) >> 6; @@ -2512,13 +2486,8 @@ ftGdiGetTextMetricsW( if (NT_SUCCESS(Status)) { - if (!(FontGDI->flRealizedType & FDM_TYPE_TEXT_METRIC)) - { - FillTM(&FontGDI->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0); - FontGDI->flRealizedType |= FDM_TYPE_TEXT_METRIC; - } + FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0); - RtlCopyMemory(&ptmwi->TextMetric, &FontGDI->TextMetric, sizeof(TEXTMETRICW)); /* FIXME: Fill Diff member */ RtlZeroMemory(&ptmwi->Diff, sizeof(ptmwi->Diff)); } @@ -2814,7 +2783,6 @@ TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj) TextObj->Font->iUniq = 1; // Now it can be cached. IntFontType(FontGdi); FontGdi->flType = TextObj->Font->flFontType; - FontGdi->flRealizedType = 0; FontGdi->Underline = TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfUnderline ? 0xff : 0; FontGdi->StrikeOut = TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfStrikeOut ? 0xff : 0; TextObj->fl |= TEXTOBJECT_INIT;