Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/tests/font.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c index 961d8459cb..0a3a3bef79 100644 --- a/dlls/gdiplus/tests/font.c +++ b/dlls/gdiplus/tests/font.c @@ -1238,6 +1238,27 @@ static void test_GdipGetFontCollectionFamilyList(void) GdipDeleteFontFamily(family2); }
+static void test_GdipGetFontCollectionFamilyCount(void) +{ + GpFontCollection *collection; + GpStatus status; + INT count; + + status = GdipGetFontCollectionFamilyCount(NULL, NULL); + ok(status == InvalidParameter, "Unexpected status %d.\n", status); + + count = 123; + status = GdipGetFontCollectionFamilyCount(NULL, &count); + ok(status == InvalidParameter, "Unexpected status %d.\n", status); + ok(count == 123, "Unexpected family count %d.\n", count); + + status = GdipNewInstalledFontCollection(&collection); + ok(status == Ok, "Failed to get system collection, status %d.\n", status); + + status = GdipGetFontCollectionFamilyCount(collection, NULL); + ok(status == InvalidParameter, "Unexpected status %d.\n", status); +} + START_TEST(font) { struct GdiplusStartupInput gdiplusStartupInput; @@ -1269,6 +1290,7 @@ START_TEST(font) test_installedfonts(); test_heightgivendpi(); test_GdipGetFontCollectionFamilyList(); + test_GdipGetFontCollectionFamilyCount();
GdiplusShutdown(gdiplusToken); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/font.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index 64778bb226..74cd29b2c3 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -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);
Signed-off-by: Vincent Povirk vincent@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/font.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index 74cd29b2c3..729592b982 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -1496,6 +1496,7 @@ static WCHAR *load_ttf_name_id( const BYTE *mem, DWORD_PTR size, DWORD id ) struct add_font_param { GpFontCollection *collection; + BOOL is_system; GpStatus stat; };
@@ -1541,6 +1542,7 @@ GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection* fontCollection, lfw.lfPitchAndFamily = 0;
param.collection = fontCollection; + param.is_system = FALSE; if (!EnumFontFamiliesExW(hdc, &lfw, add_font_proc, (LPARAM)¶m, 0)) ret = param.stat;
@@ -1651,6 +1653,9 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
if ((stat = GdipCreateFontFamilyFromName(lfw->lfFaceName, NULL, &family)) != Ok) { + WARN("Failed to create font family for %s, status %d.\n", debugstr_w(lfw->lfFaceName), stat); + if (param->is_system) + return 1; param->stat = stat; return 0; } @@ -1691,6 +1696,7 @@ GpStatus WINGDIPAPI GdipNewInstalledFontCollection( lfw.lfPitchAndFamily = 0;
param.collection = &installedFontCollection; + param.is_system = TRUE; if (!EnumFontFamiliesExW(hdc, &lfw, add_font_proc, (LPARAM)¶m, 0)) { free_installed_fonts();
Signed-off-by: Vincent Povirk vincent@codeweavers.com