Aric Stewart : usp10: Fix ScriptGetCMap handling of unsupported glyphs.
Alexandre Julliard
julliard at winehq.org
Thu May 6 11:13:21 CDT 2010
Module: wine
Branch: master
Commit: abae85b9767dce7c4eb62f8faffdb328b664dd03
URL: http://source.winehq.org/git/wine.git/?a=commit;h=abae85b9767dce7c4eb62f8faffdb328b664dd03
Author: Aric Stewart <aric at codeweavers.com>
Date: Wed May 5 11:51:52 2010 -0500
usp10: Fix ScriptGetCMap handling of unsupported glyphs.
---
dlls/usp10/tests/usp10.c | 15 +++++++++++++--
dlls/usp10/usp10.c | 9 ++++++++-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index ad65b25..f76f95c 100644
--- a/dlls/usp10/tests/usp10.c
+++ b/dlls/usp10/tests/usp10.c
@@ -583,10 +583,12 @@ static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
int cInChars;
int cChars;
unsigned short pwOutGlyphs3[256];
- WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
DWORD dwFlags;
int cnt;
+ static const WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
+ static const WCHAR TestItem2[] = {0x202B, 'i', 'n', 0x202C,0};
+
/* Check to make sure that SCRIPT_CACHE gets allocated ok */
dwFlags = 0;
cInChars = cChars = 5;
@@ -627,10 +629,19 @@ static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
-
+
hr = ScriptFreeCache( &psc);
ok (!psc, "psc is not null after ScriptFreeCache\n");
+ cInChars = cChars = 4;
+ hr = ScriptGetCMap(hdc, &psc, TestItem2, cInChars, dwFlags, pwOutGlyphs3);
+ ok (hr == S_FALSE, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr);
+ ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
+ ok(pwOutGlyphs3[0] == 0, "Glyph 0 should be default glyph\n");
+ ok(pwOutGlyphs3[3] == 0, "Glyph 0 should be default glyph\n");
+
+ hr = ScriptFreeCache( &psc);
+ ok (!psc, "psc is not null after ScriptFreeCache\n");
}
static void test_ScriptGetFontProperties(HDC hdc)
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 0ab86a1..b736966 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -1528,6 +1528,8 @@ HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars
if ((hr = init_script_cache(hdc, psc)) != S_OK) return hr;
+ hr = S_OK;
+
if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE))
{
for (i = 0; i < cChars; i++)
@@ -1537,6 +1539,11 @@ HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars
WORD glyph;
if (!hdc) return E_PENDING;
if (GetGlyphIndicesW(hdc, &pwcInChars[i], 1, &glyph, GGI_MARK_NONEXISTING_GLYPHS) == GDI_ERROR) return S_FALSE;
+ if (glyph == 0xffff)
+ {
+ hr = S_FALSE;
+ glyph = 0x0;
+ }
pwOutGlyphs[i] = set_cache_glyph(psc, pwcInChars[i], glyph);
}
}
@@ -1546,7 +1553,7 @@ HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars
TRACE("no glyph translation\n");
for (i = 0; i < cChars; i++) pwOutGlyphs[i] = pwcInChars[i];
}
- return S_OK;
+ return hr;
}
/***********************************************************************
More information about the wine-cvs
mailing list