[2/2] gdiplus: Create the FontFamily before checking for duplicates.
Vincent Povirk
madewokherd at gmail.com
Thu Dec 1 13:08:12 CST 2016
From: Vincent Povirk <vincent at codeweavers.com>
Sometimes GdipCreateFontFamilyFromName stores a different name in the
GpFontFamily object, which breaks the duplicate check.
I kept a single check before creating the FontFamily as an optimization.
It was measurably faster in my testing.
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
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;
}
--
2.7.4
More information about the wine-patches
mailing list