Alexandre Julliard : gdi32: Take into account the fontdir directory specified at build time.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Mar 17 10:02:14 CDT 2016


Module: wine
Branch: master
Commit: 1eac54ef7d6d90fcc973c5ea92a53be73f61ff12
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1eac54ef7d6d90fcc973c5ea92a53be73f61ff12

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Mar 17 17:23:24 2016 +0900

gdi32: Take into account the fontdir directory specified at build time.

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

---

 dlls/gdi32/Makefile.in |  2 ++
 dlls/gdi32/freetype.c  | 49 +++++++++++++++++++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/dlls/gdi32/Makefile.in b/dlls/gdi32/Makefile.in
index 6cc026c..a0f76d2 100644
--- a/dlls/gdi32/Makefile.in
+++ b/dlls/gdi32/Makefile.in
@@ -49,3 +49,5 @@ C_SRCS = \
 	vertical.c
 
 RC_SRCS = gdi32.rc
+
+freetype_EXTRADEFS = -DWINE_FONT_DIR=\"`$(MAKEDEP) -R ${datadir}/wine ${fontdir}`\"
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 184e1d3..a7ac1bb 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -214,6 +214,10 @@ MAKE_FUNCPTR(FcPatternGetString);
 #define GET_BE_WORD(x) RtlUshortByteSwap(x)
 #endif
 
+#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;
@@ -2969,22 +2973,44 @@ static void load_mac_fonts(void)
 
 #endif
 
+static char *get_font_dir(void)
+{
+    const char *build_dir, *data_dir;
+    char *name = NULL;
+
+    if ((data_dir = wine_get_data_dir()))
+    {
+        if (!(name = HeapAlloc( GetProcessHeap(), 0, strlen(data_dir) + 1 + sizeof(WINE_FONT_DIR) )))
+            return NULL;
+        strcpy( name, data_dir );
+        strcat( name, "/" );
+        strcat( name, WINE_FONT_DIR );
+    }
+    else if ((build_dir = wine_get_build_dir()))
+    {
+        if (!(name = HeapAlloc( GetProcessHeap(), 0, strlen(build_dir) + sizeof("/fonts") )))
+            return NULL;
+        strcpy( name, build_dir );
+        strcat( name, "/fonts" );
+    }
+    return name;
+}
+
 static char *get_data_dir_path( LPCWSTR file )
 {
     char *unix_name = NULL;
-    const char *data_dir = wine_get_data_dir();
-
-    if (!data_dir) data_dir = wine_get_build_dir();
+    char *font_dir = get_font_dir();
 
-    if (data_dir)
+    if (font_dir)
     {
         INT len = WideCharToMultiByte(CP_UNIXCP, 0, file, -1, NULL, 0, NULL, NULL);
 
-        unix_name = HeapAlloc(GetProcessHeap(), 0, strlen(data_dir) + len + sizeof("/fonts/"));
-        strcpy(unix_name, data_dir);
-        strcat(unix_name, "/fonts/");
+        unix_name = HeapAlloc(GetProcessHeap(), 0, strlen(font_dir) + len + 1 );
+        strcpy(unix_name, font_dir);
+        strcat(unix_name, "/");
 
         WideCharToMultiByte(CP_UNIXCP, 0, file, -1, unix_name + strlen(unix_name), len, NULL, NULL);
+        HeapFree( GetProcessHeap(), 0, font_dir );
     }
     return unix_name;
 }
@@ -4131,7 +4157,6 @@ static void init_font_list(void)
     DWORD valuelen, datalen, i = 0, type, dlen, vlen;
     WCHAR windowsdir[MAX_PATH];
     char *unixname;
-    const char *data_dir;
 
     delete_external_font_keys();
 
@@ -4147,13 +4172,9 @@ static void init_font_list(void)
         HeapFree(GetProcessHeap(), 0, unixname);
     }
 
-    /* load the system truetype fonts */
-    data_dir = wine_get_data_dir();
-    if (!data_dir) data_dir = wine_get_build_dir();
-    if (data_dir && (unixname = HeapAlloc(GetProcessHeap(), 0, strlen(data_dir) + sizeof("/fonts/"))))
+    /* load the wine fonts */
+    if ((unixname = get_font_dir()))
     {
-        strcpy(unixname, data_dir);
-        strcat(unixname, "/fonts/");
         ReadFontDir(unixname, TRUE);
         HeapFree(GetProcessHeap(), 0, unixname);
     }




More information about the wine-cvs mailing list