usp10: Add Phags-pa Script.

This commit is contained in:
Aric Stewart 2010-08-24 11:55:27 -05:00 committed by Alexandre Julliard
parent 29d896e40a
commit 57053fa51e
3 changed files with 93 additions and 1 deletions

View File

@ -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)

View File

@ -100,6 +100,8 @@ static const scriptRange scriptRanges[] = {
/* Modifier Tone Letters: U+A700U+A71F */
/* Latin Extended-D: U+A720U+A7FF */
{ Script_Latin, 0xa700, 0xa7ff, 0, 0},
/* Phags-pa: U+A840U+A87F */
{ Script_Phags_pa, 0xa840, 0xa87f, 0, 0},
/* Latin Ligatures: U+FB00U+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 {

View File

@ -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)