Commit e8e1d0f6 authored by Adam Petaccia's avatar Adam Petaccia Committed by Alexandre Julliard

gdiplus: Implement GdipCreateFontFamilyFromName.

parent 2ea9e28d
......@@ -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;
}
......@@ -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)
......
......@@ -185,4 +185,13 @@ struct GpStringFormat{
StringAlignment vertalign;
};
struct GpFontCollection{
GpFontFamily* FontFamilies;
};
struct GpFontFamily{
TEXTMETRICW* tmw;
WCHAR* FamilyName;
};
#endif
......@@ -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*);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment