Aric Stewart : usp10: Change OpenType_GSUB_GetFontScriptTags to OpenType_GetFontScriptTags and load scripts from GPOS table as well .

Alexandre Julliard julliard at winehq.org
Mon Jul 16 14:14:29 CDT 2012


Module: wine
Branch: master
Commit: e031293521a9673542983f53e66e13d2efcf52f0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e031293521a9673542983f53e66e13d2efcf52f0

Author: Aric Stewart <aric at codeweavers.com>
Date:   Mon Jul 16 07:23:39 2012 -0500

usp10: Change OpenType_GSUB_GetFontScriptTags to OpenType_GetFontScriptTags and load scripts from GPOS table as well.

---

 dlls/usp10/opentype.c       |   90 ++++++++++++++++++++++++++++++++++++++-----
 dlls/usp10/shape.c          |    4 +-
 dlls/usp10/usp10_internal.h |    5 +-
 3 files changed, 85 insertions(+), 14 deletions(-)

diff --git a/dlls/usp10/opentype.c b/dlls/usp10/opentype.c
index bf237eb..1aa77c02 100644
--- a/dlls/usp10/opentype.c
+++ b/dlls/usp10/opentype.c
@@ -277,6 +277,15 @@ typedef struct{
     WORD Alternate[1];
 } GSUB_AlternateSet;
 
+/* These are all structures needed for the GPOS table */
+
+typedef struct {
+    DWORD version;
+    WORD ScriptList;
+    WORD FeatureList;
+    WORD LookupList;
+} GPOS_Header;
+
 /**********
  * CMAP
  **********/
@@ -864,7 +873,7 @@ static void GSUB_initialize_script_cache(ScriptCache *psc)
 {
     int i;
 
-    if (!psc->script_count)
+    if (psc->GSUB_Table)
     {
         const OT_ScriptList *script;
         const GSUB_Header* header = (const GSUB_Header*)psc->GSUB_Table;
@@ -878,18 +887,81 @@ static void GSUB_initialize_script_cache(ScriptCache *psc)
             {
                 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);
+                psc->scripts[i].gsub_table = ((const BYTE*)script + offset);
             }
         }
     }
 }
 
-HRESULT OpenType_GSUB_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags, LPCVOID* script_table)
+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_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags)
 {
     int i;
     HRESULT rc = S_OK;
 
-    GSUB_initialize_script_cache(psc);
+    _initialize_script_cache(psc);
+
     *pcTags = psc->script_count;
 
     if (!searchingFor && cMaxTags < *pcTags)
@@ -908,8 +980,6 @@ HRESULT OpenType_GSUB_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searching
             {
                 pScriptTags[0] = psc->scripts[i].tag;
                 *pcTags = 1;
-                if (script_table)
-                    *script_table = psc->scripts[i].table;
                 rc = S_OK;
                 break;
             }
@@ -922,10 +992,10 @@ static void GSUB_initialize_language_cache(LoadedScript *script)
 {
     int i;
 
-    if (!script->language_count)
+    if (!script->language_count && script->gsub_table)
     {
         DWORD offset;
-        const OT_Script* table = script->table;
+        const OT_Script* table = script->gsub_table;
         script->language_count = GET_BE_WORD(table->LangSysCount);
         offset = GET_BE_WORD(table->DefaultLangSys);
         if (offset)
@@ -956,7 +1026,7 @@ HRESULT OpenType_GSUB_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_
     HRESULT rc = S_OK;
     LoadedScript *script = NULL;
 
-    GSUB_initialize_script_cache(psc);
+    _initialize_script_cache(psc);
 
     for (i = 0; i < psc->script_count; i++)
     {
@@ -1061,7 +1131,7 @@ HRESULT OpenType_GSUB_GetFontFeatureTags(ScriptCache *psc, OPENTYPE_TAG script_t
     LoadedScript *script = NULL;
     LoadedLanguage *language = NULL;
 
-    GSUB_initialize_script_cache(psc);
+    _initialize_script_cache(psc);
 
     for (i = 0; i < psc->script_count; i++)
     {
diff --git a/dlls/usp10/shape.c b/dlls/usp10/shape.c
index e288878..b7d2822 100644
--- a/dlls/usp10/shape.c
+++ b/dlls/usp10/shape.c
@@ -807,7 +807,7 @@ static inline BOOL get_GSUB_Indic2(SCRIPT_ANALYSIS *psa, ScriptCache *psc)
     HRESULT hr;
     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));
 }
@@ -3244,7 +3244,7 @@ HRESULT SHAPE_GetFontScriptTags( HDC hdc, ScriptCache *psc,
     if (psa && 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))
         *pcTags = 0;
     return hr;
diff --git a/dlls/usp10/usp10_internal.h b/dlls/usp10/usp10_internal.h
index 9644159..3cb48d8 100644
--- a/dlls/usp10/usp10_internal.h
+++ b/dlls/usp10/usp10_internal.h
@@ -144,7 +144,8 @@ typedef struct {
 
 typedef struct {
     OPENTYPE_TAG tag;
-    LPCVOID table;
+    LPCVOID gsub_table;
+    LPCVOID gpos_table;
     LoadedLanguage default_language;
     INT language_count;
     LoadedLanguage *languages;
@@ -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;
 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;
-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_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;




More information about the wine-cvs mailing list