Alexandre Julliard : gdi32: Move the fonts directory helper functions out of freetype.c.

Alexandre Julliard julliard at winehq.org
Mon Oct 26 16:59:42 CDT 2020


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Oct 26 12:03:21 2020 +0100

gdi32: Move the fonts directory helper functions out of freetype.c.

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

---

 dlls/gdi32/Makefile.in   |  2 +-
 dlls/gdi32/font.c        | 43 ++++++++++++++++++++++++++++++++++
 dlls/gdi32/freetype.c    | 60 +++++++-----------------------------------------
 dlls/gdi32/gdi_private.h |  4 ++++
 4 files changed, 56 insertions(+), 53 deletions(-)

diff --git a/dlls/gdi32/Makefile.in b/dlls/gdi32/Makefile.in
index a94abad599d..3b78f5e132f 100644
--- a/dlls/gdi32/Makefile.in
+++ b/dlls/gdi32/Makefile.in
@@ -52,4 +52,4 @@ C_SRCS = \
 
 RC_SRCS = gdi32.rc
 
-freetype_EXTRADEFS = -DWINE_FONT_DIR=\"`${MAKEDEP} -R ${datadir}/wine ${fontdir}`\"
+font_EXTRADEFS = -DWINE_FONT_DIR=\"`${MAKEDEP} -R ${datadir}/wine ${fontdir}`\"
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 27aa129c0de..2331c7cf784 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -350,6 +350,49 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
 };
 CRITICAL_SECTION font_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
 
+#ifndef WINE_FONT_DIR
+#define WINE_FONT_DIR "fonts"
+#endif
+
+void get_font_dir( WCHAR *path )
+{
+    static const WCHAR slashW[] = {'\\',0};
+    static const WCHAR fontsW[] = {'\\','f','o','n','t','s',0};
+    static const WCHAR winedatadirW[] = {'W','I','N','E','D','A','T','A','D','I','R',0};
+    static const WCHAR winebuilddirW[] = {'W','I','N','E','B','U','I','L','D','D','I','R',0};
+
+    if (GetEnvironmentVariableW( winedatadirW, path, MAX_PATH ))
+    {
+        const char fontdir[] = WINE_FONT_DIR;
+        strcatW( path, slashW );
+        MultiByteToWideChar( CP_ACP, 0, fontdir, -1, path + strlenW(path), MAX_PATH - strlenW(path) );
+    }
+    else if (GetEnvironmentVariableW( winebuilddirW, path, MAX_PATH ))
+    {
+        strcatW( path, fontsW );
+    }
+    if (path[5] == ':') memmove( path, path + 4, (strlenW(path) - 3) * sizeof(WCHAR) );
+    else path[1] = '\\';  /* change \??\ to \\?\ */
+}
+
+void get_fonts_data_dir_path( const WCHAR *file, WCHAR *path )
+{
+    static const WCHAR slashW[] = {'\\',0};
+
+    get_font_dir( path );
+    strcatW( path, slashW );
+    strcatW( path, file );
+}
+
+void get_fonts_win_dir_path( const WCHAR *file, WCHAR *path )
+{
+    static const WCHAR fontsW[] = {'\\','f','o','n','t','s','\\',0};
+
+    GetWindowsDirectoryW( path, MAX_PATH );
+    strcatW( path, fontsW );
+    strcatW( path, file );
+}
+
 /* realized font objects */
 
 #define FIRST_FONT_HANDLE 1
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 16fb92dd73b..7129acfeb5c 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -225,10 +225,6 @@ MAKE_FUNCPTR(FcPatternGetString);
 #define GASP_GRIDFIT 0x01
 #define GASP_DOGRAY  0x02
 
-#ifndef WINE_FONT_DIR
-#define WINE_FONT_DIR "fonts"
-#endif
-
 /* This is basically a copy of FT_Bitmap_Size with an extra element added */
 typedef struct {
     FT_Short height;
@@ -2858,46 +2854,6 @@ static void load_mac_fonts(void)
 
 #endif
 
-static void get_font_dir( WCHAR *path )
-{
-    static const WCHAR slashW[] = {'\\',0};
-    static const WCHAR fontsW[] = {'\\','f','o','n','t','s',0};
-    static const WCHAR winedatadirW[] = {'W','I','N','E','D','A','T','A','D','I','R',0};
-    static const WCHAR winebuilddirW[] = {'W','I','N','E','B','U','I','L','D','D','I','R',0};
-
-    if (GetEnvironmentVariableW( winedatadirW, path, MAX_PATH ))
-    {
-        const char fontdir[] = WINE_FONT_DIR;
-        strcatW( path, slashW );
-        MultiByteToWideChar( CP_ACP, 0, fontdir, -1, path + strlenW(path), MAX_PATH - strlenW(path) );
-    }
-    else if (GetEnvironmentVariableW( winebuilddirW, path, MAX_PATH ))
-    {
-        strcatW( path, fontsW );
-    }
-    if (path[5] == ':') memmove( path, path + 4, (strlenW(path) - 3) * sizeof(WCHAR) );
-    else path[1] = '\\';  /* change \??\ to \\?\ */
-}
-
-static void get_data_dir_path( LPCWSTR file, WCHAR *path )
-{
-    static const WCHAR slashW[] = {'\\','\0'};
-
-    get_font_dir( path );
-    strcatW( path, slashW );
-    strcatW( path, file );
-}
-
-static void get_winfonts_dir_path(LPCWSTR file, WCHAR *path)
-{
-    static const WCHAR slashW[] = {'\\','\0'};
-
-    GetWindowsDirectoryW(path, MAX_PATH);
-    strcatW(path, fontsW);
-    strcatW(path, slashW);
-    strcatW(path, file);
-}
-
 static void load_system_fonts(void)
 {
     HKEY hkey;
@@ -2910,10 +2866,10 @@ static void load_system_fonts(void)
             dlen = sizeof(data);
             if(RegQueryValueExW(hkey, *value, 0, &type, (void*)data, &dlen) == ERROR_SUCCESS &&
                type == REG_SZ) {
-                get_winfonts_dir_path( data, pathW );
+                get_fonts_win_dir_path( data, pathW );
                 if (!add_font_resource( pathW, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE ))
                 {
-                    get_data_dir_path( data, pathW );
+                    get_fonts_data_dir_path( data, pathW );
                     add_font_resource( pathW, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
                 }
             }
@@ -3110,12 +3066,12 @@ static INT CDECL freetype_AddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv
 
     if (!ret && !strchrW(file, '\\')) {
         /* Try in %WINDIR%/fonts, needed for Fotobuch Designer */
-        get_winfonts_dir_path( file, path );
+        get_fonts_win_dir_path( file, path );
         ret = add_font_resource( path, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE );
         /* Try in datadir/fonts (or builddir/fonts), needed for Magic the Gathering Online */
         if (!ret)
         {
-            get_data_dir_path( file, path );
+            get_fonts_data_dir_path( file, path );
             ret = add_font_resource( path, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE );
         }
     }
@@ -3163,11 +3119,11 @@ static BOOL CDECL freetype_RemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID
 
     if (!ret && !strchrW(file, '\\'))
     {
-        get_winfonts_dir_path( file, path );
+        get_fonts_win_dir_path( file, path );
         ret = remove_font_resource( path, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE );
         if (!ret)
         {
-            get_data_dir_path( file, path );
+            get_fonts_data_dir_path( file, path );
             ret = remove_font_resource( path, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE );
         }
     }
@@ -3615,10 +3571,10 @@ static void init_font_list(void)
                 {
                     WCHAR pathW[MAX_PATH];
 
-                    get_winfonts_dir_path( data, pathW );
+                    get_fonts_win_dir_path( data, pathW );
                     if (!add_font_resource( pathW, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE ))
                     {
-                        get_data_dir_path( data, pathW );
+                        get_fonts_data_dir_path( data, pathW );
                         add_font_resource( pathW, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
                     }
                 }
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 8036dfb986b..d7680464b6a 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -382,6 +382,10 @@ struct font_backend_funcs
     void  (CDECL *destroy_font)( struct gdi_font *font );
 };
 
+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 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;
 extern void cache_gdi_font( struct gdi_font *font ) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list