Nikolay Sivov : dwrite: Evaluate IsColorFont() flag at font level.

Alexandre Julliard julliard at winehq.org
Thu Jan 23 15:48:50 CST 2020


Module: wine
Branch: master
Commit: 15e62caa7a0855aa3d80df8a4ceaeb9a74a837a6
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=15e62caa7a0855aa3d80df8a4ceaeb9a74a837a6

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Jan 23 12:24:14 2020 +0300

dwrite: Evaluate IsColorFont() flag at font level.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dwrite/dwrite_private.h |  5 +++--
 dlls/dwrite/font.c           | 22 ++++------------------
 dlls/dwrite/opentype.c       | 19 ++++++++++++++++++-
 3 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 0705d43b1f..cf3f13b1c6 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -187,8 +187,9 @@ enum font_flags
 {
     FONT_IS_SYMBOL                 = 1 << 0,
     FONT_IS_MONOSPACED             = 1 << 1,
-    FONTFACE_HAS_KERNING_PAIRS     = 1 << 2,
-    FONTFACE_HAS_VERTICAL_VARIANTS = 1 << 3
+    FONT_IS_COLORED                = 1 << 2, /* CPAL/COLR support */
+    FONTFACE_HAS_KERNING_PAIRS     = 1 << 3,
+    FONTFACE_HAS_VERTICAL_VARIANTS = 1 << 4
 };
 
 struct dwrite_fontface
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index c1c9ce20fa..4e08b2f632 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -418,11 +418,6 @@ static const struct dwrite_fonttable *get_fontface_cpal(struct dwrite_fontface *
     return &fontface->cpal;
 }
 
-static const void* get_fontface_colr(struct dwrite_fontface *fontface)
-{
-    return get_fontface_table(&fontface->IDWriteFontFace5_iface, MS_COLR_TAG, &fontface->colr);
-}
-
 static void addref_font_data(struct dwrite_font_data *data)
 {
     InterlockedIncrement(&data->ref);
@@ -1121,7 +1116,7 @@ static BOOL WINAPI dwritefontface2_IsColorFont(IDWriteFontFace5 *iface)
 
     TRACE("%p.\n", iface);
 
-    return get_fontface_cpal(fontface) && get_fontface_colr(fontface);
+    return !!(fontface->flags & FONT_IS_COLORED);
 }
 
 static UINT32 WINAPI dwritefontface2_GetColorPaletteCount(IDWriteFontFace5 *iface)
@@ -1774,19 +1769,10 @@ static BOOL WINAPI dwritefont1_IsMonospacedFont(IDWriteFont3 *iface)
 static BOOL WINAPI dwritefont2_IsColorFont(IDWriteFont3 *iface)
 {
     struct dwrite_font *font = impl_from_IDWriteFont3(iface);
-    IDWriteFontFace5 *fontface;
-    HRESULT hr;
-    BOOL ret;
 
     TRACE("%p.\n", iface);
 
-    hr = get_fontface_from_font(font, &fontface);
-    if (FAILED(hr))
-        return FALSE;
-
-    ret = IDWriteFontFace5_IsColorFont(fontface);
-    IDWriteFontFace5_Release(fontface);
-    return ret;
+    return !!(font->data->flags & FONT_IS_COLORED);
 }
 
 static HRESULT WINAPI dwritefont3_CreateFontFace(IDWriteFont3 *iface, IDWriteFontFace3 **fontface)
@@ -4698,7 +4684,7 @@ HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_li
         fontface->panose = desc->font_data->panose;
         fontface->fontsig = desc->font_data->fontsig;
         fontface->lf = desc->font_data->lf;
-        fontface->flags |= desc->font_data->flags & (FONT_IS_SYMBOL | FONT_IS_MONOSPACED);
+        fontface->flags |= desc->font_data->flags & (FONT_IS_SYMBOL | FONT_IS_MONOSPACED | FONT_IS_COLORED);
     }
     else
     {
@@ -4718,7 +4704,7 @@ HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_li
         fontface->panose = data->panose;
         fontface->fontsig = data->fontsig;
         fontface->lf = data->lf;
-        fontface->flags |= data->flags & (FONT_IS_SYMBOL | FONT_IS_MONOSPACED);
+        fontface->flags |= data->flags & (FONT_IS_SYMBOL | FONT_IS_MONOSPACED | FONT_IS_COLORED);
 
         IDWriteLocalizedStrings_Release(names);
         release_font_data(data);
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c
index 5f41a5764b..86716f615d 100644
--- a/dlls/dwrite/opentype.c
+++ b/dlls/dwrite/opentype.c
@@ -39,6 +39,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
 #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_CFF2_TAG DWRITE_MAKE_OPENTYPE_TAG('C','F','F','2')
+#define MS_CPAL_TAG DWRITE_MAKE_OPENTYPE_TAG('C','P','A','L')
 #define MS_COLR_TAG DWRITE_MAKE_OPENTYPE_TAG('C','O','L','R')
 #define MS_SVG__TAG DWRITE_MAKE_OPENTYPE_TAG('S','V','G',' ')
 #define MS_SBIX_TAG DWRITE_MAKE_OPENTYPE_TAG('s','b','i','x')
@@ -1715,7 +1716,7 @@ void opentype_get_font_metrics(struct file_stream_desc *stream_desc, DWRITE_FONT
 
 void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct dwrite_font_props *props)
 {
-    struct dwrite_fonttable os2, head;
+    struct dwrite_fonttable os2, head, colr, cpal;
     BOOL is_symbol, is_monospaced;
     const TT_OS2_V2 *tt_os2;
     const TT_HEAD *tt_head;
@@ -1793,6 +1794,7 @@ void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct d
 
     props->lf.lfWeight = props->weight;
 
+    /* FONT_IS_SYMBOL */
     if (!(is_symbol = props->panose.familyKind == DWRITE_PANOSE_FAMILY_SYMBOL))
     {
         struct dwrite_fonttable cmap;
@@ -1824,6 +1826,7 @@ void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct d
     if (is_symbol)
         props->flags |= FONT_IS_SYMBOL;
 
+    /* FONT_IS_MONOSPACED */
     if (!(is_monospaced = props->panose.text.proportion == DWRITE_PANOSE_PROPORTION_MONOSPACED))
     {
         struct dwrite_fonttable post;
@@ -1840,6 +1843,20 @@ void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct d
     if (is_monospaced)
         props->flags |= FONT_IS_MONOSPACED;
 
+    /* FONT_IS_COLORED */
+    opentype_get_font_table(stream_desc, MS_COLR_TAG, &colr);
+    if (colr.data)
+    {
+        opentype_get_font_table(stream_desc, MS_CPAL_TAG, &cpal);
+        if (cpal.data)
+        {
+            props->flags |= FONT_IS_COLORED;
+            IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, cpal.context);
+        }
+
+        IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, colr.context);
+    }
+
     TRACE("stretch=%d, weight=%d, style %d\n", props->stretch, props->weight, props->style);
 
     if (os2.data)




More information about the wine-cvs mailing list