Aric Stewart : usp10: Add Phags-pa Script.

Alexandre Julliard julliard at winehq.org
Wed Aug 25 12:35:04 CDT 2010


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

Author: Aric Stewart <aric at codeweavers.com>
Date:   Tue Aug 24 11:55:27 2010 -0500

usp10: Add Phags-pa Script.

---

 dlls/usp10/shape.c          |   87 +++++++++++++++++++++++++++++++++++++++++++
 dlls/usp10/usp10.c          |    6 ++-
 dlls/usp10/usp10_internal.h |    1 +
 3 files changed, 93 insertions(+), 1 deletions(-)

diff --git a/dlls/usp10/shape.c b/dlls/usp10/shape.c
index cea9415..3f3513d 100644
--- a/dlls/usp10/shape.c
+++ b/dlls/usp10/shape.c
@@ -42,6 +42,7 @@ typedef VOID (*ContextualShapingProc)(HDC, ScriptCache*, SCRIPT_ANALYSIS*,
 
 static void ContextualShape_Arabic(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
 static void ContextualShape_Syriac(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
+static void ContextualShape_Phags_pa(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
 
 extern const unsigned short wine_shaping_table[];
 extern const unsigned short wine_shaping_forms[LAST_ARABIC_CHAR - FIRST_ARABIC_CHAR + 1][4];
@@ -332,6 +333,7 @@ static const ScriptShapeData ShapingData[] =
     {{ sinhala_features, 7}, "sinh", NULL},
     {{ tibetan_features, 2}, "tibt", NULL},
     {{ tibetan_features, 2}, "tibt", NULL},
+    {{ tibetan_features, 2}, "phag", ContextualShape_Phags_pa},
 };
 
 static INT GSUB_is_glyph_covered(LPCVOID table , UINT glyph)
@@ -1173,6 +1175,91 @@ right_join_causing(neighbour_joining_type(i,dirR,context_type,cChars,psa)))
     HeapFree(GetProcessHeap(),0,context_type);
 }
 
+/*
+ * ContextualShape_Phags_pa
+ */
+
+#define phags_pa_CANDRABINDU  0xA873
+#define phags_pa_START 0xA840
+#define phags_pa_END  0xA87F
+
+static void ContextualShape_Phags_pa(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust)
+{
+    INT *context_shape;
+    INT dirR, dirL;
+    int i;
+
+    if (*pcGlyphs != cChars)
+    {
+        ERR("Number of Glyphs and Chars need to match at the beginning\n");
+        return;
+    }
+
+    if (!psa->fLogicalOrder && psa->fRTL)
+    {
+        dirR = 1;
+        dirL = -1;
+    }
+    else
+    {
+        dirR = -1;
+        dirL = 1;
+    }
+
+    if (!psc->GSUB_Table)
+        psc->GSUB_Table = load_gsub_table(hdc);
+
+    if (!psc->GSUB_Table)
+        return;
+
+    context_shape = HeapAlloc(GetProcessHeap(),0,sizeof(INT) * cChars);
+
+    for (i = 0; i < cChars; i++)
+    {
+        if (pwcChars[i] >= phags_pa_START && pwcChars[i] <=  phags_pa_END)
+        {
+            WCHAR rchar = neighbour_char(i,dirR,pwcChars,cChars);
+            WCHAR lchar = neighbour_char(i,dirL,pwcChars,cChars);
+            BOOL jrchar = (rchar != phags_pa_CANDRABINDU && rchar >= phags_pa_START && rchar <=  phags_pa_END);
+            BOOL jlchar = (lchar != phags_pa_CANDRABINDU && lchar >= phags_pa_START && lchar <=  phags_pa_END);
+
+            if (jrchar && jlchar)
+                context_shape[i] = Xm;
+            else if (jrchar)
+                context_shape[i] = Xr;
+            else if (jlchar)
+                context_shape[i] = Xl;
+            else
+                context_shape[i] = Xn;
+        }
+        else
+            context_shape[i] = -1;
+    }
+
+    /* Contextual Shaping */
+    i = 0;
+    while(i < *pcGlyphs)
+    {
+        if (context_shape[i] >= 0)
+        {
+            INT nextIndex;
+            INT prevCount = *pcGlyphs;
+            nextIndex = apply_GSUB_feature_to_glyph(hdc, psa, psc, pwOutGlyphs, i, dirL, pcGlyphs, contextual_features[context_shape[i]]);
+            if (nextIndex > GSUB_E_NOGLYPH)
+            {
+                UpdateClusters(nextIndex, *pcGlyphs - prevCount, dirL, cChars, pwLogClust);
+                i = nextIndex;
+            }
+            else
+                i++;
+        }
+        else
+            i++;
+    }
+
+    HeapFree(GetProcessHeap(),0,context_shape);
+}
+
 void SHAPE_ContextualShaping(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust)
 {
     if (ShapingData[psa->eScript].contextProc)
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 23695cd..c18c532 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -100,6 +100,8 @@ static const scriptRange scriptRanges[] = {
     /* Modifier Tone Letters: U+A700–U+A71F */
     /* Latin Extended-D: U+A720–U+A7FF */
     { Script_Latin,      0xa700, 0xa7ff, 0, 0},
+    /* Phags-pa: U+A840–U+A87F */
+    { Script_Phags_pa,   0xa840, 0xa87f, 0, 0},
     /* Latin Ligatures: U+FB00–U+FB06 */
     { Script_Latin,      0xfb00, 0xfb06, 0, 0},
     /* Armenian ligatures U+FB13..U+FB17 */
@@ -160,6 +162,8 @@ static const scriptData scriptInformation[] = {
      {LANG_TIBETAN, 0, 1, 1, 1, DEFAULT_CHARSET, 0, 0, 1, 0, 1, 0, 0, 0, 0}},
     {{Script_Tibetan_Numeric, 0, 0, 0, 0, 0, 0, { 0,0,0,0,0,0,0,0,0,0,0}},
      {LANG_TIBETAN, 1, 1, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
+    {{Script_Phags_pa, 0, 0, 0, 0, 0, 0, { 0,0,0,0,0,0,0,0,0,0,0}},
+     {LANG_MONGOLIAN, 0, 1, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
 };
 
 static const SCRIPT_PROPERTIES *script_props[] =
@@ -173,7 +177,7 @@ static const SCRIPT_PROPERTIES *script_props[] =
     &scriptInformation[12].props, &scriptInformation[13].props,
     &scriptInformation[14].props, &scriptInformation[15].props,
     &scriptInformation[16].props, &scriptInformation[17].props,
-    &scriptInformation[18].props
+    &scriptInformation[18].props, &scriptInformation[19].props
 };
 
 typedef struct {
diff --git a/dlls/usp10/usp10_internal.h b/dlls/usp10/usp10_internal.h
index bc3fd57..bfde66d 100644
--- a/dlls/usp10/usp10_internal.h
+++ b/dlls/usp10/usp10_internal.h
@@ -38,6 +38,7 @@
 #define Script_Sinhala 16
 #define Script_Tibetan 17
 #define Script_Tibetan_Numeric 18
+#define Script_Phags_pa 19
 
 #define GLYPH_BLOCK_SHIFT 8
 #define GLYPH_BLOCK_SIZE  (1UL << GLYPH_BLOCK_SHIFT)




More information about the wine-cvs mailing list