cache font enum info
Aric Stewart
aric at codeweavers.com
Thu Apr 26 14:22:19 CDT 2007
cache the enum info so that repeated calls to EnumFontFamiles and such
does not have to repetidly load the font file
---
dlls/gdi32/freetype.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
-------------- next part --------------
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index caadf4b..0e5abbd 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -253,6 +253,11 @@ typedef struct tagFace {
Bitmap_Size size; /* set if face is a bitmap */
BOOL external; /* TRUE if we should manually add this font to the registry */
struct tagFamily *family;
+ /* Cached data for Enum */
+ BOOL cache_valid;
+ ENUMLOGFONTEXW elf;
+ NEWTEXTMETRICEXW ntm;
+ DWORD type;
} Face;
typedef struct tagFamily {
@@ -1157,6 +1162,7 @@ static BOOL AddFontFileToList(const char
}
}
face = HeapAlloc(GetProcessHeap(), 0, sizeof(*face));
+ face->cache_valid = FALSE;
list_add_tail(&family->faces, &face->entry);
face->StyleName = StyleW;
face->file = HeapAlloc(GetProcessHeap(),0,strlen(file)+1);
@@ -3053,6 +3059,15 @@ static void GetEnumStructs(Face *face, L
GdiFont *font = alloc_font();
LONG width, height;
+ if (face->cache_valid)
+ {
+ TRACE("Cached\n");
+ memcpy(pelf,&face->elf,sizeof(ENUMLOGFONTEXW));
+ memcpy(pntm,&face->ntm,sizeof(NEWTEXTMETRICEXW));
+ *ptype = face->type;
+ return;
+ }
+
if(face->scalable) {
height = 100;
width = 0;
@@ -3142,6 +3157,11 @@ static void GetEnumStructs(Face *face, L
pelf->elfScript[0] = '\0'; /* This will get set in WineEngEnumFonts */
+ memcpy(&face->elf,pelf,sizeof(ENUMLOGFONTEXW));
+ memcpy(&face->ntm,pntm,sizeof(NEWTEXTMETRICEXW));
+ face->type = *ptype;
+ face->cache_valid = TRUE;
+
free_font(font);
}
More information about the wine-patches
mailing list