Akihiro Sagawa : usp10/tests: Add advance width tests with CJK bitmap font.
Alexandre Julliard
julliard at winehq.org
Mon Nov 25 09:12:24 CST 2019
Module: wine
Branch: stable
Commit: 5b810ec3bd26d76543291e662f6d3cc9c036edae
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5b810ec3bd26d76543291e662f6d3cc9c036edae
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Thu Jun 13 23:50:23 2019 +0900
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 at gmail.com>
Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 9dabf7b013ea7c12a93d665d514ce15560c2f991)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/usp10/tests/usp10.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index e907c8c40a..cfd481937a 100644
--- a/dlls/usp10/tests/usp10.c
+++ b/dlls/usp10/tests/usp10.c
@@ -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])
More information about the wine-cvs
mailing list