usp10: Ignore ralf as well as pre, post and below base consonants when finding base.
This commit is contained in:
parent
5f22264c1d
commit
80531cac3f
|
@ -212,9 +212,43 @@ static INT Indic_process_next_syllable( LPCWSTR input, INT cChar, INT start, INT
|
|||
return parse_consonant_syllable(input, cChar, start, main, next, lex);
|
||||
}
|
||||
|
||||
static int FindBaseConsonant(LPWSTR input, IndicSyllable *s, lexical_function lex)
|
||||
static BOOL Consonent_is_post_base_form(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPWSTR pwChar, IndicSyllable *s, lexical_function lexical)
|
||||
{
|
||||
if (is_consonant(lexical(pwChar[s->base])) && s->base > s->start && lexical(pwChar[s->base-1]) == lex_Halant)
|
||||
return (SHAPE_does_GSUB_feature_apply_to_chars(hdc, psa, psc, &pwChar[s->base-1], 1, 2, "pstf") > 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL Consonent_is_below_base_form(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPWSTR pwChar, IndicSyllable *s, lexical_function lexical)
|
||||
{
|
||||
if (is_consonant(lexical(pwChar[s->base])) && s->base > s->start && lexical(pwChar[s->base-1]) == lex_Halant)
|
||||
return (SHAPE_does_GSUB_feature_apply_to_chars(hdc, psa, psc, &pwChar[s->base-1], 1, 2, "blwf") > 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL Consonent_is_pre_base_form(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPWSTR pwChar, IndicSyllable *s, lexical_function lexical)
|
||||
{
|
||||
if (is_consonant(lexical(pwChar[s->base])) && s->base > s->start && lexical(pwChar[s->base-1]) == lex_Halant)
|
||||
return (SHAPE_does_GSUB_feature_apply_to_chars(hdc, psa, psc, &pwChar[s->base-1], 1, 2, "pref") > 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL Consonent_is_ralf(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPWSTR pwChar, IndicSyllable *s, lexical_function lexical)
|
||||
{
|
||||
if ((lexical(pwChar[s->start])==lex_Ra) && s->end > s->start && lexical(pwChar[s->start+1]) == lex_Halant)
|
||||
return (SHAPE_does_GSUB_feature_apply_to_chars(hdc, psa, psc, &pwChar[s->start], 1, 2, "rphf") > 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int FindBaseConsonant(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPWSTR input, IndicSyllable *s, lexical_function lex)
|
||||
{
|
||||
int i;
|
||||
int start = s->start;
|
||||
|
||||
/* remove ralf from consideration */
|
||||
if (Consonent_is_ralf(hdc, psa, psc, input, s, lex))
|
||||
s->start+=2;
|
||||
|
||||
/* try to find a base consonant */
|
||||
if (!is_consonant( lex(input[s->base]) ))
|
||||
{
|
||||
|
@ -225,10 +259,23 @@ static int FindBaseConsonant(LPWSTR input, IndicSyllable *s, lexical_function le
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (Consonent_is_below_base_form(hdc, psa, psc, input, s, lex) || Consonent_is_post_base_form(hdc, psa, psc, input, s, lex) || Consonent_is_pre_base_form(hdc, psa, psc, input, s, lex))
|
||||
{
|
||||
for (i = s->base-1; i >= s->start; i--)
|
||||
if (is_consonant( lex(input[i]) ))
|
||||
{
|
||||
s->base = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
s->start = start;
|
||||
|
||||
return s->base;
|
||||
}
|
||||
|
||||
void Indic_ReorderCharacters( LPWSTR input, int cChar, IndicSyllable **syllables, int *syllable_count, lexical_function lex, reorder_function reorder_f)
|
||||
void Indic_ReorderCharacters( HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPWSTR input, int cChar, IndicSyllable **syllables, int *syllable_count, lexical_function lex, reorder_function reorder_f)
|
||||
{
|
||||
int index = 0;
|
||||
int next = 0;
|
||||
|
@ -258,7 +305,7 @@ void Indic_ReorderCharacters( LPWSTR input, int cChar, IndicSyllable **syllables
|
|||
(*syllables)[*syllable_count].start = index;
|
||||
(*syllables)[*syllable_count].base = center;
|
||||
(*syllables)[*syllable_count].end = next-1;
|
||||
FindBaseConsonant(input, &(*syllables)[*syllable_count], lex);
|
||||
FindBaseConsonant(hdc, psa, psc, input, &(*syllables)[*syllable_count], lex);
|
||||
reorder_f(input, &(*syllables)[*syllable_count], lex);
|
||||
index = next;
|
||||
*syllable_count = (*syllable_count)+1;
|
||||
|
|
|
@ -1227,6 +1227,24 @@ static VOID *load_gsub_table(HDC hdc)
|
|||
return GSUB_Table;
|
||||
}
|
||||
|
||||
INT SHAPE_does_GSUB_feature_apply_to_chars(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, const WCHAR *chars, INT write_dir, INT count, const char* feature)
|
||||
{
|
||||
WORD *glyphs;
|
||||
INT glyph_count = count;
|
||||
INT rc;
|
||||
|
||||
glyphs = HeapAlloc(GetProcessHeap(),0,sizeof(WORD)*(count*2));
|
||||
GetGlyphIndicesW(hdc, chars, count, glyphs, 0);
|
||||
rc = apply_GSUB_feature_to_glyph(hdc, psa, psc, glyphs, 0, write_dir, &glyph_count, feature);
|
||||
if (rc > GSUB_E_NOGLYPH)
|
||||
rc = count - glyph_count;
|
||||
else
|
||||
rc = 0;
|
||||
|
||||
HeapFree(GetProcessHeap(),0,glyphs);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static WORD GDEF_get_glyph_class(const GDEF_Header *header, WORD glyph)
|
||||
{
|
||||
int offset;
|
||||
|
@ -2061,7 +2079,7 @@ static void ContextualShape_Sinhala(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *
|
|||
TRACE("New double vowel expanded string %s (%i)\n",debugstr_wn(input,cCount),cCount);
|
||||
|
||||
/* Step 2: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, sinhala_lex, Reorder_Like_Sinhala);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, sinhala_lex, Reorder_Like_Sinhala);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
|
||||
/* Step 3: Strip dangling joiners */
|
||||
|
@ -2147,7 +2165,7 @@ static void ContextualShape_Devanagari(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSI
|
|||
TRACE("New composed string %s (%i)\n",debugstr_wn(input,cCount),cCount);
|
||||
|
||||
/* Step 2: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, devanagari_lex, Reorder_Like_Devanagari);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, devanagari_lex, Reorder_Like_Devanagari);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
|
||||
*pcGlyphs = cCount;
|
||||
|
@ -2221,7 +2239,7 @@ static void ContextualShape_Bengali(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *
|
|||
TRACE("New composed string %s (%i)\n",debugstr_wn(input,cCount),cCount);
|
||||
|
||||
/* Step 2: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, bengali_lex, Reorder_Like_Bengali);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, bengali_lex, Reorder_Like_Bengali);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
|
||||
*pcGlyphs = cCount;
|
||||
|
@ -2302,7 +2320,7 @@ static void ContextualShape_Gurmukhi(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS
|
|||
TRACE("New composed string %s (%i)\n",debugstr_wn(input,cCount),cCount);
|
||||
|
||||
/* Step 2: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, gurmukhi_lex, Reorder_Like_Bengali);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, gurmukhi_lex, Reorder_Like_Bengali);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
|
||||
*pcGlyphs = cCount;
|
||||
|
@ -2354,7 +2372,7 @@ static void ContextualShape_Gujarati(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS
|
|||
memcpy(input, pwcChars, cChars * sizeof(WCHAR));
|
||||
|
||||
/* Step 1: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, gujarati_lex, Reorder_Like_Devanagari);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, gujarati_lex, Reorder_Like_Devanagari);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
|
||||
*pcGlyphs = cCount;
|
||||
|
@ -2432,7 +2450,7 @@ static void ContextualShape_Oriya(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *ps
|
|||
TRACE("New composed string %s (%i)\n",debugstr_wn(input,cCount),cCount);
|
||||
|
||||
/* Step 2: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, oriya_lex, Reorder_Like_Bengali);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, oriya_lex, Reorder_Like_Bengali);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
|
||||
*pcGlyphs = cCount;
|
||||
|
@ -2491,7 +2509,7 @@ static void ContextualShape_Tamil(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *ps
|
|||
TRACE("New composed string %s (%i)\n",debugstr_wn(input,cCount),cCount);
|
||||
|
||||
/* Step 2: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, tamil_lex, Reorder_Like_Sinhala);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, tamil_lex, Reorder_Like_Sinhala);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
|
||||
*pcGlyphs = cCount;
|
||||
|
@ -2549,7 +2567,7 @@ static void ContextualShape_Telugu(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *p
|
|||
TRACE("New composed string %s (%i)\n",debugstr_wn(input,cCount),cCount);
|
||||
|
||||
/* Step 2: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, telugu_lex, Reorder_Like_Bengali);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, telugu_lex, Reorder_Like_Bengali);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
|
||||
*pcGlyphs = cCount;
|
||||
|
@ -2613,7 +2631,7 @@ static void ContextualShape_Kannada(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *
|
|||
TRACE("New composed string %s (%i)\n",debugstr_wn(input,cCount),cCount);
|
||||
|
||||
/* Step 2: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, kannada_lex, Reorder_Like_Kannada);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, kannada_lex, Reorder_Like_Kannada);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
|
||||
*pcGlyphs = cCount;
|
||||
|
@ -2670,7 +2688,7 @@ static void ContextualShape_Malayalam(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS
|
|||
TRACE("New composed string %s (%i)\n",debugstr_wn(input,cCount),cCount);
|
||||
|
||||
/* Step 2: Reorder within Syllables */
|
||||
Indic_ReorderCharacters( input, cCount, &syllables, &syllable_count, malayalam_lex, Reorder_Like_Malayalam);
|
||||
Indic_ReorderCharacters( hdc, psa, psc, input, cCount, &syllables, &syllable_count, malayalam_lex, Reorder_Like_Malayalam);
|
||||
TRACE("reordered string %s\n",debugstr_wn(input,cCount));
|
||||
GetGlyphIndicesW(hdc, input, cCount, pwOutGlyphs, 0);
|
||||
*pcGlyphs = cCount;
|
||||
|
|
|
@ -119,5 +119,6 @@ void SHAPE_ContextualShaping(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WC
|
|||
void SHAPE_ApplyDefaultOpentypeFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, INT cChars, WORD *pwLogClust) DECLSPEC_HIDDEN;
|
||||
HRESULT SHAPE_CheckFontForRequiredFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa) DECLSPEC_HIDDEN;
|
||||
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) DECLSPEC_HIDDEN;
|
||||
INT SHAPE_does_GSUB_feature_apply_to_chars(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, const WCHAR *chars, INT write_dir, INT count, const char* feature) DECLSPEC_HIDDEN;
|
||||
|
||||
void Indic_ReorderCharacters( LPWSTR input, int cChars, IndicSyllable **syllables, int *syllable_count, lexical_function lexical_f, reorder_function reorder_f) DECLSPEC_HIDDEN;
|
||||
void Indic_ReorderCharacters( HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPWSTR input, int cChars, IndicSyllable **syllables, int *syllable_count, lexical_function lexical_f, reorder_function reorder_f) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue