diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 0705d43b1f5..cf3f13b1c68 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 c1c9ce20faf..4e08b2f632b 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 5f41a5764b2..86716f615d1 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)