Alexandre Julliard : gdi32: Add support for . fot files in RemoveFontResource.

Alexandre Julliard julliard at winehq.org
Tue Jan 15 13:46:18 CST 2013


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jan 15 12:54:02 2013 +0100

gdi32: Add support for .fot files in RemoveFontResource.

---

 dlls/gdi32/font.c       |   20 +++++++++++++++++++-
 dlls/gdi32/tests/font.c |   15 ++++-----------
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index c6a6946..fe211a1 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -3565,7 +3565,25 @@ BOOL WINAPI RemoveFontResourceExA( LPCSTR str, DWORD fl, PVOID pdv )
  */
 BOOL WINAPI RemoveFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
 {
-    return WineEngRemoveFontResourceEx(str, fl, pdv);
+    int ret = WineEngRemoveFontResourceEx( str, fl, pdv );
+    WCHAR *filename;
+
+    if (ret == 0)
+    {
+        /* FreeType <2.3.5 has problems reading resources wrapped in PE files. */
+        HMODULE hModule = LoadLibraryExW(str, NULL, LOAD_LIBRARY_AS_DATAFILE);
+        if (hModule != NULL)
+        {
+            WARN("Can't unload resources from PE file %s\n", wine_dbgstr_w(str));
+            FreeLibrary(hModule);
+        }
+        else if ((filename = get_scalable_filename( str )) != NULL)
+        {
+            ret = WineEngRemoveFontResourceEx( filename, fl, pdv );
+            HeapFree( GetProcessHeap(), 0, filename );
+        }
+    }
+    return ret;
 }
 
 /***********************************************************************
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 1dfdd11..62997d1 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -4475,22 +4475,11 @@ static void test_CreateScalableFontResource(void)
 
     SetLastError(0xdeadbeef);
     ret = pRemoveFontResourceExA(fot_name, 0, 0);
-todo_wine
     ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
 
     ret = is_truetype_font_installed("wine_test");
-todo_wine
     ok(!ret, "font wine_test should not be enumerated\n");
 
-    /* FIXME: since RemoveFontResource is a stub correct testing is impossible */
-    if (ret)
-    {
-        /* remove once RemoveFontResource is implemented */
-        DeleteFile(fot_name);
-        DeleteFile(ttf_name);
-        return;
-    }
-
     ret = pRemoveFontResourceExA(fot_name, 0, 0);
     ok(!ret, "RemoveFontResourceEx() should fail\n");
 
@@ -4509,17 +4498,21 @@ todo_wine
     ok(ret, "AddFontResourceEx() error %d\n", GetLastError());
 
     ret = is_truetype_font_installed("wine_test");
+    todo_wine
     ok(!ret, "font wine_test should not be enumerated\n");
 
     /* XP allows removing a private font added with 0 flags */
     SetLastError(0xdeadbeef);
     ret = pRemoveFontResourceExA(fot_name, FR_PRIVATE, 0);
+    todo_wine
     ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
 
     ret = is_truetype_font_installed("wine_test");
+    todo_wine
     ok(!ret, "font wine_test should not be enumerated\n");
 
     ret = pRemoveFontResourceExA(fot_name, 0, 0);
+    todo_wine
     ok(!ret, "RemoveFontResourceEx() should fail\n");
 
     DeleteFile(fot_name);




More information about the wine-cvs mailing list