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,
DWORD type, LPARAM lParam)
{
GpFontCollection* fonts = (GpFontCollection*)lParam;
GpFontFamily* family;
int i;
if (type == RASTER_FONTTYPE)
......@@ -1608,10 +1609,8 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
if (lfw->lfFaceName[0] == '@')
return 1;
/* skip duplicates */
for (i=0; i<fonts->count; i++)
if (strcmpiW(lfw->lfFaceName, fonts->FontFamilies[i]->FamilyName) == 0)
return 1;
if (fonts->count && strcmpiW(lfw->lfFaceName, fonts->FontFamilies[fonts->count-1]->FamilyName) == 0)
return 1;
if (fonts->allocated == fonts->count)
{
......@@ -1627,11 +1626,21 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
fonts->allocated = new_alloc_count;
}
if (GdipCreateFontFamilyFromName(lfw->lfFaceName, NULL, &fonts->FontFamilies[fonts->count]) == Ok)
fonts->count++;
else
if (GdipCreateFontFamilyFromName(lfw->lfFaceName, NULL, &family) != Ok)
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;
}
......
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