From fd078014d8aea648db8e9cd0801a1d405a8abcf1 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Mon, 3 Dec 2018 20:28:20 +0900 Subject: [PATCH 1/2] [WIN32SS][FONT] Use HHEA table metrics if (fsSelection & 0x80) --- win32ss/gdi/ntgdi/freetype.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index dd5e0064a59..602eeb398ac 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -3317,11 +3317,12 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight) return FT_Request_Size(face, &req); } + /* See also: https://docs.microsoft.com/en-us/typography/opentype/spec/os2#fsselection */ if (lfHeight > 0) { /* case (A): lfHeight is positive */ Sum = pOS2->usWinAscent + pOS2->usWinDescent; - if (Sum == 0) + if (Sum == 0 || (pOS2->fsSelection & 0x80)) { Ascent = pHori->Ascender; Descent = -pHori->Descender; @@ -3341,8 +3342,16 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight) else if (lfHeight < 0) { /* case (B): lfHeight is negative */ - FontGDI->tmAscent = FT_MulDiv(-lfHeight, pOS2->usWinAscent, face->units_per_EM); - FontGDI->tmDescent = FT_MulDiv(-lfHeight, pOS2->usWinDescent, face->units_per_EM); + if (pOS2->fsSelection & 0x80) + { + FontGDI->tmAscent = FT_MulDiv(-lfHeight, pHori->Ascender, face->units_per_EM); + FontGDI->tmDescent = FT_MulDiv(-lfHeight, -pHori->Descender, face->units_per_EM); + } + else + { + FontGDI->tmAscent = FT_MulDiv(-lfHeight, pOS2->usWinAscent, face->units_per_EM); + FontGDI->tmDescent = FT_MulDiv(-lfHeight, pOS2->usWinDescent, face->units_per_EM); + } FontGDI->tmHeight = FontGDI->tmAscent + FontGDI->tmDescent; FontGDI->tmInternalLeading = FontGDI->tmHeight + lfHeight; } From 85fcb12e9bf0d8c7296cb0a25dbabab7ee8c9dd4 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Mon, 3 Dec 2018 21:02:35 +0900 Subject: [PATCH 2/2] use FM_SEL_USE_TYPO_METRICS macro --- win32ss/gdi/ntgdi/freetype.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index 602eeb398ac..e07606ab52b 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -3318,11 +3318,12 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight) } /* See also: https://docs.microsoft.com/en-us/typography/opentype/spec/os2#fsselection */ +#define FM_SEL_USE_TYPO_METRICS 0x80 if (lfHeight > 0) { /* case (A): lfHeight is positive */ Sum = pOS2->usWinAscent + pOS2->usWinDescent; - if (Sum == 0 || (pOS2->fsSelection & 0x80)) + if (Sum == 0 || (pOS2->fsSelection & FM_SEL_USE_TYPO_METRICS)) { Ascent = pHori->Ascender; Descent = -pHori->Descender; @@ -3342,7 +3343,7 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight) else if (lfHeight < 0) { /* case (B): lfHeight is negative */ - if (pOS2->fsSelection & 0x80) + if (pOS2->fsSelection & FM_SEL_USE_TYPO_METRICS) { FontGDI->tmAscent = FT_MulDiv(-lfHeight, pHori->Ascender, face->units_per_EM); FontGDI->tmDescent = FT_MulDiv(-lfHeight, -pHori->Descender, face->units_per_EM); @@ -3355,6 +3356,7 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight) FontGDI->tmHeight = FontGDI->tmAscent + FontGDI->tmDescent; FontGDI->tmInternalLeading = FontGDI->tmHeight + lfHeight; } +#undef FM_SEL_USE_TYPO_METRICS FontGDI->EmHeight = FontGDI->tmHeight - FontGDI->tmInternalLeading; FontGDI->EmHeight = max(FontGDI->EmHeight, 1);