usp10: Fix digit substitution, with test by hansl

Albert Lee trisk at jhu.edu
Mon Aug 14 04:49:27 CDT 2006


This implements ScriptApplyDigitSubstitution and 
ScriptRecordDigitSubstition again.
This passes the test by Hans Liedekker (matching the values returned by 
ScriptApplyDigitSubstitution on Windows XP rather than the documentation).

Thanks, Hans!

-Albert
-------------- next part --------------
Index: dlls/usp10/usp10.c
===================================================================
RCS file: /home/wine/wine/dlls/usp10/usp10.c,v
retrieving revision 1.37
diff -u -r1.37 usp10.c
--- dlls/usp10/usp10.c	8 Aug 2006 18:22:18 -0000	1.37
+++ dlls/usp10/usp10.c	14 Aug 2006 09:41:07 -0000
@@ -28,6 +28,7 @@
 #include "winbase.h"
 #include "wingdi.h"
 #include "winuser.h"
+#include "winnls.h"
 #include "usp10.h"
 
 #include "wine/debug.h"
@@ -170,10 +171,50 @@
  *      ScriptRecordDigitSubstitution (USP10.@)
  *
  */
-HRESULT WINAPI ScriptRecordDigitSubstitution(LCID Locale,SCRIPT_DIGITSUBSTITUTE *psds)
+HRESULT WINAPI ScriptRecordDigitSubstitution(LCID Locale, SCRIPT_DIGITSUBSTITUTE *psds)
 {
-    FIXME("%ld,%p\n",Locale,psds);
-    return E_NOTIMPL;
+    DWORD plgid;
+    DWORD sub;
+
+    /* This implementation appears to be correct for all languages, but it's
+     * not clear if psds->DigitSubstitute is ever set to anything except 
+     * CONTEXT or NONE in reality */
+
+    if (NULL == psds)
+        return E_POINTER;
+    
+    Locale = ConvertDefaultLocale(Locale);
+
+    if (IsValidLocale(Locale, LCID_INSTALLED) == 0)
+        return E_INVALIDARG;
+    
+    plgid = PRIMARYLANGID(LANGIDFROMLCID(Locale));
+
+    psds->TraditionalDigitLanguage = plgid;
+
+    psds->NationalDigitLanguage = ((plgid == LANG_ARABIC) || (plgid == LANG_FARSI)) ? plgid : LANG_ENGLISH;
+
+    GetLocaleInfoW(Locale, LOCALE_IDIGITSUBSTITUTION | LOCALE_RETURN_NUMBER, (LPWSTR)&sub, sizeof(sub) / sizeof(WCHAR));
+
+    switch(sub) {
+        /* http://blogs.msdn.com/michkap/archive/2006/02/22/536877.aspx */
+        case 0: 
+            psds->DigitSubstitute = ((plgid == LANG_ARABIC) || (plgid == LANG_FARSI)) ? SCRIPT_DIGITSUBSTITUTE_CONTEXT : SCRIPT_DIGITSUBSTITUTE_NONE;
+            break;
+        case 1:
+            psds->DigitSubstitute = SCRIPT_DIGITSUBSTITUTE_NONE;
+            break;
+        case 2:
+            psds->DigitSubstitute = SCRIPT_DIGITSUBSTITUTE_NATIONAL;
+            break;
+        default:
+            psds->DigitSubstitute = SCRIPT_DIGITSUBSTITUTE_TRADITIONAL;
+            break;
+    }
+
+    psds->dwReserved = 0;
+
+    return S_OK;
 }
 
 /***********************************************************************
@@ -183,8 +224,28 @@
 HRESULT WINAPI ScriptApplyDigitSubstitution(const SCRIPT_DIGITSUBSTITUTE* psds, 
                                             SCRIPT_CONTROL* psc, SCRIPT_STATE* pss)
 {
-    FIXME("%p,%p,%p\n",psds,psc,pss);
-    return E_NOTIMPL;
+    SCRIPT_DIGITSUBSTITUTE sds;
+
+    if (NULL == psds)
+    {
+        psds = &sds;
+        ScriptRecordDigitSubstitution(LOCALE_USER_DEFAULT, &sds);
+    }
+
+    psc->uDefaultLanguage = LANG_ENGLISH;
+    psc->fContextDigits = FALSE;
+    pss->fDigitSubstitute = FALSE;
+
+    switch (psds->DigitSubstitute) {
+        case SCRIPT_DIGITSUBSTITUTE_CONTEXT:
+        case SCRIPT_DIGITSUBSTITUTE_NATIONAL:
+        case SCRIPT_DIGITSUBSTITUTE_NONE:
+        case SCRIPT_DIGITSUBSTITUTE_TRADITIONAL:
+			return S_OK;
+        default:
+            return E_INVALIDARG;
+    }
+
 }
 
 /***********************************************************************
@@ -781,6 +842,34 @@
 }
 
 /***********************************************************************
+ *      ScriptJustify (USP10.@)
+ *
+ */
+HRESULT WINAPI ScriptJustify(const SCRIPT_VISATTR* psva, 
+                             const int* piAdvance, 
+                             int cGlyphs, 
+                             int iDx, 
+                             int iMinKashida, 
+                             int* piJustify)
+{
+    FIXME("(%p,%p,%d,%d,%d,%p): stub\n", psva, piAdvance, cGlyphs, iDx, iMinKashida, piJustify);
+    return E_NOTIMPL;
+}
+
+/***********************************************************************
+ *      ScriptLayout (USP10.@)
+ *
+ */
+HRESULT WINAPI ScriptLayout(int cRuns,
+                            const BYTE* pbLevel,
+                            int* piVisualToLogical, 
+                            int* piLogicalToVisual)
+{
+    FIXME("(%d,%p,%p,%p): stub\n", cRuns, pbLevel, piVisualToLogical, piLogicalToVisual);
+    return E_NOTIMPL;
+}
+
+/***********************************************************************
  *      ScriptPlace (USP10.@)
  *
  */
Index: dlls/usp10/usp10.spec
===================================================================
RCS file: /home/wine/wine/dlls/usp10/usp10.spec,v
retrieving revision 1.13
diff -u -r1.13 usp10.spec
--- dlls/usp10/usp10.spec	4 Aug 2006 19:58:05 -0000	1.13
+++ dlls/usp10/usp10.spec	14 Aug 2006 09:41:07 -0000
@@ -12,8 +12,8 @@
 @ stdcall ScriptGetProperties(ptr long)
 @ stdcall ScriptIsComplex(wstr long long)
 @ stdcall ScriptItemize(wstr long long ptr ptr ptr ptr)
-@ stub ScriptJustify
-@ stub ScriptLayout
+@ stdcall ScriptJustify(ptr ptr long long long ptr)
+@ stdcall ScriptLayout(long ptr ptr ptr)
 @ stdcall ScriptPlace(ptr ptr ptr long ptr ptr ptr ptr ptr)
 @ stdcall ScriptRecordDigitSubstitution(ptr ptr)
 @ stdcall ScriptShape(ptr ptr ptr long long ptr ptr ptr ptr ptr)
Index: dlls/usp10/tests/usp10.c
===================================================================
RCS file: /home/wine/wine/dlls/usp10/tests/usp10.c,v
retrieving revision 1.21
diff -u -r1.21 usp10.c
--- dlls/usp10/tests/usp10.c	8 Aug 2006 18:22:18 -0000	1.21
+++ dlls/usp10/tests/usp10.c	14 Aug 2006 09:41:08 -0000
@@ -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])
@@ -676,6 +677,271 @@
     }
 }
 
+static const struct
+{
+    LGRPID group;
+    LCID lcid;
+    SCRIPT_DIGITSUBSTITUTE sds;
+    DWORD uDefaultLanguage;
+    DWORD fContextDigits;
+    WORD fDigitSubstitute;
+}
+test_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);
+
+    trace("    { 0x%02lx, 0x%05lx, { %d, %d, %d, %ld }, %d, %d, %d },\n",
+          group, lcid, sds.NationalDigitLanguage, sds.TraditionalDigitLanguage,
+          sds.DigitSubstitute, sds.dwReserved, sc.uDefaultLanguage, sc.fContextDigits,
+          ss.fDigitSubstitute );
+
+    for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+    {
+        if (group == test_data[i].group && lcid == test_data[i].lcid)
+        { 
+            ok(!memcmp(&sds, &test_data[i].sds, sizeof(sds)),
+               "substitution data does not match: got { %d, %d, %d, %d }, expected { %d, %d, %d, %d }\n",
+               sds.NationalDigitLanguage, sds.TraditionalDigitLanguage,
+               sds.DigitSubstitute, sds.dwReserved,
+               test_data[i].sds.NationalDigitLanguage, test_data[i].sds.TraditionalDigitLanguage,
+               test_data[i].sds.DigitSubstitute, test_data[i].sds.dwReserved);
+
+            ok(sc.uDefaultLanguage == test_data[i].uDefaultLanguage,
+               "sc.uDefaultLanguage does not match: got %d, expected %d\n",
+               sc.uDefaultLanguage, test_data[i].uDefaultLanguage);
+            ok(sc.fContextDigits == test_data[i].fContextDigits,
+               "sc.fContextDigits does not match: got %d, expected %d\n",
+               sc.fContextDigits, test_data[i].fContextDigits);
+            ok(ss.fDigitSubstitute == test_data[i].fDigitSubstitute,
+               "ss.fDigitSubstitute does not match: got %d, expected %d\n",
+               ss.fDigitSubstitute, test_data[i].fDigitSubstitute);
+        }
+    }
+    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());
+    }
+}
+
 void test_ScriptCacheGetHeight(HDC hdc)
 {
     HRESULT hr;
@@ -758,4 +1024,6 @@
     test_ScriptTextOut();
     test_ScriptXtoX();
     test_ScriptString();
+
+    test_digit_substitution();
 }


More information about the wine-patches mailing list