diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index c53bf1a12a..5862b1cf26 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -4213,6 +4213,13 @@ ftGdiGetGlyphOutline( return needed; } +/* Forward function definition to be used in TextIntGetTextExentPoint */ +LONG FASTCALL +IntGetFontFamilyInfo(HDC Dc, + const LOGFONTW *SafeLogFont, + PFONTFAMILYINFO SafeInfo, + LONG InfoCount); + BOOL FASTCALL TextIntGetTextExtentPoint(PDC dc, @@ -4238,6 +4245,13 @@ TextIntGetTextExtentPoint(PDC dc, LOGFONTW *plf; BOOL EmuBold, EmuItalic; LONG ascender, descender; + LOGFONTW lf; + ULONG DataSize; + PFONTFAMILYINFO Info; + LONG InfoCount; + int FontFamilyCount = 0; + HDC hDC = NULL; + BYTE bCorrPF; FontGDI = ObjToGDI(TextObj->Font, FONT); @@ -4345,10 +4359,36 @@ TextIntGetTextExtentPoint(PDC dc, String++; } ASSERT(FontGDI->Magic == FONTGDI_MAGIC); - ascender = FontGDI->tmAscent; /* Units above baseline */ - descender = FontGDI->tmDescent; /* Units below baseline */ IntUnLockFreeType(); + /* Calling IntGetFontFamilyInfo gets PitchAndFamily reliably */ + + /* Initialize the LOGFONT structure */ + RtlZeroMemory(&lf, sizeof(lf)); + lf.lfCharSet = 1; // Default; + wcscpy(lf.lfFaceName, plf->lfFaceName); // our facename + + DataSize = sizeof(FONTFAMILYINFO); + Info = ExAllocatePoolWithTag(PagedPool, DataSize, TAG_FONT); + RtlZeroMemory(Info, DataSize); + InfoCount = 1; + + /* Get the correct textmetrics for our font */ + FontFamilyCount = IntGetFontFamilyInfo(hDC, &lf, Info, InfoCount); + + bCorrPF = Info->NewTextMetricEx.ntmTm.tmPitchAndFamily; // Correct PitchAndFamily + + if (FontFamilyCount && ((bCorrPF & 0x30) == 0x30) | ((bCorrPF & 1) == 1)) + { + ascender = (face->size->metrics.ascender + 32) >> 6; /* Old Units above baseline */ + descender = (32 - face->size->metrics.descender) >> 6; /* Units below baseline */ + } + else + { + ascender = FontGDI->tmAscent; /* New Units above baseline */ + descender = FontGDI->tmDescent; /* New Units below baseline */ + } + Size->cx = (TotalWidth64 + 32) >> 6; Size->cy = ascender + descender;