Dan Kegel : gdi32: Fix AddFontResource behavior with relative paths.

Alexandre Julliard julliard at winehq.org
Tue Jan 15 07:47:13 CST 2008


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

Author: Dan Kegel <dank at kegel.com>
Date:   Fri Jan 11 18:16:08 2008 -0800

gdi32: Fix AddFontResource behavior with relative paths.

---

 dlls/gdi32/freetype.c |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 7689cf9..b72ee50 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -1680,6 +1680,24 @@ static BOOL load_font_from_data_dir(LPCWSTR file)
     return ret;
 }
 
+static BOOL load_font_from_winfonts_dir(LPCWSTR file)
+{
+    static const WCHAR slashW[] = {'\\','\0'};
+    BOOL ret = FALSE;
+    WCHAR windowsdir[MAX_PATH];
+    char *unixname;
+
+    GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
+    strcatW(windowsdir, fontsW);
+    strcatW(windowsdir, slashW);
+    strcatW(windowsdir, file);
+    if ((unixname = wine_get_unix_file_name(windowsdir))) {
+        ret = AddFontFileToList(unixname, NULL, NULL, ADDFONT_FORCE_BITMAP);
+        HeapFree(GetProcessHeap(), 0, unixname);
+    }
+    return ret;
+}
+
 static void load_system_fonts(void)
 {
     HKEY hkey;
@@ -1825,6 +1843,7 @@ static void update_reg_entries(void)
  */
 INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
 {
+    INT ret = 0;
     if (ft_handle)  /* do it only if we have freetype up and running */
     {
         char *unixname;
@@ -1834,12 +1853,21 @@ INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
 
         if((unixname = wine_get_unix_file_name(file)))
         {
-            INT ret = AddFontFileToList(unixname, NULL, NULL, ADDFONT_FORCE_BITMAP);
+            ret = AddFontFileToList(unixname, NULL, NULL, ADDFONT_FORCE_BITMAP);
             HeapFree(GetProcessHeap(), 0, unixname);
-            return ret;
+        }
+        if (!ret && !strchrW(file, '\\')) {
+            /* Try in %WINDIR%/fonts, needed for Fotobuch Designer */
+            ret = load_font_from_winfonts_dir(file);
+            if (!ret) {
+                /* Try in datadir/fonts (or builddir/fonts),
+                 * needed for Magic the Gathering Online
+                 */
+                ret = load_font_from_data_dir(file);
+            }
         }
     }
-    return 0;
+   return ret;
 }
 
 /*************************************************************




More information about the wine-cvs mailing list