[PATCH] dwrite: Partially implement GetGlyphImageFormats()

Nikolay Sivov nsivov at codeweavers.com
Fri Apr 21 06:28:24 CDT 2017


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/dwrite/dwrite_private.h |  1 +
 dlls/dwrite/font.c           |  8 ++++++--
 dlls/dwrite/opentype.c       | 38 ++++++++++++++++++++++++++++++++++++++
 dlls/dwrite/tests/font.c     |  1 -
 4 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 886beb7c57..7dca5fbd22 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -229,6 +229,7 @@ extern UINT32 opentype_get_cpal_paletteentrycount(const void*) DECLSPEC_HIDDEN;
 extern HRESULT opentype_get_cpal_entries(const void*,UINT32,UINT32,UINT32,DWRITE_COLOR_F*) DECLSPEC_HIDDEN;
 extern HRESULT opentype_get_font_signature(struct file_stream_desc*,FONTSIGNATURE*) DECLSPEC_HIDDEN;
 extern BOOL opentype_has_vertical_variants(IDWriteFontFace4*) DECLSPEC_HIDDEN;
+extern UINT32 opentype_get_glyph_image_formats(IDWriteFontFace4*) DECLSPEC_HIDDEN;
 
 struct dwrite_colorglyph {
     USHORT layer; /* [0, num_layers) index indicating current layer */
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index c74b2bb2b1..ca2d69a6f3 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -242,6 +242,7 @@ struct dwrite_fontface {
     DWRITE_FONT_STRETCH stretch;
     DWRITE_FONT_WEIGHT weight;
     DWRITE_PANOSE panose;
+    UINT32 glyph_image_formats;
 
     LOGFONTW lf;
 };
@@ -1278,8 +1279,10 @@ static HRESULT WINAPI dwritefontface4_GetGlyphImageFormats_(IDWriteFontFace4 *if
 static DWRITE_GLYPH_IMAGE_FORMATS WINAPI dwritefontface4_GetGlyphImageFormats(IDWriteFontFace4 *iface)
 {
     struct dwrite_fontface *This = impl_from_IDWriteFontFace4(iface);
-    FIXME("(%p): stub\n", This);
-    return DWRITE_GLYPH_IMAGE_FORMATS_NONE;
+
+    TRACE("(%p)\n", This);
+
+    return This->glyph_image_formats;
 }
 
 static HRESULT WINAPI dwritefontface4_GetGlyphImageData(IDWriteFontFace4 *iface, UINT16 glyph,
@@ -4345,6 +4348,7 @@ HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_li
         fontface->flags |= FONTFACE_IS_MONOSPACED;
     if (opentype_has_vertical_variants(&fontface->IDWriteFontFace4_iface))
         fontface->flags |= FONTFACE_HAS_VERTICAL_VARIANTS;
+    fontface->glyph_image_formats = opentype_get_glyph_image_formats(&fontface->IDWriteFontFace4_iface);
 
     /* Font properties are reused from font object when 'normal' face creation path is used:
        collection -> family -> matching font -> fontface.
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c
index 7a3e641ad4..b7e9d87868 100644
--- a/dlls/dwrite/opentype.c
+++ b/dlls/dwrite/opentype.c
@@ -34,6 +34,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
 #define MS_GPOS_TAG DWRITE_MAKE_OPENTYPE_TAG('G','P','O','S')
 #define MS_GSUB_TAG DWRITE_MAKE_OPENTYPE_TAG('G','S','U','B')
 #define MS_NAME_TAG DWRITE_MAKE_OPENTYPE_TAG('n','a','m','e')
+#define MS_GLYF_TAG DWRITE_MAKE_OPENTYPE_TAG('g','l','y','f')
+#define MS_CFF__TAG DWRITE_MAKE_OPENTYPE_TAG('C','F','F',' ')
+#define MS_COLR_TAG DWRITE_MAKE_OPENTYPE_TAG('C','O','L','R')
 
 #ifdef WORDS_BIGENDIAN
 #define GET_BE_WORD(x) (x)
@@ -2034,3 +2037,38 @@ BOOL opentype_has_vertical_variants(IDWriteFontFace4 *fontface)
 
     return ret;
 }
+
+static BOOL opentype_has_font_table(IDWriteFontFace4 *fontface, UINT32 tag)
+{
+    BOOL exists = FALSE;
+    const void *data;
+    void *context;
+    UINT32 size;
+    HRESULT hr;
+
+    hr = IDWriteFontFace4_TryGetFontTable(fontface, tag, &data, &size, &context, &exists);
+    if (FAILED(hr))
+        return FALSE;
+
+    if (exists)
+        IDWriteFontFace4_ReleaseFontTable(fontface, context);
+
+    return exists;
+}
+
+UINT32 opentype_get_glyph_image_formats(IDWriteFontFace4 *fontface)
+{
+    UINT32 ret = DWRITE_GLYPH_IMAGE_FORMATS_NONE;
+
+    if (opentype_has_font_table(fontface, MS_GLYF_TAG))
+        ret |= DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE;
+
+    if (opentype_has_font_table(fontface, MS_CFF__TAG))
+        ret |= DWRITE_GLYPH_IMAGE_FORMATS_CFF;
+
+    if (opentype_has_font_table(fontface, MS_COLR_TAG))
+        ret |= DWRITE_GLYPH_IMAGE_FORMATS_COLR;
+
+    /* TODO: handle SVG and bitmap data */
+    return ret;
+}
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 2c874df5bf..4d5780c18b 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -7504,7 +7504,6 @@ static void test_GetGlyphImageFormats(void)
             /* Mask describes font as a whole. */
             formats = IDWriteFontFace4_GetGlyphImageFormats(fontface4);
             expected_formats = get_face_glyph_image_formats(fontface4);
-        todo_wine
             ok(formats == expected_formats, "%s - %s, expected formats %#x, got formats %#x.\n",
                 wine_dbgstr_w(familynameW), wine_dbgstr_w(facenameW), expected_formats, formats);
 
-- 
2.11.0




More information about the wine-patches mailing list