Commit f68c03c4 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

usp10: Add Khmer script.

parent 05cd57b4
......@@ -53,6 +53,7 @@ static void ContextualShape_Tamil(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *ps
static void ContextualShape_Telugu(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
static void ContextualShape_Kannada(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
static void ContextualShape_Malayalam(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust);
static void ContextualShape_Khmer(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*);
......@@ -71,6 +72,7 @@ static void ShapeCharGlyphProp_Tamil( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS
static void ShapeCharGlyphProp_Telugu( 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_Kannada( 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_Malayalam( 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_Khmer( 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 indic_syllabic_table[];
extern const unsigned short wine_shaping_table[];
......@@ -545,6 +547,29 @@ static const char* required_telugu_features[] =
NULL
};
static OPENTYPE_FEATURE_RECORD khmer_features[] =
{
{ MS_MAKE_TAG('p','r','e','s'), 1},
{ MS_MAKE_TAG('b','l','w','s'), 1},
{ MS_MAKE_TAG('a','b','v','s'), 1},
{ MS_MAKE_TAG('p','s','t','s'), 1},
{ MS_MAKE_TAG('c','l','i','g'), 1},
};
static const char* required_khmer_features[] =
{
"pref",
"blwf",
"abvf",
"pstf",
"pres",
"blws",
"abvs",
"psts",
"clig",
NULL
};
typedef struct ScriptShapeDataTag {
TEXTRANGE_PROPERTIES defaultTextRange;
const char** requiredFeatures;
......@@ -609,6 +634,8 @@ static const ScriptShapeData ShapingData[] =
{{ standard_features, 2}, NULL, "tale", "", NULL, NULL},
{{ standard_features, 2}, NULL, "talu", "", NULL, NULL},
{{ standard_features, 2}, NULL, "talu", "", NULL, NULL},
{{ khmer_features, 5}, required_khmer_features, "khmr", "", ContextualShape_Khmer, ShapeCharGlyphProp_Khmer},
{{ khmer_features, 5}, required_khmer_features, "khmr", "", ContextualShape_Khmer, ShapeCharGlyphProp_Khmer},
};
static INT GSUB_is_glyph_covered(LPCVOID table , UINT glyph)
......@@ -2968,6 +2995,40 @@ static void ContextualShape_Malayalam(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS
HeapFree(GetProcessHeap(),0,syllables);
}
static int khmer_lex(WCHAR c)
{
return unicode_lex(c);
}
static void ContextualShape_Khmer(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust)
{
int cCount = cChars;
WCHAR *input;
IndicSyllable *syllables = NULL;
int syllable_count = 0;
if (*pcGlyphs != cChars)
{
ERR("Number of Glyphs and Chars need to match at the beginning\n");
return;
}
input = HeapAlloc(GetProcessHeap(), 0, cChars * sizeof(WCHAR));
memcpy(input, pwcChars, cChars * sizeof(WCHAR));
/* Step 1: Reorder within Syllables */
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, khmer_lex, Reorder_Like_Devanagari, FALSE);
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
*pcGlyphs = cCount;
/* Step 2: Base Form application to syllables */
ShapeIndicSyllables(hdc, psc, psa, input, cChars, syllables, syllable_count, pwOutGlyphs, pcGlyphs, pwLogClust, khmer_lex, NULL, FALSE);
HeapFree(GetProcessHeap(),0,input);
HeapFree(GetProcessHeap(),0,syllables);
}
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;
......@@ -3406,6 +3467,11 @@ static void ShapeCharGlyphProp_Malayalam( HDC hdc, ScriptCache *psc, SCRIPT_ANAL
ShapeCharGlyphProp_BaseIndic(hdc, psc, psa, pwcChars, cChars, pwGlyphs, cGlyphs, pwLogClust, pCharProp, pGlyphProp, malayalam_lex, TRUE, TRUE);
}
static void ShapeCharGlyphProp_Khmer( 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, khmer_lex, TRUE, TRUE);
}
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)
......
......@@ -152,6 +152,7 @@ static inline void _test_items_ok(LPCWSTR string, DWORD cchString,
#define mymr_tag MS_MAKE_TAG('m','y','m','r')
#define tale_tag MS_MAKE_TAG('t','a','l','e')
#define talu_tag MS_MAKE_TAG('t','a','l','u')
#define khmr_tag MS_MAKE_TAG('k','h','m','r')
static void test_ScriptItemize( void )
{
......@@ -316,6 +317,10 @@ static void test_ScriptItemize( void )
static const itemTest t261[2] = {{{0,0,0,0,0},0,0,0,0,talu_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
static const itemTest t262[2] = {{{0,0,0,0,0},0,0,0,2,talu_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
/* Khmer */
static const WCHAR test27[] = {0x1781,0x17c1,0x1798,0x179a,0x1797,0x17b6,0x179f,0x17b6};
static const itemTest t271[2] = {{{0,0,0,0,0},0,0,0,0,khmr_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
static const itemTest t272[2] = {{{0,0,0,0,0},0,0,0,2,khmr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
SCRIPT_ITEM items[15];
......@@ -377,6 +382,7 @@ static void test_ScriptItemize( void )
test_items_ok(test24,12,NULL,NULL,1,t241,FALSE,0);
test_items_ok(test25,10,NULL,NULL,1,t251,FALSE,0);
test_items_ok(test26,2,NULL,NULL,1,t261,FALSE,0);
test_items_ok(test27,8,NULL,NULL,1,t271,FALSE,0);
State.uBidiLevel = 0;
test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
......@@ -410,6 +416,7 @@ static void test_ScriptItemize( void )
test_items_ok(test24,12,&Control,&State,1,t241,FALSE,0);
test_items_ok(test25,10,&Control,&State,1,t251,FALSE,0);
test_items_ok(test26,2,&Control,&State,1,t261,FALSE,0);
test_items_ok(test27,8,&Control,&State,1,t271,FALSE,0);
State.uBidiLevel = 1;
test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
......@@ -443,6 +450,7 @@ static void test_ScriptItemize( void )
test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
State.uBidiLevel = 1;
Control.fMergeNeutralItems = TRUE;
......@@ -477,6 +485,7 @@ static void test_ScriptItemize( void )
test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
}
static inline void _test_shape_ok(int valid, HDC hdc, LPCWSTR string,
......
......@@ -111,10 +111,14 @@ static const scriptRange scriptRanges[] = {
{ Script_Myanmar, 0x1000, 0x109f, Script_Myanmar_Numeric, 0},
/* Georgian: U+10A0–U+10FF */
{ Script_Georgian, 0x10a0, 0x10ff, 0, 0},
/* Khmer: U+1780–U+17FF */
{ Script_Khmer, 0x1780, 0x17ff, Script_Khmer_Numeric, 0},
/* Tai Le: U+1950–U+197F */
{ Script_Tai_Le, 0x1950, 0x197f, 0, 0},
/* New Tai Lue: U+1980–U+19DF */
{ Script_New_Tai_Lue,0x1980, 0x19df, Script_New_Tai_Lue_Numeric, 0},
/* Khmer Symbols: U+19E0–U+19FF */
{ Script_Khmer, 0x19e0, 0x19ff, Script_Khmer_Numeric, 0},
/* Vedic Extensions: U+1CD0-U+1CFF */
{ Script_Devanagari, 0x1cd0, 0x1cff, Script_Devanagari_Numeric, 0},
/* Phonetic Extensions: U+1D00–U+1DBF */
......@@ -405,6 +409,14 @@ static const scriptData scriptInformation[] = {
{0, 0, 1, 0, 1, DEFAULT_CHARSET, 0, 0, 0, 0, 0, 0, 0, 0, 0},
MS_MAKE_TAG('t','a','l','u'),
{'M','i','c','r','o','s','o','f','t',' ','N','e','w',' ','T','a','i',' ','L','u','e'}},
{{Script_Khmer, 0, 0, 0, 0, 0, 0, { 0,0,0,0,0,0,0,0,0,0,0}},
{0x53, 0, 1, 1, 1, DEFAULT_CHARSET, 0, 0, 0, 0, 1, 0, 0, 0, 0},
MS_MAKE_TAG('k','h','m','r'),
{'D','a','u','n','P','e','n','h'}},
{{Script_Khmer, 0, 0, 0, 0, 0, 0, { 0,0,0,0,0,0,0,0,0,0,0}},
{0x53, 1, 1, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, 0, 0, 0, 0, 0},
MS_MAKE_TAG('k','h','m','r'),
{'D','a','u','n','P','e','n','h'}},
};
static const SCRIPT_PROPERTIES *script_props[] =
......@@ -434,7 +446,8 @@ static const SCRIPT_PROPERTIES *script_props[] =
&scriptInformation[44].props, &scriptInformation[45].props,
&scriptInformation[46].props, &scriptInformation[47].props,
&scriptInformation[48].props, &scriptInformation[49].props,
&scriptInformation[50].props, &scriptInformation[51].props
&scriptInformation[50].props, &scriptInformation[51].props,
&scriptInformation[52].props, &scriptInformation[53].props
};
typedef struct {
......
......@@ -81,6 +81,8 @@
#define Script_Tai_Le 49
#define Script_New_Tai_Lue 50
#define Script_New_Tai_Lue_Numeric 51
#define Script_Khmer 52
#define Script_Khmer_Numeric 53
#define GLYPH_BLOCK_SHIFT 8
#define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment