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

usp10: Replace GSUB_get_feature with GSUB_GetFontFeatureTags.

parent 3d98085d
...@@ -349,6 +349,7 @@ typedef struct { ...@@ -349,6 +349,7 @@ typedef struct {
static INT GSUB_apply_lookup(const GSUB_LookupList* lookup, INT lookup_index, WORD *glyphs, INT glyph_index, INT write_dir, INT *glyph_count); static INT GSUB_apply_lookup(const GSUB_LookupList* lookup, INT lookup_index, WORD *glyphs, INT glyph_index, INT write_dir, INT *glyph_count);
static HRESULT GSUB_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags, LPCVOID* script_table); static HRESULT GSUB_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags, LPCVOID* script_table);
static HRESULT GSUB_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pLanguageTags, int *pcTags, LPCVOID* language_table); static HRESULT GSUB_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pLanguageTags, int *pcTags, LPCVOID* language_table);
static HRESULT 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);
typedef struct tagVowelComponents typedef struct tagVowelComponents
{ {
...@@ -767,26 +768,6 @@ static INT GSUB_is_glyph_covered(LPCVOID table , UINT glyph) ...@@ -767,26 +768,6 @@ static INT GSUB_is_glyph_covered(LPCVOID table , UINT glyph)
return -1; return -1;
} }
static const GSUB_Feature * GSUB_get_feature(const GSUB_Header *header, const GSUB_LangSys *lang, const char* tag)
{
int i;
const GSUB_FeatureList *feature;
feature = (const GSUB_FeatureList*)((const BYTE*)header + GET_BE_WORD(header->FeatureList));
TRACE("%i features\n",GET_BE_WORD(lang->FeatureCount));
for (i = 0; i < GET_BE_WORD(lang->FeatureCount); i++)
{
int index = GET_BE_WORD(lang->FeatureIndex[i]);
if (strncmp(feature->FeatureRecord[index].FeatureTag,tag,4)==0)
{
const GSUB_Feature *feat;
feat = (const GSUB_Feature*)((const BYTE*)feature + GET_BE_WORD(feature->FeatureRecord[index].Feature));
return feat;
}
}
return NULL;
}
static INT GSUB_apply_SingleSubst(const GSUB_LookupTable *look, WORD *glyphs, INT glyph_index, INT write_dir, INT *glyph_count) static INT GSUB_apply_SingleSubst(const GSUB_LookupTable *look, WORD *glyphs, INT glyph_index, INT write_dir, INT *glyph_count)
{ {
int j; int j;
...@@ -1180,61 +1161,44 @@ static OPENTYPE_TAG get_opentype_script(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCac ...@@ -1180,61 +1161,44 @@ static OPENTYPE_TAG get_opentype_script(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCac
static LPCVOID load_GSUB_feature(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache *psc, const char* feat) static LPCVOID load_GSUB_feature(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache *psc, const char* feat)
{ {
const GSUB_Feature *feature; LoadedFeature *feature = NULL;
OPENTYPE_TAG script;
int i;
script = get_opentype_script(hdc,psa,psc,FALSE);
for (i = 0; i < psc->feature_count; i++)
{
if (psc->features[i].tag == MS_MAKE_TAG(feat[0],feat[1],feat[2],feat[3])&& psc->features[i].script == script)
return psc->features[i].feature;
}
feature = NULL;
if (psc->GSUB_Table) if (psc->GSUB_Table)
{ {
const GSUB_LangSys *language = NULL;
int attempt = 2; int attempt = 2;
OPENTYPE_TAG scriptTags; OPENTYPE_TAG tags;
OPENTYPE_TAG language;
OPENTYPE_TAG script;
int cTags; int cTags;
do do
{ {
script = get_opentype_script(hdc,psa,psc,(attempt==2));
if (psc->userLang != 0) if (psc->userLang != 0)
GSUB_GetFontLanguageTags(psc, get_opentype_script(hdc,psa,psc,(attempt==2)), psc->userLang, 1, &scriptTags, &cTags, (LPCVOID*)&language); language = psc->userLang;
else else
GSUB_GetFontLanguageTags(psc, get_opentype_script(hdc,psa,psc,(attempt==2)), MS_MAKE_TAG('x','x','x','x'), 1, &scriptTags, &cTags, (LPCVOID*)&language); /* Need to get Lang tag */ language = MS_MAKE_TAG('d','f','l','t');
attempt--; attempt--;
if (language)
feature = GSUB_get_feature(psc->GSUB_Table, language, feat); GSUB_GetFontFeatureTags(psc, script, language, FALSE, MS_MAKE_TAG(feat[0],feat[1],feat[2],feat[3]), 1, &tags, &cTags, &feature);
} while(attempt && !feature); } while(attempt && !feature);
/* try in the default (latin) table */ /* try in the default (latin) table */
if (!feature) if (!feature)
{ GSUB_GetFontFeatureTags(psc, MS_MAKE_TAG('l','a','t','n'), MS_MAKE_TAG('d','f','l','t'), FALSE, MS_MAKE_TAG(feat[0],feat[1],feat[2],feat[3]), 1, &tags, &cTags, &feature);
GSUB_GetFontLanguageTags(psc, MS_MAKE_TAG('l','a','t','n'), MS_MAKE_TAG('x','x','x','x'), 1, &scriptTags, &cTags, (LPCVOID*)&language); /* Need to get Lang tag */
if (language)
feature = GSUB_get_feature(psc->GSUB_Table, language, feat);
}
} }
TRACE("Feature %s located at %p\n",debugstr_an(feat,4),feature); if (feature)
{
psc->feature_count++; TRACE("Feature %s located at %p\n",debugstr_an(feat,4),feature->feature);
return feature->feature;
if (psc->features) }
psc->features = HeapReAlloc(GetProcessHeap(), 0, psc->features, psc->feature_count * sizeof(LoadedFeature));
else else
psc->features = HeapAlloc(GetProcessHeap(), 0, psc->feature_count * sizeof(LoadedFeature)); {
TRACE("Feature %s not located\n",debugstr_an(feat,4));
psc->features[psc->feature_count - 1].tag = MS_MAKE_TAG(feat[0],feat[1],feat[2],feat[3]); return NULL;
psc->features[psc->feature_count - 1].script = script; }
psc->features[psc->feature_count - 1].feature = feature;
return feature;
} }
static INT apply_GSUB_feature_to_glyph(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, WORD *glyphs, INT index, INT write_dir, INT* glyph_count, const char* feat) static INT apply_GSUB_feature_to_glyph(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, WORD *glyphs, INT index, INT write_dir, INT* glyph_count, const char* feat)
......
...@@ -933,7 +933,6 @@ HRESULT WINAPI ScriptFreeCache(SCRIPT_CACHE *psc) ...@@ -933,7 +933,6 @@ HRESULT WINAPI ScriptFreeCache(SCRIPT_CACHE *psc)
heap_free(((ScriptCache *)*psc)->scripts[i].languages); heap_free(((ScriptCache *)*psc)->scripts[i].languages);
} }
heap_free(((ScriptCache *)*psc)->scripts); heap_free(((ScriptCache *)*psc)->scripts);
heap_free(((ScriptCache *)*psc)->features);
heap_free(*psc); heap_free(*psc);
*psc = NULL; *psc = NULL;
} }
......
...@@ -127,7 +127,6 @@ ...@@ -127,7 +127,6 @@
typedef struct { typedef struct {
OPENTYPE_TAG tag; OPENTYPE_TAG tag;
OPENTYPE_TAG script;
LPCVOID feature; LPCVOID feature;
} LoadedFeature; } LoadedFeature;
...@@ -156,8 +155,6 @@ typedef struct { ...@@ -156,8 +155,6 @@ typedef struct {
LPVOID GDEF_Table; LPVOID GDEF_Table;
LPVOID CMAP_Table; LPVOID CMAP_Table;
LPVOID CMAP_format12_Table; LPVOID CMAP_format12_Table;
INT feature_count;
LoadedFeature *features;
INT script_count; INT script_count;
LoadedScript *scripts; LoadedScript *scripts;
......
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