Vincent Povirk : gdiplus: Create the FontFamily before checking for duplicates.
Alexandre Julliard
julliard at winehq.org
Fri Dec 2 17:00:09 CST 2016
Module: wine
Branch: master
Commit: 50185949d8d41c78fe52ba7c6fc1e5de39491f03
URL: http://source.winehq.org/git/wine.git/?a=commit;h=50185949d8d41c78fe52ba7c6fc1e5de39491f03
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Thu Dec 1 13:08:12 2016 -0600
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: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdiplus/font.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index ed0499d..1068a47 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -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;
}
More information about the wine-cvs
mailing list