Commit 50185949 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Create the FontFamily before checking for duplicates.

Sometimes GdipCreateFontFamilyFromName stores a different name in the GpFontFamily object, which breaks the duplicate check. Signed-off-by: 's avatarVincent Povirk <vincent@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0d6a4b06
...@@ -1599,6 +1599,7 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm, ...@@ -1599,6 +1599,7 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
DWORD type, LPARAM lParam) DWORD type, LPARAM lParam)
{ {
GpFontCollection* fonts = (GpFontCollection*)lParam; GpFontCollection* fonts = (GpFontCollection*)lParam;
GpFontFamily* family;
int i; int i;
if (type == RASTER_FONTTYPE) if (type == RASTER_FONTTYPE)
...@@ -1608,10 +1609,8 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm, ...@@ -1608,10 +1609,8 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
if (lfw->lfFaceName[0] == '@') if (lfw->lfFaceName[0] == '@')
return 1; return 1;
/* skip duplicates */ if (fonts->count && strcmpiW(lfw->lfFaceName, fonts->FontFamilies[fonts->count-1]->FamilyName) == 0)
for (i=0; i<fonts->count; i++) return 1;
if (strcmpiW(lfw->lfFaceName, fonts->FontFamilies[i]->FamilyName) == 0)
return 1;
if (fonts->allocated == fonts->count) if (fonts->allocated == fonts->count)
{ {
...@@ -1627,11 +1626,21 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm, ...@@ -1627,11 +1626,21 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
fonts->allocated = new_alloc_count; fonts->allocated = new_alloc_count;
} }
if (GdipCreateFontFamilyFromName(lfw->lfFaceName, NULL, &fonts->FontFamilies[fonts->count]) == Ok) if (GdipCreateFontFamilyFromName(lfw->lfFaceName, NULL, &family) != Ok)
fonts->count++;
else
return 0; return 0;
/* skip duplicates */
for (i=0; i<fonts->count; i++)
{
if (strcmpiW(family->FamilyName, fonts->FontFamilies[i]->FamilyName) == 0)
{
GdipDeleteFontFamily(family);
return 1;
}
}
fonts->FontFamilies[fonts->count++] = family;
return 1; return 1;
} }
......
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