Commit 591a31ba authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Increment the face refcount when loading the same font file multiple times.

parent 93c1389b
......@@ -1304,6 +1304,13 @@ static BOOL insert_face_in_family_list( Face *face, Family *family )
debugstr_w(family->FamilyName), debugstr_w(face->StyleName),
cursor->font_version, face->font_version);
if (face->file && face->dev == cursor->dev && face->ino == cursor->ino)
{
cursor->refcount++;
TRACE("Font %s already in list, refcount now %d\n",
debugstr_w(face->file), cursor->refcount);
return FALSE;
}
if (face->font_version <= cursor->font_version)
{
TRACE("Original font %s is newer so skipping %s\n",
......
......@@ -4567,6 +4567,7 @@ static void test_CreateScalableFontResource(void)
char fot_name[MAX_PATH];
char *file_part;
DWORD ret;
int i;
if (!pAddFontResourceExA || !pRemoveFontResourceExA)
{
......@@ -4655,6 +4656,22 @@ static void test_CreateScalableFontResource(void)
ret = pRemoveFontResourceExA(fot_name, 0, 0);
ok(!ret, "RemoveFontResourceEx() should fail\n");
/* test refcounting */
for (i = 0; i < 5; i++)
{
SetLastError(0xdeadbeef);
ret = pAddFontResourceExA(fot_name, 0, 0);
ok(ret, "AddFontResourceEx() error %d\n", GetLastError());
}
for (i = 0; i < 5; i++)
{
SetLastError(0xdeadbeef);
ret = pRemoveFontResourceExA(fot_name, 0, 0);
ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
}
ret = pRemoveFontResourceExA(fot_name, 0, 0);
ok(!ret, "RemoveFontResourceEx() should fail\n");
DeleteFile(fot_name);
/* test hidden font resource */
......
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