Alexandre Julliard : gdi32: Move the loading of system fonts out of freetype.c.

Alexandre Julliard julliard at winehq.org
Tue Oct 27 16:43:49 CDT 2020


Module: wine
Branch: master
Commit: 131d3b1f5d371257af90593f79d1753d6d53e533
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=131d3b1f5d371257af90593f79d1753d6d53e533

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Oct 27 10:27:06 2020 +0100

gdi32: Move the loading of system fonts out of freetype.c.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/font.c        | 22 ++++++++++++++++++++++
 dlls/gdi32/freetype.c    | 39 +--------------------------------------
 dlls/gdi32/gdi_private.h |  1 +
 3 files changed, 24 insertions(+), 38 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index af87c66498f..d4ed29d7fd9 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -5375,6 +5375,28 @@ static BOOL remove_font_resource( LPCWSTR file, DWORD flags )
     return ret;
 }
 
+void load_system_bitmap_fonts(void)
+{
+    static const WCHAR keyW[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s',0};
+    static const WCHAR fontsW[] = {'F','O','N','T','S','.','F','O','N',0};
+    static const WCHAR oemfontW[] = {'O','E','M','F','O','N','T','.','F','O','N',0};
+    static const WCHAR fixedfonW[] = {'F','I','X','E','D','F','O','N','.','F','O','N',0};
+    static const WCHAR * const fonts[] = { fontsW, oemfontW, fixedfonW };
+
+    HKEY hkey;
+    WCHAR data[MAX_PATH];
+    DWORD i, dlen, type;
+
+    if (RegOpenKeyW( HKEY_CURRENT_CONFIG, keyW, &hkey )) return;
+    for (i = 0; i < ARRAY_SIZE(fonts); i++)
+    {
+        dlen = sizeof(data);
+        if (!RegQueryValueExW( hkey, fonts[i], 0, &type, (BYTE *)data, &dlen ) && type == REG_SZ)
+            add_system_font_resource( data, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
+    }
+    RegCloseKey( hkey );
+}
+
 /***********************************************************************
  *           AddFontResourceExW    (GDI32.@)
  */
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 9ed6077443f..0a05f6a701c 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -340,18 +340,6 @@ static const WCHAR winnt_font_reg_key[] = {'S','o','f','t','w','a','r','e','\\',
                                            'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
                                            'F','o','n','t','s','\0'};
 
-static const WCHAR system_fonts_reg_key[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s','\0'};
-static const WCHAR FixedSys_Value[] = {'F','I','X','E','D','F','O','N','.','F','O','N','\0'};
-static const WCHAR System_Value[] = {'F','O','N','T','S','.','F','O','N','\0'};
-static const WCHAR OEMFont_Value[] = {'O','E','M','F','O','N','T','.','F','O','N','\0'};
-
-static const WCHAR * const SystemFontValues[] = {
-    System_Value,
-    OEMFont_Value,
-    FixedSys_Value,
-    NULL
-};
-
 static const WCHAR external_fonts_reg_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
                                                'F','o','n','t','s','\\','E','x','t','e','r','n','a','l',' ','F','o','n','t','s','\0'};
 
@@ -2861,30 +2849,6 @@ static void load_mac_fonts(void)
 
 #endif
 
-static void load_system_fonts(void)
-{
-    HKEY hkey;
-    WCHAR data[MAX_PATH], pathW[MAX_PATH];
-    const WCHAR * const *value;
-    DWORD dlen, type;
-
-    if(RegOpenKeyW(HKEY_CURRENT_CONFIG, system_fonts_reg_key, &hkey) == ERROR_SUCCESS) {
-        for(value = SystemFontValues; *value; value++) { 
-            dlen = sizeof(data);
-            if(RegQueryValueExW(hkey, *value, 0, &type, (void*)data, &dlen) == ERROR_SUCCESS &&
-               type == REG_SZ) {
-                get_fonts_win_dir_path( data, pathW );
-                if (!freetype_add_font( pathW, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE ))
-                {
-                    get_fonts_data_dir_path( data, pathW );
-                    freetype_add_font( pathW, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
-                }
-            }
-        }
-        RegCloseKey(hkey);
-    }
-}
-
 static WCHAR *get_full_path_name(const WCHAR *name)
 {
     WCHAR *full_path;
@@ -3456,8 +3420,7 @@ static void init_font_list(void)
 
     delete_external_font_keys();
 
-    /* load the system bitmap fonts */
-    load_system_fonts();
+    load_system_bitmap_fonts();
 
     /* load in the fonts from %WINDOWSDIR%\\Fonts first of all */
     GetWindowsDirectoryW(path, ARRAY_SIZE(path));
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 32cdace5c7d..5c4da5d629d 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -392,6 +392,7 @@ struct font_backend_funcs
 extern void get_font_dir( WCHAR *path ) DECLSPEC_HIDDEN;
 extern void get_fonts_data_dir_path( const WCHAR *file, WCHAR *path ) DECLSPEC_HIDDEN;
 extern void get_fonts_win_dir_path( const WCHAR *file, WCHAR *path ) DECLSPEC_HIDDEN;
+extern void load_system_bitmap_fonts(void) DECLSPEC_HIDDEN;
 
 extern struct gdi_font *alloc_gdi_font( const WCHAR *file, void *data_ptr, SIZE_T data_size ) DECLSPEC_HIDDEN;
 extern void free_gdi_font( struct gdi_font *font ) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list