Commit 1090cd2f authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

usp10: Cache FontScriptTags information.

parent 1fc01563
......@@ -3779,39 +3779,53 @@ DWORD CMAP_GetGlyphIndex(HDC hdc, ScriptCache *psc, DWORD utf32c, LPWORD pgi, DW
return 0;
}
static HRESULT GSUB_GetFontScriptTags(LPCVOID table, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags, LPCVOID* script_table)
static void GSUB_initialize_script_cache(ScriptCache *psc)
{
const GSUB_ScriptList *script;
const GSUB_Header* header = (const GSUB_Header*)table;
int i;
HRESULT rc = S_OK;
script = (const GSUB_ScriptList*)((const BYTE*)header + GET_BE_WORD(header->ScriptList));
if (!psc->script_count)
{
const GSUB_ScriptList *script;
const GSUB_Header* header = (const GSUB_Header*)psc->GSUB_Table;
script = (const GSUB_ScriptList*)((const BYTE*)header + GET_BE_WORD(header->ScriptList));
psc->script_count = GET_BE_WORD(script->ScriptCount);
TRACE("initializing %i scripts in this font\n",psc->script_count);
psc->scripts = HeapAlloc(GetProcessHeap(),0,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].table = ((const BYTE*)script + offset);
}
}
}
*pcTags = GET_BE_WORD(script->ScriptCount);
TRACE("%i scripts in this font\n",*pcTags);
static HRESULT GSUB_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags, LPCVOID* script_table)
{
int i;
HRESULT rc = S_OK;
GSUB_initialize_script_cache(psc);
*pcTags = psc->script_count;
if (!searchingFor && cMaxTags < *pcTags)
rc = E_OUTOFMEMORY;
else if (searchingFor)
rc = USP_E_SCRIPT_NOT_IN_FONT;
for (i = 0; i < *pcTags; i++)
for (i = 0; i < psc->script_count; i++)
{
if (i < cMaxTags)
pScriptTags[i] = MS_MAKE_TAG(script->ScriptRecord[i].ScriptTag[0], script->ScriptRecord[i].ScriptTag[1], script->ScriptRecord[i].ScriptTag[2], script->ScriptRecord[i].ScriptTag[3]);
pScriptTags[i] = psc->scripts[i].tag;
if (searchingFor)
{
if (strncmp(script->ScriptRecord[i].ScriptTag, (char*)&searchingFor,4)==0)
if (searchingFor == psc->scripts[i].tag)
{
pScriptTags[0] = MS_MAKE_TAG(script->ScriptRecord[i].ScriptTag[0], script->ScriptRecord[i].ScriptTag[1], script->ScriptRecord[i].ScriptTag[2], script->ScriptRecord[i].ScriptTag[3]);
pScriptTags[0] = psc->scripts[i].tag;
*pcTags = 1;
if (script_table)
{
int offset = GET_BE_WORD(script->ScriptRecord[i].Script);
*script_table = ((const BYTE*)script + offset);
}
*script_table = psc->scripts[i].table;
rc = S_OK;
break;
}
......@@ -3836,7 +3850,7 @@ HRESULT SHAPE_GetFontScriptTags( HDC hdc, ScriptCache *psc,
searching = MS_MAKE_TAG(ShapingData[psa->eScript].otTag[0], ShapingData[psa->eScript].otTag[1], ShapingData[psa->eScript].otTag[2], ShapingData[psa->eScript].otTag[3]);
}
hr = GSUB_GetFontScriptTags(psc->GSUB_Table, searching, cMaxTags, pScriptTags, pcTags, NULL);
hr = GSUB_GetFontScriptTags(psc, searching, cMaxTags, pScriptTags, pcTags, NULL);
if (FAILED(hr))
*pcTags = 0;
return hr;
......
......@@ -933,6 +933,7 @@ HRESULT WINAPI ScriptFreeCache(SCRIPT_CACHE *psc)
heap_free(((ScriptCache *)*psc)->GSUB_Table);
heap_free(((ScriptCache *)*psc)->GDEF_Table);
heap_free(((ScriptCache *)*psc)->CMAP_Table);
heap_free(((ScriptCache *)*psc)->scripts);
heap_free(((ScriptCache *)*psc)->features);
heap_free(*psc);
*psc = NULL;
......
......@@ -132,6 +132,11 @@ typedef struct {
} LoadedFeature;
typedef struct {
OPENTYPE_TAG tag;
LPCVOID table;
} LoadedScript;
typedef struct {
LOGFONTW lf;
TEXTMETRICW tm;
BOOL sfnt;
......@@ -143,6 +148,8 @@ typedef struct {
LPVOID CMAP_format12_Table;
INT feature_count;
LoadedFeature *features;
INT script_count;
LoadedScript *scripts;
OPENTYPE_TAG userScript;
OPENTYPE_TAG userLang;
......
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