usp10: Implement and test Script{Apply, Record}DigitSubstitution.

This commit is contained in:
Albert Lee 2006-09-07 02:42:56 -04:00 committed by Alexandre Julliard
parent 2ff880edc1
commit b2182f9d82
2 changed files with 354 additions and 7 deletions

View File

@ -30,6 +30,7 @@
#include <wingdi.h>
#include <winuser.h>
#include <winerror.h>
#include <winnls.h>
#include <usp10.h>
static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
@ -726,6 +727,259 @@ void test_ScriptGetGlyphABCWidth(HDC hdc)
ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr);
}
static const struct
{
LGRPID group;
LCID lcid;
SCRIPT_DIGITSUBSTITUTE sds;
DWORD uDefaultLanguage;
DWORD fContextDigits;
WORD fDigitSubstitute;
}
subst_data[] =
{
{ 0x01, 0x00403, { 9, 3, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00406, { 9, 6, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00407, { 9, 7, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00409, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0040a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0040b, { 9, 11, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0040c, { 9, 12, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0040f, { 9, 15, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00410, { 9, 16, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00413, { 9, 19, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00414, { 9, 20, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00416, { 9, 22, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0041d, { 9, 29, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00421, { 9, 33, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0042d, { 9, 45, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00432, { 9, 50, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00434, { 9, 52, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00435, { 9, 53, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00436, { 9, 54, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00438, { 9, 56, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0043a, { 9, 58, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0043b, { 9, 59, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0043e, { 9, 62, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00441, { 9, 65, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00452, { 9, 82, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00456, { 9, 86, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0046b, { 9, 107, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0046c, { 9, 108, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00481, { 9, 129, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00807, { 9, 7, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00809, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0080a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0080c, { 9, 12, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00810, { 9, 16, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00813, { 9, 19, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00814, { 9, 20, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00816, { 9, 22, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0081d, { 9, 29, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0083b, { 9, 59, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0083e, { 9, 62, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0086b, { 9, 107, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00c07, { 9, 7, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00c09, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00c0c, { 9, 12, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00c3b, { 9, 59, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x00c6b, { 9, 107, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x01007, { 9, 7, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x01009, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0100a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0100c, { 9, 12, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0103b, { 9, 59, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x01407, { 9, 7, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x01409, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0140a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0140c, { 9, 12, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0143b, { 9, 59, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x01809, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0180a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0180c, { 9, 12, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0183b, { 9, 59, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x01c09, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x01c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x01c3b, { 9, 59, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x02009, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0200a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0203b, { 9, 59, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x02409, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0240a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0243b, { 9, 59, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x02809, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0280a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x02c09, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x02c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x03009, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0300a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x03409, { 9, 9, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0340a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0380a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x03c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0400a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0440a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0480a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x04c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x0500a, { 9, 10, 1, 0 }, 9, 0, 0 },
{ 0x01, 0x10407, { 9, 7, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x00405, { 9, 5, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x0040e, { 9, 14, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x00415, { 9, 21, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x00418, { 9, 24, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x0041a, { 9, 26, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x0041b, { 9, 27, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x0041c, { 9, 28, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x00424, { 9, 36, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x0081a, { 9, 26, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x0101a, { 9, 26, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x0141a, { 9, 26, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x0181a, { 9, 26, 1, 0 }, 9, 0, 0 },
{ 0x02, 0x1040e, { 9, 14, 1, 0 }, 9, 0, 0 },
{ 0x03, 0x00425, { 9, 37, 1, 0 }, 9, 0, 0 },
{ 0x03, 0x00426, { 9, 38, 1, 0 }, 9, 0, 0 },
{ 0x03, 0x00427, { 9, 39, 1, 0 }, 9, 0, 0 },
{ 0x04, 0x00408, { 9, 8, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x00402, { 9, 2, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x00419, { 9, 25, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x00422, { 9, 34, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x00423, { 9, 35, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x0042f, { 9, 47, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x0043f, { 9, 63, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x00440, { 9, 64, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x00444, { 9, 68, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x00450, { 9, 80, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x0082c, { 9, 44, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x00843, { 9, 67, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x00c1a, { 9, 26, 1, 0 }, 9, 0, 0 },
{ 0x05, 0x01c1a, { 9, 26, 1, 0 }, 9, 0, 0 },
{ 0x06, 0x0041f, { 9, 31, 1, 0 }, 9, 0, 0 },
{ 0x06, 0x0042c, { 9, 44, 1, 0 }, 9, 0, 0 },
{ 0x06, 0x00443, { 9, 67, 1, 0 }, 9, 0, 0 },
{ 0x07, 0x00411, { 9, 17, 1, 0 }, 9, 0, 0 },
{ 0x08, 0x00412, { 9, 18, 1, 0 }, 9, 0, 0 },
{ 0x09, 0x00404, { 9, 4, 1, 0 }, 9, 0, 0 },
{ 0x09, 0x00c04, { 9, 4, 1, 0 }, 9, 0, 0 },
{ 0x09, 0x01404, { 9, 4, 1, 0 }, 9, 0, 0 },
{ 0x09, 0x21404, { 9, 4, 1, 0 }, 9, 0, 0 },
{ 0x09, 0x30404, { 9, 4, 1, 0 }, 9, 0, 0 },
{ 0x0a, 0x00804, { 9, 4, 1, 0 }, 9, 0, 0 },
{ 0x0a, 0x01004, { 9, 4, 1, 0 }, 9, 0, 0 },
{ 0x0a, 0x20804, { 9, 4, 1, 0 }, 9, 0, 0 },
{ 0x0a, 0x21004, { 9, 4, 1, 0 }, 9, 0, 0 },
{ 0x0b, 0x0041e, { 9, 30, 1, 0 }, 9, 0, 0 },
{ 0x0c, 0x0040d, { 9, 13, 1, 0 }, 9, 0, 0 },
{ 0x0d, 0x00401, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x00420, { 9, 32, 1, 0 }, 9, 0, 0 },
{ 0x0d, 0x00429, { 41, 41, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x0045a, { 9, 90, 1, 0 }, 9, 0, 0 },
{ 0x0d, 0x00465, { 9, 101, 1, 0 }, 9, 0, 0 },
{ 0x0d, 0x00801, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x00c01, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x01001, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x01401, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x01801, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x01c01, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x02001, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x02401, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x02801, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x02c01, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x03001, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x03401, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x03801, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x03c01, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0d, 0x04001, { 1, 1, 0, 0 }, 9, 0, 0 },
{ 0x0e, 0x0042a, { 9, 42, 1, 0 }, 9, 0, 0 },
{ 0x0f, 0x00439, { 9, 57, 1, 0 }, 9, 0, 0 },
{ 0x0f, 0x00446, { 9, 70, 1, 0 }, 9, 0, 0 },
{ 0x0f, 0x00447, { 9, 71, 1, 0 }, 9, 0, 0 },
{ 0x0f, 0x00449, { 9, 73, 1, 0 }, 9, 0, 0 },
{ 0x0f, 0x0044a, { 9, 74, 1, 0 }, 9, 0, 0 },
{ 0x0f, 0x0044b, { 9, 75, 1, 0 }, 9, 0, 0 },
{ 0x0f, 0x0044e, { 9, 78, 1, 0 }, 9, 0, 0 },
{ 0x0f, 0x0044f, { 9, 79, 1, 0 }, 9, 0, 0 },
{ 0x0f, 0x00457, { 9, 87, 1, 0 }, 9, 0, 0 },
{ 0x10, 0x00437, { 9, 55, 1, 0 }, 9, 0, 0 },
{ 0x10, 0x10437, { 9, 55, 1, 0 }, 9, 0, 0 },
{ 0x11, 0x0042b, { 9, 43, 1, 0 }, 9, 0, 0 }
};
static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR lparam)
{
HRESULT hr;
SCRIPT_DIGITSUBSTITUTE sds;
SCRIPT_CONTROL sc;
SCRIPT_STATE ss;
LCID lcid_old;
unsigned int i;
if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
memset(&sds, 0, sizeof(sds));
memset(&sc, 0, sizeof(sc));
memset(&ss, 0, sizeof(ss));
lcid_old = GetThreadLocale();
if (!SetThreadLocale(lcid)) return TRUE;
hr = ScriptRecordDigitSubstitution(lcid, &sds);
ok(hr == S_OK, "ScriptRecordDigitSubstitution failed: 0x%08lx\n", hr);
hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);
ok(hr == S_OK, "ScriptApplyDigitSubstitution failed: 0x%08lx\n", hr);
for (i = 0; i < sizeof(subst_data)/sizeof(subst_data[0]); i++)
{
if (group == subst_data[i].group && lcid == subst_data[i].lcid)
{
ok(!memcmp(&sds, &subst_data[i].sds, sizeof(sds)),
"substitution data does not match\n");
ok(sc.uDefaultLanguage == subst_data[i].uDefaultLanguage,
"sc.uDefaultLanguage does not match\n");
ok(sc.fContextDigits == subst_data[i].fContextDigits,
"sc.fContextDigits does not match\n");
ok(ss.fDigitSubstitute == subst_data[i].fDigitSubstitute,
"ss.fDigitSubstitute does not match\n");
}
}
SetThreadLocale(lcid_old);
return TRUE;
}
static void test_digit_substitution(void)
{
BOOL ret;
unsigned int i;
static const LGRPID groups[] =
{
LGRPID_WESTERN_EUROPE,
LGRPID_CENTRAL_EUROPE,
LGRPID_BALTIC,
LGRPID_GREEK,
LGRPID_CYRILLIC,
LGRPID_TURKISH,
LGRPID_JAPANESE,
LGRPID_KOREAN,
LGRPID_TRADITIONAL_CHINESE,
LGRPID_SIMPLIFIED_CHINESE,
LGRPID_THAI,
LGRPID_HEBREW,
LGRPID_ARABIC,
LGRPID_VIETNAMESE,
LGRPID_INDIC,
LGRPID_GEORGIAN,
LGRPID_ARMENIAN
};
for (i = 0; i < sizeof(groups)/sizeof(groups[0]); i++)
{
ret = EnumLanguageGroupLocales(enum_proc, groups[i], 0, 0);
ok(ret, "EnumLanguageGroupLocales failed unexpectedly: 0x%08lx\n", GetLastError());
}
}
START_TEST(usp10)
{
HWND hwnd;
@ -756,4 +1010,6 @@ START_TEST(usp10)
test_ScriptTextOut();
test_ScriptXtoX();
test_ScriptString();
test_digit_substitution();
}

View File

@ -28,6 +28,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "usp10.h"
#include "wine/debug.h"
@ -169,22 +170,112 @@ HRESULT WINAPI ScriptGetFontProperties(HDC hdc, SCRIPT_CACHE *psc, SCRIPT_FONTPR
/***********************************************************************
* ScriptRecordDigitSubstitution (USP10.@)
*
* Record digit substitution settings for a given locale.
*
* PARAMS
* locale [I] Locale identifier.
* sds [I] Structure to record substitution settings.
*
* RETURNS
* Success: S_OK
* Failure: E_POINTER if sds is NULL, E_INVALIDARG otherwise.
*
* SEE ALSO
* http://blogs.msdn.com/michkap/archive/2006/02/22/536877.aspx
*/
HRESULT WINAPI ScriptRecordDigitSubstitution(LCID Locale,SCRIPT_DIGITSUBSTITUTE *psds)
HRESULT WINAPI ScriptRecordDigitSubstitution(LCID locale, SCRIPT_DIGITSUBSTITUTE *sds)
{
FIXME("%ld,%p\n",Locale,psds);
return E_NOTIMPL;
DWORD plgid, sub;
TRACE("0x%lx, %p\n", locale, sds);
/* This implementation appears to be correct for all languages, but it's
* not clear if sds->DigitSubstitute is ever set to anything except
* CONTEXT or NONE in reality */
if (!sds) return E_POINTER;
locale = ConvertDefaultLocale(locale);
if (!IsValidLocale(locale, LCID_INSTALLED))
return E_INVALIDARG;
plgid = PRIMARYLANGID(LANGIDFROMLCID(locale));
sds->TraditionalDigitLanguage = plgid;
if (plgid == LANG_ARABIC || plgid == LANG_FARSI)
sds->NationalDigitLanguage = plgid;
else
sds->NationalDigitLanguage = LANG_ENGLISH;
if (!GetLocaleInfoW(locale, LOCALE_IDIGITSUBSTITUTION | LOCALE_RETURN_NUMBER,
(LPWSTR)&sub, sizeof(sub)/sizeof(WCHAR))) return E_INVALIDARG;
switch (sub)
{
case 0:
if (plgid == LANG_ARABIC || plgid == LANG_FARSI)
sds->DigitSubstitute = SCRIPT_DIGITSUBSTITUTE_CONTEXT;
else
sds->DigitSubstitute = SCRIPT_DIGITSUBSTITUTE_NONE;
break;
case 1:
sds->DigitSubstitute = SCRIPT_DIGITSUBSTITUTE_NONE;
break;
case 2:
sds->DigitSubstitute = SCRIPT_DIGITSUBSTITUTE_NATIONAL;
break;
default:
sds->DigitSubstitute = SCRIPT_DIGITSUBSTITUTE_TRADITIONAL;
break;
}
sds->dwReserved = 0;
return S_OK;
}
/***********************************************************************
* ScriptApplyDigitSubstitution (USP10.@)
*
* Apply digit substitution settings.
*
* PARAMS
* sds [I] Structure with recorded substitution settings.
* sc [I] Script control structure.
* ss [I] Script state structure.
*
* RETURNS
* Success: S_OK
* Failure: E_INVALIDARG if sds is invalid. Otherwise an HRESULT.
*/
HRESULT WINAPI ScriptApplyDigitSubstitution(const SCRIPT_DIGITSUBSTITUTE* psds,
SCRIPT_CONTROL* psc, SCRIPT_STATE* pss)
HRESULT WINAPI ScriptApplyDigitSubstitution(const SCRIPT_DIGITSUBSTITUTE *sds,
SCRIPT_CONTROL *sc, SCRIPT_STATE *ss)
{
FIXME("%p,%p,%p\n",psds,psc,pss);
return E_NOTIMPL;
SCRIPT_DIGITSUBSTITUTE psds;
TRACE("%p, %p, %p\n", sds, sc, ss);
if (!sc || !ss) return E_POINTER;
if (!sds)
{
sds = &psds;
if (ScriptRecordDigitSubstitution(LOCALE_USER_DEFAULT, &psds) != S_OK)
return E_INVALIDARG;
}
sc->uDefaultLanguage = LANG_ENGLISH;
sc->fContextDigits = 0;
ss->fDigitSubstitute = 0;
switch (sds->DigitSubstitute) {
case SCRIPT_DIGITSUBSTITUTE_CONTEXT:
case SCRIPT_DIGITSUBSTITUTE_NATIONAL:
case SCRIPT_DIGITSUBSTITUTE_NONE:
case SCRIPT_DIGITSUBSTITUTE_TRADITIONAL:
return S_OK;
default:
return E_INVALIDARG;
}
}
/***********************************************************************