usp10/tests: Add advance width tests with CJK bitmap font.

We should use associated glyph's advance width instead of the default one.
Because, when using CJK bitmap system font, full-width character
(e.g. Hiragana) is rendered with associated font. The glyph is different from
the default glyph.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Aric Stewart <aric@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Akihiro Sagawa 2019-06-13 23:50:23 +09:00 committed by Alexandre Julliard
parent 0a4f831979
commit 9dabf7b013
1 changed files with 60 additions and 0 deletions

View File

@ -2091,6 +2091,7 @@ static void test_ScriptShape(HDC hdc)
static void test_ScriptPlace(HDC hdc)
{
static const WCHAR test1[] = {'t', 'e', 's', 't',0};
static const WCHAR test2[] = {0x3044, 0x308d, 0x306f,0}; /* Hiragana, Iroha */
BOOL ret;
HRESULT hr;
SCRIPT_CACHE sc = NULL;
@ -2101,6 +2102,9 @@ static void test_ScriptPlace(HDC hdc)
int nb, widths[4];
GOFFSET offset[4];
ABC abc[4];
HFONT hfont, prev_hfont;
LOGFONTA lf;
TEXTMETRICW tm;
hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
@ -2154,6 +2158,62 @@ static void test_ScriptPlace(HDC hdc)
ok(ret, "ExtTextOutW should return TRUE\n");
ScriptFreeCache(&sc);
/* test CJK bitmap font which has associated font */
memset(&lf, 0, sizeof(lf));
strcpy(lf.lfFaceName, "Fixedsys");
lf.lfCharSet = DEFAULT_CHARSET;
hfont = CreateFontIndirectA(&lf);
prev_hfont = SelectObject(hdc, hfont);
ret = GetTextMetricsW(hdc, &tm);
ok(ret, "GetTextMetrics failed\n");
switch(tm.tmCharSet) {
case SHIFTJIS_CHARSET:
case HANGUL_CHARSET:
case GB2312_CHARSET:
case CHINESEBIG5_CHARSET:
{
SIZE sz;
DWORD len = lstrlenW(test2), i, total;
ret = GetTextExtentExPointW(hdc, test2, len, 0, NULL, NULL, &sz);
ok(ret, "GetTextExtentExPoint failed\n");
if (sz.cx > len * tm.tmAveCharWidth)
{
hr = ScriptItemize(test2, len, 2, NULL, NULL, items, NULL);
ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
items[0].a.fNoGlyphIndex = TRUE;
memset(glyphs, 'a', sizeof(glyphs));
hr = ScriptShape(hdc, &sc, test2, len, ARRAY_SIZE(glyphs), &items[0].a, glyphs, logclust, attrs, &nb);
ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
memset(offset, 'a', sizeof(offset));
memset(widths, 'a', sizeof(widths));
hr = ScriptPlace(hdc, &sc, glyphs, ARRAY_SIZE(widths), attrs, &items[0].a, widths, offset, NULL);
ok(hr == S_OK, "ScriptPlace should return S_OK not %08x\n", hr);
for (total = 0, i = 0; i < nb; i++)
{
ok(offset[i].du == 0, "[%d] expected 0, got %d\n", i, offset[i].du);
ok(offset[i].dv == 0, "[%d] expected 0, got %d\n", i, offset[i].dv);
todo_wine ok(widths[i] > tm.tmAveCharWidth, "[%d] expected greater than %d, got %d\n",
i, tm.tmAveCharWidth, widths[i]);
total += widths[i];
}
todo_wine ok(total == sz.cx, "expected %d, got %d\n", sz.cx, total);
}
else
skip("Associated font is unavailable\n");
break;
}
default:
skip("Non-CJK locale\n");
}
SelectObject(hdc, prev_hfont);
}
static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])