[PATCH] 1/4 Implement GdipCreateFontFamilyFromName

Adam Petaccia adam at tpetaccia.com
Tue Jun 17 13:10:42 CDT 2008


---
 dlls/gdiplus/font.c            |   77 ++++++++++++++++++++++++++++++++++++++++
 dlls/gdiplus/gdiplus.spec      |    2 +-
 dlls/gdiplus/gdiplus_private.h |   12 ++++++
 include/gdiplusflat.h          |    2 +
 include/gdiplusgpstubs.h       |    4 ++
 5 files changed, 96 insertions(+), 1 deletions(-)

diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index 82523ce..bc999af 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -28,6 +28,11 @@
 #include "gdiplus.h"
 #include "gdiplus_private.h"
 
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL (gdiplus);
+
 GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
     GDIPCONST LOGFONTW *logfont, GpFont **font)
 {
@@ -130,3 +135,75 @@ GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
 
     return Ok;
 }
+
+/* Borrowed from GDI32 */
+static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf,
+                            const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
+{
+    return 0;
+}
+
+static BOOL is_font_installed(const WCHAR *name)
+{
+    HDC hdc = GetDC(0);
+    BOOL ret = FALSE;
+
+    if(!EnumFontFamiliesW(hdc, name, is_font_installed_proc, 0))
+        ret = TRUE;
+
+    ReleaseDC(0, hdc);
+    return ret;
+}
+
+
+/*******************************************************************************
+ * GdipCreateFontFamilyFromName [GDIPLUS.@]
+ *
+ * Creates a font family object based on a supplied name
+ *
+ * PARAMS
+ *  *name               [I] Name of the font
+ *  *fontCollection     [I] What font collection (if any) the font belongs to (may be NULL)
+ *  **FontFamily        [O] Pointer to the resulting FontFamily object
+ *
+ * RETURNS
+ *   Ok if the object was created.
+ *   FamilyNotFound if the requested FontFamily does not exist on the system
+ *   Invalid parameter if FontFamily or name is NULL
+ *
+ * NOTES
+ *   If fontCollection is NULL then the object is not part of any collection
+ *
+ */
+GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
+                                        GpFontCollection *fontCollection,
+                                        GpFontFamily **FontFamily)
+{
+    GpFontFamily* ffamily;
+
+    TRACE("%s, %p %p\n", debugstr_w(name), fontCollection, FontFamily);
+
+    if (!(name && FontFamily))
+        return InvalidParameter;
+    if (fontCollection)
+        FIXME("No support for FontCollections yet!\n");
+    if (!is_font_installed(name))
+        return FontFamilyNotFound;
+
+    ffamily = GdipAlloc(sizeof (GpFontFamily));
+    if (!ffamily) return OutOfMemory;
+
+    ffamily->FamilyName = GdipAlloc(LF_FACESIZE * sizeof (WCHAR));
+    if (!ffamily->FamilyName)
+    {
+        GdipFree(ffamily);
+        return OutOfMemory;
+    }
+
+    lstrcpynW (ffamily->FamilyName, name, LF_FACESIZE);
+
+    *FontFamily = ffamily;
+
+    return Ok;
+}
+
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index f2eb2b3..61fff6f 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -85,7 +85,7 @@
 @ stdcall GdipCreateCustomLineCap(ptr ptr long long ptr)
 @ stub GdipCreateEffect
 @ stub GdipCreateFont
-@ stub GdipCreateFontFamilyFromName
+@ stdcall GdipCreateFontFamilyFromName(ptr ptr ptr)
 @ stdcall GdipCreateFontFromDC(long ptr)
 @ stdcall GdipCreateFontFromLogfontA(long ptr ptr)
 @ stdcall GdipCreateFontFromLogfontW(long ptr ptr)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 539254b..91bd073 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -185,4 +185,16 @@ struct GpStringFormat{
     StringAlignment vertalign;
 };
 
+struct GpFontCollection{
+	GpFontFamily* fontfamilies;
+};
+
+struct GpFontFamily{
+	UINT16 CellAscent;
+	UINT16 CellDecent;
+	UINT16 EmLineHeight;
+	WCHAR* FamilyName;
+	UINT16 LineSpacing;
+};
+
 #endif
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 0d21c82..09601af 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -344,6 +344,8 @@ GpStatus WINGDIPAPI GdipDeleteFont(GpFont*);
 GpStatus WINGDIPAPI GdipGetLogFontW(GpFont*,GpGraphics*,LOGFONTW*);
 GpStatus WINGDIPAPI GdipCloneFont(GpFont*,GpFont**);
 
+GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name, GpFontCollection *fontCollection, GpFontFamily **FontFamily);
+
 GpStatus WINGDIPAPI GdipCreateStringFormat(INT,LANGID,GpStringFormat**);
 GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat*);
 GpStatus WINGDIPAPI GdipGetStringFormatAlign(GpStringFormat*,StringAlignment*);
diff --git a/include/gdiplusgpstubs.h b/include/gdiplusgpstubs.h
index 9f7d092..1dfbfe9 100644
--- a/include/gdiplusgpstubs.h
+++ b/include/gdiplusgpstubs.h
@@ -37,6 +37,8 @@ class GpPathGradient : public GpBrush {};
 class GpLineGradient : public GpBrush {};
 class GpTexture : public GpBrush {};
 class GpFont {};
+class GpFontCollection {};
+class GpFontFamily {};
 class GpStringFormat {};
 class GpRegion {};
 class CGpEffect {};
@@ -59,6 +61,8 @@ typedef struct GpPathGradient GpPathGradient;
 typedef struct GpLineGradient GpLineGradient;
 typedef struct GpTexture GpTexture;
 typedef struct GpFont GpFont;
+typedef struct GpFontCollection GpFontCollection;
+typedef struct GpFontFamily GpFontFamily;
 typedef struct GpStringFormat GpStringFormat;
 typedef struct GpRegion GpRegion;
 typedef struct CGpEffect CGpEffect;
-- 
1.5.4.3




More information about the wine-patches mailing list