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

This commit is contained in:
Alexandre Julliard 2013-03-04 11:35:50 +01:00
parent 93c1389b7c
commit 591a31ba67
2 changed files with 24 additions and 0 deletions

View file

@ -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",

View file

@ -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 */