[1/2] mlang: Implement IMLangFontLink2_CodePageToScriptID.

Hans Leidekker hans at codeweavers.com
Fri Jun 26 07:20:07 CDT 2009


diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c
index d762bac..6590ea5 100644
--- a/dlls/mlang/mlang.c
+++ b/dlls/mlang/mlang.c
@@ -455,13 +455,13 @@ static const struct mlang_data
     { "Arabic",1256,sizeof(arabic_cp)/sizeof(arabic_cp[0]),arabic_cp,
       "Courier","Arial", sidArabic }, /* FIXME */
     { "Baltic",1257,sizeof(baltic_cp)/sizeof(baltic_cp[0]),baltic_cp,
-      "Courier","Arial" }, /* FIXME */
+      "Courier","Arial", sidAsciiLatin }, /* FIXME */
     { "Chinese Simplified",936,sizeof(chinese_simplified_cp)/sizeof(chinese_simplified_cp[0]),chinese_simplified_cp,
-      "Courier","Arial" }, /* FIXME */
+      "Courier","Arial", sidHan }, /* FIXME */
     { "Chinese Traditional",950,sizeof(chinese_traditional_cp)/sizeof(chinese_traditional_cp[0]),chinese_traditional_cp,
-      "Courier","Arial" }, /* FIXME */
+      "Courier","Arial", sidBopomofo }, /* FIXME */
     { "Central European",1250,sizeof(central_european_cp)/sizeof(central_european_cp[0]),central_european_cp,
-      "Courier","Arial" }, /* FIXME */
+      "Courier","Arial", sidAsciiLatin }, /* FIXME */
     { "Cyrillic",1251,sizeof(cyrillic_cp)/sizeof(cyrillic_cp[0]),cyrillic_cp,
       "Courier","Arial", sidCyrillic }, /* FIXME */
     { "Greek",1253,sizeof(greek_cp)/sizeof(greek_cp[0]),greek_cp,
@@ -469,17 +469,17 @@ static const struct mlang_data
     { "Hebrew",1255,sizeof(hebrew_cp)/sizeof(hebrew_cp[0]),hebrew_cp,
       "Courier","Arial", sidHebrew }, /* FIXME */
     { "Japanese",932,sizeof(japanese_cp)/sizeof(japanese_cp[0]),japanese_cp,
-      "MS Gothic","MS PGothic" },
+      "MS Gothic","MS PGothic", sidKana },
     { "Korean",949,sizeof(korean_cp)/sizeof(korean_cp[0]),korean_cp,
-      "Courier","Arial" }, /* FIXME */
+      "Courier","Arial", sidHangul }, /* FIXME */
     { "Thai",874,sizeof(thai_cp)/sizeof(thai_cp[0]),thai_cp,
       "Courier","Arial", sidThai }, /* FIXME */
     { "Turkish",1254,sizeof(turkish_cp)/sizeof(turkish_cp[0]),turkish_cp,
-      "Courier","Arial" }, /* FIXME */
+      "Courier","Arial", sidAsciiLatin }, /* FIXME */
     { "Vietnamese",1258,sizeof(vietnamese_cp)/sizeof(vietnamese_cp[0]),vietnamese_cp,
-      "Courier","Arial" }, /* FIXME */
+      "Courier","Arial", sidAsciiLatin }, /* FIXME */
     { "Western European",1252,sizeof(western_cp)/sizeof(western_cp[0]),western_cp,
-      "Courier","Arial", sidLatin }, /* FIXME */
+      "Courier","Arial", sidAsciiLatin }, /* FIXME */
     { "Unicode",CP_UNICODE,sizeof(unicode_cp)/sizeof(unicode_cp[0]),unicode_cp,
       "Courier","Arial" } /* FIXME */
 };
@@ -3401,8 +3401,21 @@ static HRESULT WINAPI fnIMLangFontLink2_GetScriptFontInfo(IMLangFontLink2* This,
 static HRESULT WINAPI fnIMLangFontLink2_CodePageToScriptID(IMLangFontLink2* This,
         UINT uiCodePage, SCRIPT_ID *pSid)
 {
-    FIXME("(%p)->%i %p\n",This, uiCodePage, pSid);
-    return E_NOTIMPL;
+    UINT i;
+
+    TRACE("(%p)->%i %p\n", This, uiCodePage, pSid);
+
+    if (uiCodePage == CP_UNICODE) return E_FAIL;
+
+    for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
+    {
+        if (uiCodePage == mlang_data[i].family_codepage)
+        {
+            if (pSid) *pSid = mlang_data[i].sid;
+            return S_OK;
+        }
+    }
+    return E_FAIL;
 }
 
 static const IMLangFontLink2Vtbl IMLangFontLink2_vtbl =
diff --git a/dlls/mlang/tests/mlang.c b/dlls/mlang/tests/mlang.c
index 4530a09..eceb3ab 100644
--- a/dlls/mlang/tests/mlang.c
+++ b/dlls/mlang/tests/mlang.c
@@ -1841,23 +1841,23 @@ static void test_GetScriptFontInfo(IMLangFontLink2 *font_link)
     SCRIPTFONTINFO sfi[1];
 
     nfonts = 0;
-    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, 0, &nfonts, NULL);
+    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, 0, &nfonts, NULL);
     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
     ok(nfonts, "unexpected result\n");
 
     nfonts = 0;
-    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_FIXED_FONT, &nfonts, NULL);
+    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, SCRIPTCONTF_FIXED_FONT, &nfonts, NULL);
     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
     ok(nfonts, "unexpected result\n");
 
     nfonts = 0;
-    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_PROPORTIONAL_FONT, &nfonts, NULL);
+    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, SCRIPTCONTF_PROPORTIONAL_FONT, &nfonts, NULL);
     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
     ok(nfonts, "unexpected result\n");
 
     nfonts = 1;
     memset(sfi, 0, sizeof(sfi));
-    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_FIXED_FONT, &nfonts, sfi);
+    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, SCRIPTCONTF_FIXED_FONT, &nfonts, sfi);
     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
     ok(nfonts == 1, "got %u, expected 1\n", nfonts);
     ok(sfi[0].scripts != 0, "unexpected result\n");
@@ -1865,13 +1865,55 @@ static void test_GetScriptFontInfo(IMLangFontLink2 *font_link)
 
     nfonts = 1;
     memset(sfi, 0, sizeof(sfi));
-    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_PROPORTIONAL_FONT, &nfonts, sfi);
+    hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, SCRIPTCONTF_PROPORTIONAL_FONT, &nfonts, sfi);
     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
     ok(nfonts == 1, "got %u, expected 1\n", nfonts);
     ok(sfi[0].scripts != 0, "unexpected result\n");
     ok(sfi[0].wszFont[0], "unexpected result\n");
 }
 
+static void test_CodePageToScriptID(IMLangFontLink2 *font_link)
+{
+    HRESULT hr;
+    UINT i;
+    SCRIPT_ID sid;
+    static const struct
+    {
+        UINT cp;
+        SCRIPT_ID sid;
+        HRESULT hr;
+    }
+    cp_sid[] =
+    {
+        {874,  sidThai},
+        {932,  sidKana},
+        {936,  sidHan},
+        {949,  sidHangul},
+        {950,  sidBopomofo},
+        {1250, sidAsciiLatin},
+        {1251, sidCyrillic},
+        {1252, sidAsciiLatin},
+        {1253, sidGreek},
+        {1254, sidAsciiLatin},
+        {1255, sidHebrew},
+        {1256, sidArabic},
+        {1257, sidAsciiLatin},
+        {1258, sidAsciiLatin},
+        {CP_UNICODE, 0, E_FAIL}
+    };
+
+    for (i = 0; i < sizeof(cp_sid)/sizeof(cp_sid[0]); i++)
+    {
+        hr = IMLangFontLink2_CodePageToScriptID(font_link, cp_sid[i].cp, &sid);
+        ok(hr == cp_sid[i].hr, "%u CodePageToScriptID failed 0x%08x %u\n", i, hr, GetLastError());
+        if (SUCCEEDED(hr))
+        {
+            ok(sid == cp_sid[i].sid,
+               "%u got sid %u for codepage %u, expected %u\n", i, sid, cp_sid[i].cp, cp_sid[i].sid);
+        }
+    }
+}
+
 START_TEST(mlang)
 {
     IMultiLanguage  *iML = NULL;
@@ -1949,6 +1991,7 @@ START_TEST(mlang)
     if (ret != S_OK || !iMLFL2) return;
 
     test_GetScriptFontInfo(iMLFL2);
+    test_CodePageToScriptID(iMLFL2);
     IMLangFontLink2_Release(iMLFL2);
 
     CoUninitialize();



More information about the wine-patches mailing list