Nikolay Sivov : dwrite: Pass raw NAME table pointer to table reading code.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Oct 24 08:32:35 CDT 2014


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Oct 24 11:42:35 2014 +0400

dwrite: Pass raw NAME table pointer to table reading code.

---

 dlls/dwrite/dwrite_private.h |  2 +-
 dlls/dwrite/font.c           | 21 +++++++++++++++++----
 dlls/dwrite/main.c           | 39 +++++++++++++++++++++------------------
 dlls/dwrite/opentype.c       | 15 +++------------
 dlls/dwrite/tests/font.c     |  6 ++----
 5 files changed, 44 insertions(+), 39 deletions(-)

diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 02601fb..faf1b0a 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -113,7 +113,7 @@ extern HRESULT opentype_get_font_table(IDWriteFontFileStream*,DWRITE_FONT_FACE_T
 extern void opentype_cmap_get_glyphindex(void*,UINT32,UINT16*) DECLSPEC_HIDDEN;
 extern HRESULT opentype_cmap_get_unicode_ranges(void*,UINT32,DWRITE_UNICODE_RANGE*,UINT32*) DECLSPEC_HIDDEN;
 extern VOID get_font_properties(LPCVOID os2, LPCVOID head, LPCVOID post, DWRITE_FONT_METRICS *metrics, DWRITE_FONT_STRETCH *stretch, DWRITE_FONT_WEIGHT *weight, DWRITE_FONT_STYLE *style) DECLSPEC_HIDDEN;
-extern HRESULT opentype_get_font_strings_from_id(IDWriteFontFace2*,DWRITE_INFORMATIONAL_STRING_ID,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
+extern HRESULT opentype_get_font_strings_from_id(const void*,DWRITE_INFORMATIONAL_STRING_ID,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
 
 extern HRESULT bidi_computelevels(const WCHAR*,UINT32,UINT8,UINT8*,UINT8*) DECLSPEC_HIDDEN;
 extern WCHAR bidi_get_mirrored_char(WCHAR) DECLSPEC_HIDDEN;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index fcdfdb5..217f772 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -29,6 +29,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
 #define MS_OS2_TAG  DWRITE_MAKE_OPENTYPE_TAG('O','S','/','2')
 #define MS_POST_TAG DWRITE_MAKE_OPENTYPE_TAG('p','o','s','t')
 #define MS_CMAP_TAG DWRITE_MAKE_OPENTYPE_TAG('c','m','a','p')
+#define MS_NAME_TAG DWRITE_MAKE_OPENTYPE_TAG('n','a','m','e')
 
 struct dwrite_fontface_data {
     LONG ref;
@@ -986,14 +987,26 @@ static HRESULT WINAPI dwritefont_GetInformationalStrings(IDWriteFont2 *iface,
 
     if (!data->info_strings[stringid]) {
         IDWriteFontFace2 *fontface;
+        const void *table_data;
+        BOOL table_exists;
+        void *context;
+        UINT32 size;
 
         hr = get_fontface_from_font(This, &fontface);
         if (FAILED(hr))
             return hr;
 
-        hr = opentype_get_font_strings_from_id(fontface, stringid, &data->info_strings[stringid]);
-        if (FAILED(hr) || !data->info_strings[stringid])
-            return hr;
+        table_exists = FALSE;
+        hr = IDWriteFontFace2_TryGetFontTable(fontface, MS_NAME_TAG, &table_data, &size, &context, &table_exists);
+        if (FAILED(hr) || !table_exists)
+            WARN("no NAME table found.\n");
+
+        if (table_exists) {
+            hr = opentype_get_font_strings_from_id(table_data, stringid, &data->info_strings[stringid]);
+            if (FAILED(hr) || !data->info_strings[stringid])
+                return hr;
+            IDWriteFontFace2_ReleaseFontTable(fontface, context);
+        }
     }
 
     hr = clone_localizedstring(data->info_strings[stringid], strings);
@@ -1001,7 +1014,7 @@ static HRESULT WINAPI dwritefont_GetInformationalStrings(IDWriteFont2 *iface,
         return hr;
 
     *exists = TRUE;
-    return hr;
+    return S_OK;
 }
 
 static DWRITE_FONT_SIMULATIONS WINAPI dwritefont_GetSimulations(IDWriteFont2 *iface)
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index 4c549d6..d844e7f 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -361,33 +361,36 @@ HRESULT add_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *locale,
     return S_OK;
 }
 
-HRESULT clone_localizedstring(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **strings)
-{
-    struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
-    struct localizedstrings *New;
+HRESULT clone_localizedstring(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **ret)
+ {
+    struct localizedstrings *strings, *strings_clone;
     int i;
 
-    *strings = NULL;
+    *ret = NULL;
+
+    if (!iface)
+        return S_FALSE;
 
-    New = heap_alloc(sizeof(struct localizedstrings));
-    if (!New) return E_OUTOFMEMORY;
+    strings = impl_from_IDWriteLocalizedStrings(iface);
+    strings_clone = heap_alloc(sizeof(struct localizedstrings));
+    if (!strings_clone) return E_OUTOFMEMORY;
 
-    New->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl;
-    New->ref = 1;
-    New->count = This->count;
-    New->data = heap_alloc(sizeof(struct localizedpair) * New->count);
-    if (!New->data) {
-        heap_free(New);
+    strings_clone->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl;
+    strings_clone->ref = 1;
+    strings_clone->count = strings->count;
+    strings_clone->data = heap_alloc(sizeof(struct localizedpair) * strings_clone->count);
+    if (!strings_clone->data) {
+        heap_free(strings_clone);
         return E_OUTOFMEMORY;
     }
-    for (i = 0; i < New->count; i++)
+    for (i = 0; i < strings_clone->count; i++)
     {
-        New->data[i].locale = heap_strdupW(This->data[i].locale);
-        New->data[i].string = heap_strdupW(This->data[i].string);
+        strings_clone->data[i].locale = heap_strdupW(strings->data[i].locale);
+        strings_clone->data[i].string = heap_strdupW(strings->data[i].string);
     }
-    New->alloc = New->count;
+    strings_clone->alloc = strings_clone->count;
 
-    *strings = &New->IDWriteLocalizedStrings_iface;
+    *ret = &strings_clone->IDWriteLocalizedStrings_iface;
 
     return S_OK;
 }
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c
index ed08899..c007b35 100644
--- a/dlls/dwrite/opentype.c
+++ b/dlls/dwrite/opentype.c
@@ -26,7 +26,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
 
 #define MS_TTCF_TAG DWRITE_MAKE_OPENTYPE_TAG('t','t','c','f')
 #define MS_OTTO_TAG DWRITE_MAKE_OPENTYPE_TAG('O','T','T','O')
-#define MS_NAME_TAG DWRITE_MAKE_OPENTYPE_TAG('n','a','m','e')
 
 #ifdef WORDS_BIGENDIAN
 #define GET_BE_WORD(x) (x)
@@ -615,24 +614,18 @@ VOID get_font_properties(LPCVOID os2, LPCVOID head, LPCVOID post, DWRITE_FONT_ME
     }
 }
 
-HRESULT opentype_get_font_strings_from_id(IDWriteFontFace2 *fontface, DWRITE_INFORMATIONAL_STRING_ID id, IDWriteLocalizedStrings **strings)
+HRESULT opentype_get_font_strings_from_id(const void *table_data, DWRITE_INFORMATIONAL_STRING_ID id, IDWriteLocalizedStrings **strings)
 {
-    const void *table_data = NULL;
-    void *name_context = NULL;
     const TT_NAME_V0 *header;
     BYTE *storage_area = 0;
-    BOOL exists = FALSE;
     USHORT count = 0;
     UINT16 name_id;
-    UINT32 size;
+    BOOL exists;
     HRESULT hr;
     int i;
 
-    hr = IDWriteFontFace2_TryGetFontTable(fontface, MS_NAME_TAG, &table_data, &size, &name_context, &exists);
-    if (FAILED(hr) || !exists) {
-        FIXME("failed to get NAME table\n");
+    if (!table_data)
         return E_FAIL;
-    }
 
     hr = create_localizedstrings(strings);
     if (FAILED(hr)) return hr;
@@ -727,8 +720,6 @@ HRESULT opentype_get_font_strings_from_id(IDWriteFontFace2 *fontface, DWRITE_INF
         }
     }
 
-    IDWriteFontFace2_ReleaseFontTable(fontface, name_context);
-
     if (!exists) {
         IDWriteLocalizedStrings_Release(*strings);
         *strings = NULL;
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index baba6c2..3830bc9 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -1521,10 +1521,9 @@ static void test_GetInformationalStrings(void)
     exists = FALSE;
     strings = NULL;
     hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists);
-todo_wine {
     ok(hr == S_OK, "got 0x%08x\n", hr);
     ok(exists == TRUE, "got %d\n", exists);
-}
+
     exists = TRUE;
     strings = NULL;
     hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_NONE, &strings, &exists);
@@ -1534,10 +1533,9 @@ todo_wine {
     /* strings instance is not reused */
     strings2 = NULL;
     hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings2, &exists);
-todo_wine {
     ok(hr == S_OK, "got 0x%08x\n", hr);
+todo_wine
     ok(strings2 != strings, "got %p, %p\n", strings2, strings);
-}
 
 if (strings)
     IDWriteLocalizedStrings_Release(strings);




More information about the wine-cvs mailing list