Paul Gofman : gdi32: Collapse relative paths inside true type fonts file names in registry.

Alexandre Julliard julliard at winehq.org
Thu Oct 17 16:01:25 CDT 2019


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

Author: Paul Gofman <gofmanp at gmail.com>
Date:   Wed Oct 16 14:49:24 2019 +0300

gdi32: Collapse relative paths inside true type fonts file names in registry.

Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/freetype.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index e3cff25b76..f0e5514649 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -3107,6 +3107,33 @@ static void load_system_fonts(void)
     }
 }
 
+static WCHAR *get_full_path_name(const WCHAR *name)
+{
+    WCHAR *full_path;
+    DWORD len;
+
+    if (!(len = GetFullPathNameW(name, 0, NULL, NULL)))
+    {
+        ERR("GetFullPathNameW() failed, name %s.\n", debugstr_w(name));
+        return NULL;
+    }
+
+    if (!(full_path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*full_path))))
+    {
+        ERR("Could not get memory.\n");
+        return NULL;
+    }
+
+    if (GetFullPathNameW(name, len, full_path, NULL) != len - 1)
+    {
+        ERR("Unexpected GetFullPathNameW() result, name %s.\n", debugstr_w(name));
+        HeapFree(GetProcessHeap(), 0, full_path);
+        return NULL;
+    }
+
+    return full_path;
+}
+
 /*************************************************************
  *
  * This adds registry entries for any externally loaded fonts
@@ -3121,7 +3148,7 @@ static void update_reg_entries(void)
     DWORD len;
     Family *family;
     Face *face;
-    WCHAR *file, *path;
+    WCHAR *file, *path, *full_path;
     static const WCHAR TrueType[] = {' ','(','T','r','u','e','T','y','p','e',')','\0'};
 
     if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, winnt_font_reg_key,
@@ -3168,11 +3195,22 @@ static void update_reg_entries(void)
             HeapFree( GetProcessHeap(), 0, buffer );
 
             if (path)
+            {
+                if ((full_path = get_full_path_name(path)))
+                {
+                    HeapFree(GetProcessHeap(), 0, path);
+                    path = full_path;
+                }
                 file = path;
+            }
             else if ((file = strrchrW(face->file, '/')))
+            {
                 file++;
+            }
             else
+            {
                 file = face->file;
+            }
 
             len = strlenW(file) + 1;
             RegSetValueExW(winnt_key, valueW, 0, REG_SZ, (BYTE*)file, len * sizeof(WCHAR));




More information about the wine-cvs mailing list