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

usp10: Change OpenType_GSUB_GetFontScriptTags to OpenType_GetFontScriptTags and…

usp10: Change OpenType_GSUB_GetFontScriptTags to OpenType_GetFontScriptTags and load scripts from GPOS table as well.
parent 9d408bbb
...@@ -277,6 +277,15 @@ typedef struct{ ...@@ -277,6 +277,15 @@ typedef struct{
WORD Alternate[1]; WORD Alternate[1];
} GSUB_AlternateSet; } GSUB_AlternateSet;
/* These are all structures needed for the GPOS table */
typedef struct {
DWORD version;
WORD ScriptList;
WORD FeatureList;
WORD LookupList;
} GPOS_Header;
/********** /**********
* CMAP * CMAP
**********/ **********/
...@@ -864,7 +873,7 @@ static void GSUB_initialize_script_cache(ScriptCache *psc) ...@@ -864,7 +873,7 @@ static void GSUB_initialize_script_cache(ScriptCache *psc)
{ {
int i; int i;
if (!psc->script_count) if (psc->GSUB_Table)
{ {
const OT_ScriptList *script; const OT_ScriptList *script;
const GSUB_Header* header = (const GSUB_Header*)psc->GSUB_Table; const GSUB_Header* header = (const GSUB_Header*)psc->GSUB_Table;
...@@ -878,18 +887,81 @@ static void GSUB_initialize_script_cache(ScriptCache *psc) ...@@ -878,18 +887,81 @@ static void GSUB_initialize_script_cache(ScriptCache *psc)
{ {
int offset = GET_BE_WORD(script->ScriptRecord[i].Script); int offset = GET_BE_WORD(script->ScriptRecord[i].Script);
psc->scripts[i].tag = MS_MAKE_TAG(script->ScriptRecord[i].ScriptTag[0], script->ScriptRecord[i].ScriptTag[1], script->ScriptRecord[i].ScriptTag[2], script->ScriptRecord[i].ScriptTag[3]); psc->scripts[i].tag = MS_MAKE_TAG(script->ScriptRecord[i].ScriptTag[0], script->ScriptRecord[i].ScriptTag[1], script->ScriptRecord[i].ScriptTag[2], script->ScriptRecord[i].ScriptTag[3]);
psc->scripts[i].table = ((const BYTE*)script + offset); psc->scripts[i].gsub_table = ((const BYTE*)script + offset);
}
}
}
}
static void GPOS_expand_script_cache(ScriptCache *psc)
{
int i, count;
const OT_ScriptList *script;
const GPOS_Header* header = (const GPOS_Header*)psc->GPOS_Table;
if (!header)
return;
script = (const OT_ScriptList*)((const BYTE*)header + GET_BE_WORD(header->ScriptList));
count = GET_BE_WORD(script->ScriptCount);
if (!psc->script_count)
{
psc->script_count = count;
TRACE("initializing %i scripts in this font\n",psc->script_count);
if (psc->script_count)
{
psc->scripts = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(LoadedScript) * psc->script_count);
for (i = 0; i < psc->script_count; i++)
{
int offset = GET_BE_WORD(script->ScriptRecord[i].Script);
psc->scripts[i].tag = MS_MAKE_TAG(script->ScriptRecord[i].ScriptTag[0], script->ScriptRecord[i].ScriptTag[1], script->ScriptRecord[i].ScriptTag[2], script->ScriptRecord[i].ScriptTag[3]);
psc->scripts[i].gpos_table = ((const BYTE*)script + offset);
}
}
}
else
{
for (i = 0; i < count; i++)
{
int j;
int offset = GET_BE_WORD(script->ScriptRecord[i].Script);
OPENTYPE_TAG tag = MS_MAKE_TAG(script->ScriptRecord[i].ScriptTag[0], script->ScriptRecord[i].ScriptTag[1], script->ScriptRecord[i].ScriptTag[2], script->ScriptRecord[i].ScriptTag[3]);
for (j = 0; j < psc->script_count; j++)
{
if (psc->scripts[j].tag == tag)
{
psc->scripts[j].gpos_table = ((const BYTE*)script + offset);
break;
} }
} }
if (j == psc->script_count)
{
psc->script_count++;
psc->scripts = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,psc->scripts, sizeof(LoadedScript) * psc->script_count);
psc->scripts[j].tag = tag;
psc->scripts[j].gpos_table = ((const BYTE*)script + offset);
}
}
}
}
static void _initialize_script_cache(ScriptCache *psc)
{
if (!psc->script_count)
{
GSUB_initialize_script_cache(psc);
GPOS_expand_script_cache(psc);
} }
} }
HRESULT OpenType_GSUB_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags, LPCVOID* script_table) HRESULT OpenType_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags)
{ {
int i; int i;
HRESULT rc = S_OK; HRESULT rc = S_OK;
GSUB_initialize_script_cache(psc); _initialize_script_cache(psc);
*pcTags = psc->script_count; *pcTags = psc->script_count;
if (!searchingFor && cMaxTags < *pcTags) if (!searchingFor && cMaxTags < *pcTags)
...@@ -908,8 +980,6 @@ HRESULT OpenType_GSUB_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searching ...@@ -908,8 +980,6 @@ HRESULT OpenType_GSUB_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searching
{ {
pScriptTags[0] = psc->scripts[i].tag; pScriptTags[0] = psc->scripts[i].tag;
*pcTags = 1; *pcTags = 1;
if (script_table)
*script_table = psc->scripts[i].table;
rc = S_OK; rc = S_OK;
break; break;
} }
...@@ -922,10 +992,10 @@ static void GSUB_initialize_language_cache(LoadedScript *script) ...@@ -922,10 +992,10 @@ static void GSUB_initialize_language_cache(LoadedScript *script)
{ {
int i; int i;
if (!script->language_count) if (!script->language_count && script->gsub_table)
{ {
DWORD offset; DWORD offset;
const OT_Script* table = script->table; const OT_Script* table = script->gsub_table;
script->language_count = GET_BE_WORD(table->LangSysCount); script->language_count = GET_BE_WORD(table->LangSysCount);
offset = GET_BE_WORD(table->DefaultLangSys); offset = GET_BE_WORD(table->DefaultLangSys);
if (offset) if (offset)
...@@ -956,7 +1026,7 @@ HRESULT OpenType_GSUB_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_ ...@@ -956,7 +1026,7 @@ HRESULT OpenType_GSUB_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_
HRESULT rc = S_OK; HRESULT rc = S_OK;
LoadedScript *script = NULL; LoadedScript *script = NULL;
GSUB_initialize_script_cache(psc); _initialize_script_cache(psc);
for (i = 0; i < psc->script_count; i++) for (i = 0; i < psc->script_count; i++)
{ {
...@@ -1061,7 +1131,7 @@ HRESULT OpenType_GSUB_GetFontFeatureTags(ScriptCache *psc, OPENTYPE_TAG script_t ...@@ -1061,7 +1131,7 @@ HRESULT OpenType_GSUB_GetFontFeatureTags(ScriptCache *psc, OPENTYPE_TAG script_t
LoadedScript *script = NULL; LoadedScript *script = NULL;
LoadedLanguage *language = NULL; LoadedLanguage *language = NULL;
GSUB_initialize_script_cache(psc); _initialize_script_cache(psc);
for (i = 0; i < psc->script_count; i++) for (i = 0; i < psc->script_count; i++)
{ {
......
...@@ -807,7 +807,7 @@ static inline BOOL get_GSUB_Indic2(SCRIPT_ANALYSIS *psa, ScriptCache *psc) ...@@ -807,7 +807,7 @@ static inline BOOL get_GSUB_Indic2(SCRIPT_ANALYSIS *psa, ScriptCache *psc)
HRESULT hr; HRESULT hr;
int count = 0; int count = 0;
hr = OpenType_GSUB_GetFontScriptTags(psc, ShapingData[psa->eScript].newOtTag, 1, &tag, &count, NULL); hr = OpenType_GetFontScriptTags(psc, ShapingData[psa->eScript].newOtTag, 1, &tag, &count);
return(SUCCEEDED(hr)); return(SUCCEEDED(hr));
} }
...@@ -3244,7 +3244,7 @@ HRESULT SHAPE_GetFontScriptTags( HDC hdc, ScriptCache *psc, ...@@ -3244,7 +3244,7 @@ HRESULT SHAPE_GetFontScriptTags( HDC hdc, ScriptCache *psc,
if (psa && scriptInformation[psa->eScript].scriptTag) if (psa && scriptInformation[psa->eScript].scriptTag)
searching = scriptInformation[psa->eScript].scriptTag; searching = scriptInformation[psa->eScript].scriptTag;
hr = OpenType_GSUB_GetFontScriptTags(psc, searching, cMaxTags, pScriptTags, pcTags, NULL); hr = OpenType_GetFontScriptTags(psc, searching, cMaxTags, pScriptTags, pcTags);
if (FAILED(hr)) if (FAILED(hr))
*pcTags = 0; *pcTags = 0;
return hr; return hr;
......
...@@ -144,7 +144,8 @@ typedef struct { ...@@ -144,7 +144,8 @@ typedef struct {
typedef struct { typedef struct {
OPENTYPE_TAG tag; OPENTYPE_TAG tag;
LPCVOID table; LPCVOID gsub_table;
LPCVOID gpos_table;
LoadedLanguage default_language; LoadedLanguage default_language;
INT language_count; INT language_count;
LoadedLanguage *languages; LoadedLanguage *languages;
...@@ -234,6 +235,6 @@ void BREAK_line(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT ...@@ -234,6 +235,6 @@ void BREAK_line(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT
DWORD OpenType_CMAP_GetGlyphIndex(HDC hdc, ScriptCache *psc, DWORD utf32c, LPWORD pgi, DWORD flags) DECLSPEC_HIDDEN; DWORD OpenType_CMAP_GetGlyphIndex(HDC hdc, ScriptCache *psc, DWORD utf32c, LPWORD pgi, DWORD flags) DECLSPEC_HIDDEN;
void OpenType_GDEF_UpdateGlyphProps(HDC hdc, ScriptCache *psc, const WORD *pwGlyphs, const WORD cGlyphs, WORD* pwLogClust, const WORD cChars, SCRIPT_GLYPHPROP *pGlyphProp) DECLSPEC_HIDDEN; void OpenType_GDEF_UpdateGlyphProps(HDC hdc, ScriptCache *psc, const WORD *pwGlyphs, const WORD cGlyphs, WORD* pwLogClust, const WORD cChars, SCRIPT_GLYPHPROP *pGlyphProp) DECLSPEC_HIDDEN;
INT OpenType_apply_GSUB_lookup(LPCVOID table, INT lookup_index, WORD *glyphs, INT glyph_index, INT write_dir, INT *glyph_count) DECLSPEC_HIDDEN; INT OpenType_apply_GSUB_lookup(LPCVOID table, INT lookup_index, WORD *glyphs, INT glyph_index, INT write_dir, INT *glyph_count) DECLSPEC_HIDDEN;
HRESULT OpenType_GSUB_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags, LPCVOID* script_table) DECLSPEC_HIDDEN; HRESULT OpenType_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags) DECLSPEC_HIDDEN;
HRESULT OpenType_GSUB_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pLanguageTags, int *pcTags, LPCVOID* language_table) DECLSPEC_HIDDEN; HRESULT OpenType_GSUB_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pLanguageTags, int *pcTags, LPCVOID* language_table) DECLSPEC_HIDDEN;
HRESULT OpenType_GSUB_GetFontFeatureTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG language_tag, BOOL filtered, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pFeatureTags, int *pcTags, LoadedFeature** feature) DECLSPEC_HIDDEN; HRESULT OpenType_GSUB_GetFontFeatureTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG language_tag, BOOL filtered, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pFeatureTags, int *pcTags, LoadedFeature** feature) DECLSPEC_HIDDEN;
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