Commit 9a15753d authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

usp10: Introduce a helper function to lookup a language in a LoadedScript structure.

parent 7c26ebfc
...@@ -2610,6 +2610,19 @@ HRESULT OpenType_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, ...@@ -2610,6 +2610,19 @@ HRESULT OpenType_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor,
return rc; return rc;
} }
static LoadedLanguage *usp10_script_get_language(LoadedScript *script, OPENTYPE_TAG tag)
{
size_t i;
for (i = 0; i < script->language_count; ++i)
{
if (script->languages[i].tag == tag)
return &script->languages[i];
}
return NULL;
}
static void GSUB_initialize_language_cache(LoadedScript *script) static void GSUB_initialize_language_cache(LoadedScript *script)
{ {
int i; int i;
...@@ -2646,6 +2659,7 @@ static void GPOS_expand_language_cache(LoadedScript *script) ...@@ -2646,6 +2659,7 @@ static void GPOS_expand_language_cache(LoadedScript *script)
{ {
int count; int count;
const OT_Script* table = script->gpos_table; const OT_Script* table = script->gpos_table;
LoadedLanguage *language;
DWORD offset; DWORD offset;
if (!table) if (!table)
...@@ -2678,27 +2692,21 @@ static void GPOS_expand_language_cache(LoadedScript *script) ...@@ -2678,27 +2692,21 @@ static void GPOS_expand_language_cache(LoadedScript *script)
} }
else if (count) else if (count)
{ {
int i,j; int i;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
int offset = GET_BE_WORD(table->LangSysRecord[i].LangSys); int offset = GET_BE_WORD(table->LangSysRecord[i].LangSys);
OPENTYPE_TAG tag = MS_MAKE_TAG(table->LangSysRecord[i].LangSysTag[0], table->LangSysRecord[i].LangSysTag[1], table->LangSysRecord[i].LangSysTag[2], table->LangSysRecord[i].LangSysTag[3]); OPENTYPE_TAG tag = MS_MAKE_TAG(table->LangSysRecord[i].LangSysTag[0], table->LangSysRecord[i].LangSysTag[1], table->LangSysRecord[i].LangSysTag[2], table->LangSysRecord[i].LangSysTag[3]);
for (j = 0; j < script->language_count; j++) if (!(language = usp10_script_get_language(script, tag)))
{
if (script->languages[j].tag == tag)
{
script->languages[j].gpos_table = ((const BYTE*)table + offset);
break;
}
}
if (j == script->language_count)
{ {
script->language_count++; script->language_count++;
script->languages = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,script->languages, sizeof(LoadedLanguage) * script->language_count); script->languages = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
script->languages[j].tag = tag; script->languages, script->language_count * sizeof(*script->languages));
script->languages[j].gpos_table = ((const BYTE*)table + offset); language = &script->languages[script->language_count - 1];
language->tag = tag;
} }
language->gpos_table = (const BYTE *)table + offset;
} }
} }
} }
...@@ -2919,16 +2927,7 @@ HRESULT OpenType_GetFontFeatureTags(ScriptCache *psc, OPENTYPE_TAG script_tag, O ...@@ -2919,16 +2927,7 @@ HRESULT OpenType_GetFontFeatureTags(ScriptCache *psc, OPENTYPE_TAG script_tag, O
if ((script->default_language.gsub_table || script->default_language.gpos_table) && script->default_language.tag == language_tag) if ((script->default_language.gsub_table || script->default_language.gpos_table) && script->default_language.tag == language_tag)
language = &script->default_language; language = &script->default_language;
else else
{ language = usp10_script_get_language(script, language_tag);
for (i = 0; i < script->language_count; i++)
{
if (script->languages[i].tag == language_tag)
{
language = &script->languages[i];
break;
}
}
}
if (!language) if (!language)
{ {
......
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