Aric Stewart : usp10: Handle Combining Diacritical Marks.

Alexandre Julliard julliard at winehq.org
Mon Nov 21 11:10:06 CST 2011


Module: wine
Branch: master
Commit: 714408684dbbc269d4d321d5b5f2d01f84d48dcf
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=714408684dbbc269d4d321d5b5f2d01f84d48dcf

Author: Aric Stewart <aric at codeweavers.com>
Date:   Sun Nov 20 21:05:00 2011 -0700

usp10: Handle Combining Diacritical Marks.

---

 dlls/usp10/shape.c          |    1 +
 dlls/usp10/tests/usp10.c    |   16 ++++++++++++++++
 dlls/usp10/usp10.c          |   23 ++++++++++++++++++++++-
 dlls/usp10/usp10_internal.h |    2 ++
 4 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/dlls/usp10/shape.c b/dlls/usp10/shape.c
index bd383b9..3662bc8 100644
--- a/dlls/usp10/shape.c
+++ b/dlls/usp10/shape.c
@@ -582,6 +582,7 @@ static const ScriptShapeData ShapingData[] =
     {{ devanagari_features, 6}, required_telugu_features, "knda", "knd2", ContextualShape_Kannada, ShapeCharGlyphProp_Kannada},
     {{ devanagari_features, 6}, required_telugu_features, "mlym", "mlm2", ContextualShape_Malayalam, ShapeCharGlyphProp_Malayalam},
     {{ devanagari_features, 6}, required_telugu_features, "mlym", "mlm2", ContextualShape_Malayalam, ShapeCharGlyphProp_Malayalam},
+    {{ standard_features, 2}, NULL, "" , "", NULL, NULL},
 };
 
 static INT GSUB_is_glyph_covered(LPCVOID table , UINT glyph)
diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index 492564e..ede7603 100644
--- a/dlls/usp10/tests/usp10.c
+++ b/dlls/usp10/tests/usp10.c
@@ -277,6 +277,14 @@ static void test_ScriptItemize( void )
     static const itemTest t191[2] = {{{0,0,0,0,0},0,0,0,0,mlym_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
     static const itemTest t192[2] = {{{0,0,0,0,0},0,0,0,2,mlym_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
 
+    /* Diacritical */
+    static const WCHAR test20[] = {0x0309,'a','b','c','d',0};
+    static const itemTest t201[3] = {{{0,0,0,0,0},0,0,0,0,0x0,FALSE},{{0,0,0,0,0},1,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
+    static const itemTest t202[3] = {{{0,0,0,0,0},0,0,0,2,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},1,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
+
+    static const WCHAR test21[] = {0x0710, 0x0712, 0x0308, 0x0712, 0x0714,0};
+    static const itemTest t211[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
+
     SCRIPT_ITEM items[15];
     SCRIPT_CONTROL  Control;
     SCRIPT_STATE    State;
@@ -329,6 +337,8 @@ static void test_ScriptItemize( void )
     test_items_ok(test17,6,NULL,NULL,1,t171,FALSE,0);
     test_items_ok(test18,5,NULL,NULL,1,t181,FALSE,0);
     test_items_ok(test19,6,NULL,NULL,1,t191,FALSE,0);
+    test_items_ok(test20,5,NULL,NULL,2,t201,FALSE,0);
+    test_items_ok(test21,5,NULL,NULL,1,t211,FALSE,0);
 
     State.uBidiLevel = 0;
     test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
@@ -355,6 +365,8 @@ static void test_ScriptItemize( void )
     test_items_ok(test17,6,&Control,&State,1,t171,FALSE,0);
     test_items_ok(test18,5,&Control,&State,1,t181,FALSE,0);
     test_items_ok(test19,6,&Control,&State,1,t191,FALSE,0);
+    test_items_ok(test20,5,&Control,&State,2,t201,FALSE,0);
+    test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
 
     State.uBidiLevel = 1;
     test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
@@ -381,6 +393,8 @@ static void test_ScriptItemize( void )
     test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
     test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
     test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
+    test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
+    test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
 
     State.uBidiLevel = 1;
     Control.fMergeNeutralItems = TRUE;
@@ -408,6 +422,8 @@ static void test_ScriptItemize( void )
     test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
     test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
     test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
+    test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
+    test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
 }
 
 static inline void _test_shape_ok(int valid, HDC hdc, LPCWSTR string,
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 06cde93..ae3a7b4 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -57,6 +57,8 @@ static const scriptRange scriptRanges[] = {
     /* Latin Extended-B: U+0180–U+024F */
     /* IPA Extensions: U+0250–U+02AF */
     { Script_Latin,      0x00,   0x2af ,  Script_Numeric, Script_Punctuation},
+    /* Combining Diacritical Marks : U+0300–U+036F */
+    { Script_Diacritical,0x300,  0x36f,  0, 0},
     /* Greek: U+0370–U+03FF */
     { Script_Greek,      0x370,  0x3ff,  0, 0},
     /* Cyrillic: U+0400–U+04FF */
@@ -110,6 +112,8 @@ static const scriptRange scriptRanges[] = {
     { Script_Devanagari, 0x1cd0, 0x1cff, Script_Devanagari_Numeric, 0},
     /* Phonetic Extensions: U+1D00–U+1DBF */
     { Script_Latin,      0x1d00, 0x1dbf, 0, 0},
+    /* Combining Diacritical Marks Supplement: U+1DC0–U+1DFF */
+    { Script_Diacritical,0x1dc0, 0x1dff, 0, 0},
     /* Latin Extended Additional: U+1E00–U+1EFF */
     { Script_Latin,      0x1e00, 0x1eff, 0, 0},
     /* Greek Extended: U+1F00–U+1FFF */
@@ -354,6 +358,10 @@ static const scriptData scriptInformation[] = {
      {LANG_MALAYALAM, 1, 1, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      MS_MAKE_TAG('m','l','y','m'),
      {'K','a','r','t','i','k','a',0}},
+    {{Script_Diacritical, 0, 0, 0, 0, 0, 0, { 0,0,0,0,0,0,0,0,0,0,0}},
+     {LANG_ENGLISH, 0, 1, 0, 1, ANSI_CHARSET, 0, 0, 0, 0, 0, 1, 1, 0, 0},
+     0x00000000,
+     {0}},
 };
 
 static const SCRIPT_PROPERTIES *script_props[] =
@@ -379,7 +387,8 @@ static const SCRIPT_PROPERTIES *script_props[] =
     &scriptInformation[36].props, &scriptInformation[37].props,
     &scriptInformation[38].props, &scriptInformation[39].props,
     &scriptInformation[40].props, &scriptInformation[41].props,
-    &scriptInformation[42].props, &scriptInformation[43].props
+    &scriptInformation[42].props, &scriptInformation[43].props,
+    &scriptInformation[44].props
 };
 
 typedef struct {
@@ -870,6 +879,10 @@ HRESULT WINAPI ScriptItemizeOpenType(const WCHAR *pwcInChars, int cInChars, int
            Right-to-Left Mark U+200F) will force us into bidi mode */
         if (!forceLevels && pwcInChars[i] >= 0x200B && pwcInChars[i] <= 0x200F)
             forceLevels = TRUE;
+
+        /* Diacritical marks merge with other scripts */
+        if (scripts[i] == Script_Diacritical && i > 0)
+                scripts[i] = scripts[i-1];
     }
 
     for (i = 0; i < cInChars; i++)
@@ -927,6 +940,14 @@ HRESULT WINAPI ScriptItemizeOpenType(const WCHAR *pwcInChars, int cInChars, int
             }
             BIDI_GetStrengths(pwcInChars, cInChars, psControl, strength);
 
+            /* We currently mis-level leading Diacriticals */
+            if (scripts[0] == Script_Diacritical)
+                for (i = 0; i < cInChars && scripts[0] == Script_Diacritical; i++)
+                {
+                    levels[i] = odd(levels[i])?levels[i]+1:levels[i];
+                    strength[i] = BIDI_STRONG;
+                }
+
             for (i = 0; i < cInChars; i++)
             {
                 /* Script_Numeric and select puncuation at level 0 get bumped to level 2 */
diff --git a/dlls/usp10/usp10_internal.h b/dlls/usp10/usp10_internal.h
index 9f13b40..d6c910f 100644
--- a/dlls/usp10/usp10_internal.h
+++ b/dlls/usp10/usp10_internal.h
@@ -71,6 +71,8 @@
 #define Script_Kannada_Numeric 41
 #define Script_Malayalam 42
 #define Script_Malayalam_Numeric 43
+/* More supplemental */
+#define Script_Diacritical 44
 
 #define GLYPH_BLOCK_SHIFT 8
 #define GLYPH_BLOCK_SIZE  (1UL << GLYPH_BLOCK_SHIFT)




More information about the wine-cvs mailing list