https://git.reactos.org/?p=reactos.git;a=commitdiff;h=467768f7664f8b33000ff…
commit 467768f7664f8b33000ffd3f4743ddbff11f8d76
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Nov 8 16:31:10 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Nov 8 16:31:10 2022 +0900
[NTGDI][FREETYPE] Reduce font size request (#4862)
- Delete some IntRequestFontSize function calls.
- Enable cache on font size requests.
- Add two members into FONTGDI structure, for font size cache.
CORE-15554
---
win32ss/gdi/eng/engobjects.h | 2 ++
win32ss/gdi/ntgdi/freetype.c | 24 ++++++++++++------------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/win32ss/gdi/eng/engobjects.h b/win32ss/gdi/eng/engobjects.h
index dc579664e6e..6c3476f57ea 100644
--- a/win32ss/gdi/eng/engobjects.h
+++ b/win32ss/gdi/eng/engobjects.h
@@ -161,6 +161,8 @@ typedef struct _FONTGDI {
LONG tmInternalLeading;
LONG EmHeight;
LONG Magic;
+ LONG lfWidth;
+ LONG lfHeight;
} FONTGDI, *PFONTGDI;
/* The initialized 'Magic' value in FONTGDI */
diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c
index b56aab526d6..a23f49ba9e2 100644
--- a/win32ss/gdi/ntgdi/freetype.c
+++ b/win32ss/gdi/ntgdi/freetype.c
@@ -1067,9 +1067,6 @@ IntLoadSystemFonts(VOID)
}
}
-static FT_Error
-IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight);
-
/* NOTE: If nIndex < 0 then return the number of charsets. */
UINT FASTCALL IntGetCharSet(INT nIndex, FT_ULong CodePageRange1)
{
@@ -1349,10 +1346,6 @@ IntGdiLoadFontsFromMemory(PGDI_LOAD_FONT pLoadFont,
DPRINT("Num glyphs: %d\n", Face->num_glyphs);
DPRINT("CharSet: %d\n", FontGDI->CharSet);
- IntLockFreeType();
- IntRequestFontSize(NULL, FontGDI, 0, 0);
- IntUnLockFreeType();
-
/* Add this font resource to the font table */
Entry->Font = FontGDI;
Entry->NotEnum = (Characteristics & FR_NOT_ENUM);
@@ -3512,6 +3505,13 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG
lfHeight)
FT_WinFNT_HeaderRec WinFNT;
LONG Ascent, Descent, Sum, EmHeight64;
+ if (FontGDI->Magic == FONTGDI_MAGIC &&
+ FontGDI->lfHeight == lfHeight &&
+ FontGDI->lfWidth == lfWidth)
+ {
+ return 0; /* Cached */
+ }
+
lfWidth = abs(lfWidth);
if (lfHeight == 0)
{
@@ -3550,7 +3550,9 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG
lfHeight)
FontGDI->EmHeight = FontGDI->tmHeight -
FontGDI->tmInternalLeading;
FontGDI->EmHeight = max(FontGDI->EmHeight, 1);
FontGDI->EmHeight = min(FontGDI->EmHeight, USHORT_MAX);
- FontGDI->Magic = FONTGDI_MAGIC;
+ FontGDI->Magic = FONTGDI_MAGIC;
+ FontGDI->lfWidth = lfWidth;
+ FontGDI->lfHeight = lfHeight;
return 0;
}
@@ -3607,6 +3609,8 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG
lfHeight)
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);
@@ -5263,10 +5267,6 @@ TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj)
PFONTGDI FontGdi = ObjToGDI(TextObj->Font, FONT);
PSHARED_FACE SharedFace = FontGdi->SharedFace;
- IntLockFreeType();
- IntRequestFontSize(NULL, FontGdi, pLogFont->lfWidth, pLogFont->lfHeight);
- IntUnLockFreeType();
-
TextObj->TextFace[0] = UNICODE_NULL;
if (MatchFontNames(SharedFace, SubstitutedLogFont.lfFaceName))
{