gdiplus: Return actual code on failed attempt to add a font.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
a1ff2c44ea
commit
4aaa94111b
|
@ -1493,6 +1493,12 @@ static WCHAR *load_ttf_name_id( const BYTE *mem, DWORD_PTR size, DWORD id )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct add_font_param
|
||||
{
|
||||
GpFontCollection *collection;
|
||||
GpStatus stat;
|
||||
};
|
||||
|
||||
static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam);
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -1520,6 +1526,7 @@ GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
|
|||
ret = InvalidParameter;
|
||||
else
|
||||
{
|
||||
struct add_font_param param;
|
||||
HDC hdc;
|
||||
LOGFONTW lfw;
|
||||
|
||||
|
@ -1533,8 +1540,9 @@ GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
|
|||
lstrcpyW(lfw.lfFaceName, name);
|
||||
lfw.lfPitchAndFamily = 0;
|
||||
|
||||
if (!EnumFontFamiliesExW(hdc, &lfw, add_font_proc, (LPARAM)fontCollection, 0))
|
||||
ret = OutOfMemory;
|
||||
param.collection = fontCollection;
|
||||
if (!EnumFontFamiliesExW(hdc, &lfw, add_font_proc, (LPARAM)¶m, 0))
|
||||
ret = param.stat;
|
||||
|
||||
DeleteDC(hdc);
|
||||
}
|
||||
|
@ -1606,10 +1614,14 @@ void free_installed_fonts(void)
|
|||
static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
|
||||
DWORD type, LPARAM lParam)
|
||||
{
|
||||
GpFontCollection* fonts = (GpFontCollection*)lParam;
|
||||
struct add_font_param *param = (struct add_font_param *)lParam;
|
||||
GpFontCollection *fonts = param->collection;
|
||||
GpFontFamily* family;
|
||||
GpStatus stat;
|
||||
int i;
|
||||
|
||||
param->stat = Ok;
|
||||
|
||||
if (type == RASTER_FONTTYPE)
|
||||
return 1;
|
||||
|
||||
|
@ -1626,7 +1638,10 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
|
|||
GpFontFamily** new_family_list = heap_alloc(new_alloc_count*sizeof(void*));
|
||||
|
||||
if (!new_family_list)
|
||||
{
|
||||
param->stat = OutOfMemory;
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(new_family_list, fonts->FontFamilies, fonts->count*sizeof(void*));
|
||||
heap_free(fonts->FontFamilies);
|
||||
|
@ -1634,8 +1649,11 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
|
|||
fonts->allocated = new_alloc_count;
|
||||
}
|
||||
|
||||
if (GdipCreateFontFamilyFromName(lfw->lfFaceName, NULL, &family) != Ok)
|
||||
if ((stat = GdipCreateFontFamilyFromName(lfw->lfFaceName, NULL, &family)) != Ok)
|
||||
{
|
||||
param->stat = stat;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* skip duplicates */
|
||||
for (i=0; i<fonts->count; i++)
|
||||
|
@ -1662,6 +1680,7 @@ GpStatus WINGDIPAPI GdipNewInstalledFontCollection(
|
|||
|
||||
if (installedFontCollection.count == 0)
|
||||
{
|
||||
struct add_font_param param;
|
||||
HDC hdc;
|
||||
LOGFONTW lfw;
|
||||
|
||||
|
@ -1671,11 +1690,12 @@ GpStatus WINGDIPAPI GdipNewInstalledFontCollection(
|
|||
lfw.lfFaceName[0] = 0;
|
||||
lfw.lfPitchAndFamily = 0;
|
||||
|
||||
if (!EnumFontFamiliesExW(hdc, &lfw, add_font_proc, (LPARAM)&installedFontCollection, 0))
|
||||
param.collection = &installedFontCollection;
|
||||
if (!EnumFontFamiliesExW(hdc, &lfw, add_font_proc, (LPARAM)¶m, 0))
|
||||
{
|
||||
free_installed_fonts();
|
||||
DeleteDC(hdc);
|
||||
return OutOfMemory;
|
||||
return param.stat;
|
||||
}
|
||||
|
||||
DeleteDC(hdc);
|
||||
|
|
Loading…
Reference in New Issue