[NTGDI][FREETYPE] Simplify IntRequestFontSize and FONTGDI
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Thu, 24 Nov 2022 05:18:20 +0000 (14:18 +0900)
committerKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Thu, 24 Nov 2022 05:18:20 +0000 (14:18 +0900)
FONTGDI.lfWidth and FONTGDI.EmHeight are not used.
Simplify code without setting these members.
CORE-11848

win32ss/gdi/eng/engobjects.h
win32ss/gdi/ntgdi/freetype.c

index 29f7f0f..81f2b58 100644 (file)
@@ -162,9 +162,7 @@ typedef struct _FONTGDI {
   LONG          tmAscent;
   LONG          tmDescent;
   LONG          tmInternalLeading;
-  LONG          EmHeight;
   LONG          Magic;
-  LONG          lfWidth;
   LONG          lfHeight;
 } FONTGDI, *PFONTGDI;
 
index f850885..7d3e205 100644 (file)
@@ -3503,14 +3503,7 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
     TT_OS2 *pOS2;
     TT_HoriHeader *pHori;
     FT_WinFNT_HeaderRec WinFNT;
-    LONG Ascent, Descent, Sum, EmHeight64;
-
-    if (FontGDI->Magic == FONTGDI_MAGIC &&
-        FontGDI->lfHeight == lfHeight &&
-        FontGDI->lfWidth == lfWidth)
-    {
-        return 0; /* Cached */
-    }
+    LONG Ascent, Descent, Sum, EmHeight;
 
     lfWidth = abs(lfWidth);
     if (lfHeight == 0)
@@ -3529,6 +3522,9 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
     if (lfHeight == -1)
         lfHeight = -2;
 
+    if (FontGDI->Magic == FONTGDI_MAGIC && FontGDI->lfHeight == lfHeight)
+        return 0; /* Cached */
+
     ASSERT_FREETYPE_LOCK_HELD();
     pOS2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, FT_SFNT_OS2);
     pHori = (TT_HoriHeader *)FT_Get_Sfnt_Table(face, FT_SFNT_HHEA);
@@ -3547,11 +3543,7 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
         FontGDI->tmAscent           = WinFNT.ascent;
         FontGDI->tmDescent          = FontGDI->tmHeight - FontGDI->tmAscent;
         FontGDI->tmInternalLeading  = WinFNT.internal_leading;
-        FontGDI->EmHeight           = FontGDI->tmHeight - FontGDI->tmInternalLeading;
-        FontGDI->EmHeight = max(FontGDI->EmHeight, 1);
-        FontGDI->EmHeight = min(FontGDI->EmHeight, USHORT_MAX);
         FontGDI->Magic              = FONTGDI_MAGIC;
-        FontGDI->lfWidth            = lfWidth;
         FontGDI->lfHeight           = lfHeight;
         return 0;
     }
@@ -3605,18 +3597,16 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight)
     }
 #undef FM_SEL_USE_TYPO_METRICS
 
-    FontGDI->EmHeight = FontGDI->tmHeight - FontGDI->tmInternalLeading;
-    FontGDI->EmHeight = max(FontGDI->EmHeight, 1);
-    FontGDI->EmHeight = min(FontGDI->EmHeight, USHORT_MAX);
     FontGDI->Magic = FONTGDI_MAGIC;
-    FontGDI->lfWidth = lfWidth;
     FontGDI->lfHeight = lfHeight;
 
-    EmHeight64 = (FontGDI->EmHeight << 6);
+    EmHeight = FontGDI->tmHeight - FontGDI->tmInternalLeading;
+    EmHeight = max(EmHeight, 1);
+    EmHeight = min(EmHeight, USHORT_MAX);
 
     req.type           = FT_SIZE_REQUEST_TYPE_NOMINAL;
     req.width          = 0;
-    req.height         = EmHeight64;
+    req.height         = (EmHeight << 6);
     req.horiResolution = 0;
     req.vertResolution = 0;
     return FT_Request_Size(face, &req);