gdiplus: Implement GdipPrivateAddFontFile.

Dmitry Timoshkov dmitry at baikal.ru
Tue Nov 5 21:44:21 CST 2013


---
 dlls/gdiplus/font.c | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index a6c7924..a811a60 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -1127,15 +1127,39 @@ GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontColle
 /*****************************************************************************
  * GdipPrivateAddFontFile [GDIPLUS.@]
  */
-GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection* fontCollection,
-        GDIPCONST WCHAR* filename)
+GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection *collection, GDIPCONST WCHAR *name)
 {
-    FIXME("stub: %p, %s\n", fontCollection, debugstr_w(filename));
+    HANDLE file, mapping;
+    LARGE_INTEGER size;
+    void *mem;
+    GpStatus status;
+
+    TRACE("%p, %s\n", collection, debugstr_w(name));
+
+    if (!collection || !name) return InvalidParameter;
 
-    if (!(fontCollection && filename))
+    file = CreateFileW(name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
+    if (file == INVALID_HANDLE_VALUE) return InvalidParameter;
+
+    if (!GetFileSizeEx(file, &size) || size.u.HighPart)
+    {
+        CloseHandle(file);
         return InvalidParameter;
+    }
+
+    mapping = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
+    CloseHandle(file);
+    if (!mapping) return InvalidParameter;
+
+    mem = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
+    CloseHandle(mapping);
+    if (!mem) return InvalidParameter;
+
+    /* GdipPrivateAddMemoryFont creates a copy of the memory block */
+    status = GdipPrivateAddMemoryFont(collection, mem, size.u.LowPart);
+    UnmapViewOfFile(mem);
 
-    return NotImplemented;
+    return status;
 }
 
 #define TT_PLATFORM_APPLE_UNICODE   0
-- 
1.8.4.1




More information about the wine-patches mailing list