Nikolay Sivov : dwrite: Use stream fragment context when reading font tables.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Nov 27 16:07:41 CST 2014


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Nov 26 09:27:38 2014 +0300

dwrite: Use stream fragment context when reading font tables.

---

 dlls/dwrite/font.c       | 38 ++------------------------------------
 dlls/dwrite/tests/font.c |  2 --
 2 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index 76f3e3e..073f11a 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -91,14 +91,6 @@ struct dwrite_font {
     struct dwrite_font_data *data;
 };
 
-#define DWRITE_FONTTABLE_MAGIC 0xededfafa
-
-struct dwrite_fonttablecontext {
-    UINT32 magic;
-    void  *context;
-    UINT32 file_index;
-};
-
 struct dwrite_fonttable {
     void  *data;
     void  *context;
@@ -359,45 +351,19 @@ static HRESULT WINAPI dwritefontface_TryGetFontTable(IDWriteFontFace2 *iface, UI
     const void **table_data, UINT32 *table_size, void **context, BOOL *exists)
 {
     struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface);
-    struct dwrite_fonttablecontext *tablecontext;
-    HRESULT hr = S_OK;
-    int i;
 
     TRACE("(%p)->(%u %p %p %p %p)\n", This, table_tag, table_data, table_size, context, exists);
 
-    tablecontext = heap_alloc(sizeof(struct dwrite_fonttablecontext));
-    if (!tablecontext)
-        return E_OUTOFMEMORY;
-    tablecontext->magic = DWRITE_FONTTABLE_MAGIC;
-
-    *exists = FALSE;
-    for (i = 0; i < This->file_count && !(*exists); i++) {
-        hr = opentype_get_font_table(This->streams[i], This->type, This->index, table_tag, table_data, &tablecontext->context, table_size, exists);
-        tablecontext->file_index = i;
-    }
-    if (FAILED(hr) && !*exists)
-        heap_free(tablecontext);
-    else
-        *context = (void*)tablecontext;
-
-    return hr;
+    return opentype_get_font_table(This->streams[0], This->type, This->index, table_tag, table_data, context, table_size, exists);
 }
 
 static void WINAPI dwritefontface_ReleaseFontTable(IDWriteFontFace2 *iface, void *table_context)
 {
     struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface);
-    struct dwrite_fonttablecontext *tablecontext = (struct dwrite_fonttablecontext*)table_context;
 
     TRACE("(%p)->(%p)\n", This, table_context);
 
-    if (tablecontext->magic != DWRITE_FONTTABLE_MAGIC)
-    {
-        TRACE("Invalid table magic\n");
-        return;
-    }
-
-    IDWriteFontFileStream_ReleaseFileFragment(This->streams[tablecontext->file_index], tablecontext->context);
-    heap_free(tablecontext);
+    IDWriteFontFileStream_ReleaseFileFragment(This->streams[0], table_context);
 }
 
 static HRESULT WINAPI dwritefontface_GetGlyphRunOutline(IDWriteFontFace2 *iface, FLOAT emSize,
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 221a5d3..c14cf09 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -2324,7 +2324,6 @@ static void test_TryGetFontTable(void)
     hr = IDWriteFontFace_TryGetFontTable(fontface, MS_CMAP_TAG, &table, &size, &context, &exists);
     ok(hr == S_OK, "got 0x%08x\n",hr);
     ok(exists == TRUE, "got %d\n", exists);
-todo_wine
     ok(context == NULL && table != NULL, "cmap: context %p, table %p\n", context, table);
 
     exists = FALSE;
@@ -2333,7 +2332,6 @@ todo_wine
     hr = IDWriteFontFace_TryGetFontTable(fontface, MS_CMAP_TAG, &table2, &size, &context2, &exists);
     ok(hr == S_OK, "got 0x%08x\n",hr);
     ok(exists == TRUE, "got %d\n", exists);
-todo_wine
     ok(context2 == context && table2 == table, "cmap: context2 %p, table2 %p\n", context2, table2);
 
     IDWriteFontFace_ReleaseFontTable(fontface, context2);




More information about the wine-cvs mailing list