Module: wine Branch: master Commit: e8e1d0f6fe51507195fdaaee5e07cef5ca97a9e3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=e8e1d0f6fe51507195fdaaee5e...
Author: Adam Petaccia adam@tpetaccia.com Date: Sat Jun 21 13:02:47 2008 -0400
gdiplus: Implement GdipCreateFontFamilyFromName.
---
dlls/gdiplus/font.c | 88 ++++++++++++++++++++++++++++++++++++++++ dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/gdiplus_private.h | 9 ++++ include/gdiplusflat.h | 3 + include/gdiplusgpstubs.h | 4 ++ 5 files changed, 105 insertions(+), 1 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index 82523ce..b3e49c4 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -22,6 +22,10 @@ #include "winbase.h" #include "wingdi.h" #include "winnls.h" +#include "wine/debug.h" +#include "wine/unicode.h" + +WINE_DEFAULT_DEBUG_CHANNEL (gdiplus);
#include "objbase.h"
@@ -130,3 +134,87 @@ 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 + * SUCCESS: Ok + * FAILURE: FamilyNotFound if the requested FontFamily does not exist on the system + * FAILURE: 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; + HDC hdc; + HFONT hFont; + LOGFONTW lfw; + + 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->tmw = GdipAlloc(sizeof (TEXTMETRICW)); + if (!ffamily->tmw) {GdipFree (ffamily); return OutOfMemory;} + + hdc = GetDC(0); + lstrcpynW(lfw.lfFaceName, name, sizeof(WCHAR) * LF_FACESIZE); + hFont = CreateFontIndirectW (&lfw); + SelectObject(hdc, hFont); + + GetTextMetricsW(hdc, ffamily->tmw); + + ffamily->FamilyName = GdipAlloc(LF_FACESIZE * sizeof (WCHAR)); + if (!ffamily->FamilyName) + { + GdipFree(ffamily); + return OutOfMemory; + } + + lstrcpynW(ffamily->FamilyName, name, sizeof(WCHAR) * LF_FACESIZE); + + *FontFamily = ffamily; + ReleaseDC(0, hdc); + + return Ok; +} diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 8d7c892..2af90ea 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(wstr 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..acda374 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -185,4 +185,13 @@ struct GpStringFormat{ StringAlignment vertalign; };
+struct GpFontCollection{ + GpFontFamily* FontFamilies; +}; + +struct GpFontFamily{ + TEXTMETRICW* tmw; + WCHAR* FamilyName; +}; + #endif diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 07c60f1..aa9c6dc 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -348,6 +348,9 @@ GpStatus WINGDIPAPI GdipDeleteFont(GpFont*); GpStatus WINGDIPAPI GdipGetLogFontW(GpFont*,GpGraphics*,LOGFONTW*); GpStatus WINGDIPAPI GdipCloneFont(GpFont*,GpFont**);
+GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR*, + GpFontCollection*, GpFontFamily**); + 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 c5e676d..e2f8ab7 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;