usp10: Add Tamil script.

This commit is contained in:
Aric Stewart 2011-06-02 14:56:49 -05:00 committed by Alexandre Julliard
parent bafc5f0f30
commit c5747304f0
4 changed files with 121 additions and 1 deletions

View File

@ -49,6 +49,7 @@ static void ContextualShape_Bengali(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *
static void ContextualShape_Gurmukhi(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
static void ContextualShape_Gujarati(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
static void ContextualShape_Oriya(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
static void ContextualShape_Tamil(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
typedef VOID (*ShapeCharGlyphPropProc)( HDC , ScriptCache*, SCRIPT_ANALYSIS*, const WCHAR*, const INT, const WORD*, const INT, WORD*, SCRIPT_CHARPROP*, SCRIPT_GLYPHPROP*);
@ -63,6 +64,7 @@ static void ShapeCharGlyphProp_Bengali( HDC hdc, ScriptCache *psc, SCRIPT_ANALYS
static void ShapeCharGlyphProp_Gurmukhi( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WCHAR* pwcChars, const INT cChars, const WORD* pwGlyphs, const INT cGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProp, SCRIPT_GLYPHPROP *pGlyphProp );
static void ShapeCharGlyphProp_Gujarati( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WCHAR* pwcChars, const INT cChars, const WORD* pwGlyphs, const INT cGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProp, SCRIPT_GLYPHPROP *pGlyphProp );
static void ShapeCharGlyphProp_Oriya( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WCHAR* pwcChars, const INT cChars, const WORD* pwGlyphs, const INT cGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProp, SCRIPT_GLYPHPROP *pGlyphProp );
static void ShapeCharGlyphProp_Tamil( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WCHAR* pwcChars, const INT cChars, const WORD* pwGlyphs, const INT cGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProp, SCRIPT_GLYPHPROP *pGlyphProp );
extern const unsigned short wine_shaping_table[];
extern const unsigned short wine_shaping_forms[LAST_ARABIC_CHAR - FIRST_ARABIC_CHAR + 1][4];
@ -551,6 +553,41 @@ static OPENTYPE_FEATURE_RECORD oriya_features[] =
{ MS_MAKE_TAG('c','a','l','t'), 1},
};
static const char* required_tamil_features[] =
{
"nukt",
"akhn",
"rphf",
"pref",
"half",
"pres",
"abvs",
"blws",
"psts",
"haln",
"calt",
NULL
};
static OPENTYPE_FEATURE_RECORD tamil_features[] =
{
/* Localized forms */
{ MS_MAKE_TAG('l','o','c','l'), 1},
/* Base forms */
{ MS_MAKE_TAG('n','u','k','t'), 1},
{ MS_MAKE_TAG('a','k','h','n'), 1},
{ MS_MAKE_TAG('r','p','h','f'), 1},
{ MS_MAKE_TAG('p','r','e','f'), 1},
{ MS_MAKE_TAG('h','a','l','f'), 1},
/* Presentation forms */
{ MS_MAKE_TAG('p','r','e','s'), 1},
{ MS_MAKE_TAG('a','b','v','s'), 1},
{ MS_MAKE_TAG('b','l','w','s'), 1},
{ MS_MAKE_TAG('p','s','t','s'), 1},
{ MS_MAKE_TAG('h','a','l','n'), 1},
{ MS_MAKE_TAG('c','a','l','t'), 1},
};
typedef struct ScriptShapeDataTag {
TEXTRANGE_PROPERTIES defaultTextRange;
const char** requiredFeatures;
@ -598,6 +635,8 @@ static const ScriptShapeData ShapingData[] =
{{ devanagari_features, 15}, required_devanagari_features, "gujr", "gjr2", ContextualShape_Gujarati, ShapeCharGlyphProp_Gujarati},
{{ oriya_features, 13}, required_oriya_features, "orya", "ory2", ContextualShape_Oriya, ShapeCharGlyphProp_Oriya},
{{ oriya_features, 13}, required_oriya_features, "orya", "ory2", ContextualShape_Oriya, ShapeCharGlyphProp_Oriya},
{{ tamil_features, 12}, required_tamil_features, "taml", "tam2", ContextualShape_Tamil, ShapeCharGlyphProp_Tamil},
{{ tamil_features, 12}, required_tamil_features, "taml", "tam2", ContextualShape_Tamil, ShapeCharGlyphProp_Tamil},
};
static INT GSUB_is_glyph_covered(LPCVOID table , UINT glyph)
@ -2265,6 +2304,62 @@ static void ContextualShape_Oriya(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *ps
HeapFree(GetProcessHeap(),0,input);
}
static int tamil_lex(WCHAR c)
{
switch (c)
{
case 0x0BC0: return lex_Mantra_above;
case 0x0BCD: return lex_Halant;
case 0x0BD7: return lex_Mantra_post;
case 0x200C: return lex_ZWNJ;
case 0x200D: return lex_ZWJ;
default:
if (c>=0x0B95 && c<=0x0BB9) return lex_Consonant;
else if (c>=0x0BBE && c<=0x0BBF) return lex_Mantra_post;
else if (c>=0x0BC1 && c<=0x0BC2) return lex_Mantra_below;
else if (c>=0x0BC6 && c<=0x0BC8) return lex_Mantra_pre;
else return lex_Generic;
}
}
static const VowelComponents Tamil_vowels[] = {
{0x0BCA, {0x0BC6,0x0BBE,0x0000}},
{0x0BCB, {0x0BC7,0x0BBE,0x0000}},
{0x0BCB, {0x0BC6,0x0BD7,0x0000}},
{0x0000, {0x0000,0x0000,0x0000}}};
static const ConsonantComponents Tamil_consonants[] = {
{{0x0B92,0x0BD7,0x0000}, 0x0B94},
{{0x0000,0x0000,0x0000}, 0x0000}};
static void ContextualShape_Tamil(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust)
{
int cCount = cChars;
WCHAR *input;
if (*pcGlyphs != cChars)
{
ERR("Number of Glyphs and Chars need to match at the beginning\n");
return;
}
input = HeapAlloc(GetProcessHeap(), 0, (cChars*2) * sizeof(WCHAR));
memcpy(input, pwcChars, cChars * sizeof(WCHAR));
/* Step 1: Decompose Vowels and Compose Consonents */
DecomposeVowels(hdc, input, &cCount, Tamil_vowels);
ComposeConsonants(hdc, input, &cCount, Tamil_consonants);
TRACE("New composed string %s (%i)\n",debugstr_wn(input,cCount),cCount);
/* Step 2: Reorder within Syllables */
Indic_ReorderCharacters( input, cCount, tamil_lex, Reorder_Like_Sinhala);
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
*pcGlyphs = cCount;
HeapFree(GetProcessHeap(),0,input);
}
static void ShapeCharGlyphProp_Default( HDC hdc, ScriptCache* psc, SCRIPT_ANALYSIS* psa, const WCHAR* pwcChars, const INT cChars, const WORD* pwGlyphs, const INT cGlyphs, WORD* pwLogClust, SCRIPT_CHARPROP* pCharProp, SCRIPT_GLYPHPROP* pGlyphProp)
{
int i,k;
@ -2648,6 +2743,11 @@ static void ShapeCharGlyphProp_Oriya( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS
ShapeCharGlyphProp_BaseIndic(hdc, psc, psa, pwcChars, cChars, pwGlyphs, cGlyphs, pwLogClust, pCharProp, pGlyphProp, oriya_lex);
}
static void ShapeCharGlyphProp_Tamil( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WCHAR* pwcChars, const INT cChars, const WORD* pwGlyphs, const INT cGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProp, SCRIPT_GLYPHPROP *pGlyphProp )
{
ShapeCharGlyphProp_BaseIndic(hdc, psc, psa, pwcChars, cChars, pwGlyphs, cGlyphs, pwLogClust, pCharProp, pGlyphProp, tamil_lex);
}
void SHAPE_CharGlyphProp(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WCHAR* pwcChars, const INT cChars, const WORD* pwGlyphs, const INT cGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProp, SCRIPT_GLYPHPROP *pGlyphProp)
{
if (ShapingData[psa->eScript].charGlyphPropProc)

View File

@ -131,6 +131,7 @@ static inline void _test_items_ok(LPCWSTR string, DWORD cchString,
#define guru_tag MS_MAKE_TAG('g','u','r','u')
#define gujr_tag MS_MAKE_TAG('g','u','j','r')
#define orya_tag MS_MAKE_TAG('o','r','y','a')
#define taml_tag MS_MAKE_TAG('t','a','m','l')
static void test_ScriptItemize( void )
{
@ -237,6 +238,10 @@ static void test_ScriptItemize( void )
static const itemTest t151[2] = {{{0,0,0,0,0},0,0,0,0,orya_tag},{{0,0,0,0,0},5,0,0,0,-1}};
static const itemTest t152[2] = {{{0,0,0,0,0},0,0,0,2,orya_tag},{{0,0,0,0,0},5,0,0,0,-1}};
/* Tamil */
static const WCHAR test16[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
static const itemTest t161[2] = {{{0,0,0,0,0},0,0,0,0,taml_tag},{{0,0,0,0,0},5,0,0,0,-1}};
static const itemTest t162[2] = {{{0,0,0,0,0},0,0,0,2,taml_tag},{{0,0,0,0,0},5,0,0,0,-1}};
SCRIPT_ITEM items[15];
SCRIPT_CONTROL Control;
@ -285,6 +290,7 @@ static void test_ScriptItemize( void )
test_items_ok(test13,7,NULL,NULL,1,t131,FALSE,0);
test_items_ok(test14,7,NULL,NULL,1,t141,FALSE,0);
test_items_ok(test15,5,NULL,NULL,1,t151,FALSE,0);
test_items_ok(test16,5,NULL,NULL,1,t161,FALSE,0);
State.uBidiLevel = 0;
test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
@ -306,6 +312,7 @@ static void test_ScriptItemize( void )
test_items_ok(test13,7,&Control,&State,1,t131,FALSE,0);
test_items_ok(test14,7,&Control,&State,1,t141,FALSE,0);
test_items_ok(test15,5,&Control,&State,1,t151,FALSE,0);
test_items_ok(test16,5,&Control,&State,1,t161,FALSE,0);
State.uBidiLevel = 1;
test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
@ -327,6 +334,7 @@ static void test_ScriptItemize( void )
test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
State.uBidiLevel = 1;
Control.fMergeNeutralItems = TRUE;
@ -349,6 +357,7 @@ static void test_ScriptItemize( void )
test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
}
static inline void _test_shape_ok(int valid, HDC hdc, LPCWSTR string,

View File

@ -87,6 +87,8 @@ static const scriptRange scriptRanges[] = {
{ Script_Gujarati, 0xa80, 0xaff, Script_Gujarati_Numeric, 0},
/* Oriya: U+0B00U+0B7F */
{ Script_Oriya, 0xb00, 0xb7f, Script_Oriya_Numeric, 0},
/* Tamil: U+0B80U+0BFF */
{ Script_Tamil, 0xb80, 0xbff, Script_Tamil_Numeric, 0},
/* Sinhala: U+0D80U+0DFF */
{ Script_Sinhala, 0xd80, 0xdff, 0, 0},
/* Thai: U+0E00U+0E7F */
@ -251,6 +253,12 @@ static const scriptData scriptInformation[] = {
{{Script_Oriya_Numeric, 0, 0, 0, 0, 0, 0, { 0,0,0,0,0,0,0,0,0,0,0}},
{LANG_ORIYA, 1, 1, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, 0, 0, 0, 0, 0},
MS_MAKE_TAG('o','r','y','a')},
{{Script_Tamil, 0, 0, 0, 0, 0, 0, { 0,0,0,0,0,0,0,0,0,0,0}},
{LANG_TAMIL, 0, 1, 0, 1, DEFAULT_CHARSET, 0, 0, 0, 0, 1, 0, 0, 0, 0},
MS_MAKE_TAG('t','a','m','l')},
{{Script_Tamil_Numeric, 0, 0, 0, 0, 0, 0, { 0,0,0,0,0,0,0,0,0,0,0}},
{LANG_TAMIL, 1, 1, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, 0, 0, 0, 0, 0},
MS_MAKE_TAG('t','a','m','l')},
};
static const SCRIPT_PROPERTIES *script_props[] =
@ -272,7 +280,8 @@ static const SCRIPT_PROPERTIES *script_props[] =
&scriptInformation[28].props, &scriptInformation[29].props,
&scriptInformation[30].props, &scriptInformation[31].props,
&scriptInformation[32].props, &scriptInformation[33].props,
&scriptInformation[34].props, &scriptInformation[35].props
&scriptInformation[34].props, &scriptInformation[35].props,
&scriptInformation[36].props, &scriptInformation[37].props
};
typedef struct {

View File

@ -63,6 +63,8 @@
#define Script_Gujarati_Currency 33
#define Script_Oriya 34
#define Script_Oriya_Numeric 35
#define Script_Tamil 36
#define Script_Tamil_Numeric 37
#define GLYPH_BLOCK_SHIFT 8
#define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)