From f8e3cba7462eaa936a14add168ffe2fcb7d839ef Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 8 Mar 2021 11:30:49 +0300 Subject: [PATCH] dwrite: Check for vertical variants only when asked. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/dwrite_private.h | 13 +++++++------ dlls/dwrite/font.c | 4 +--- dlls/dwrite/opentype.c | 12 ++++++++++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 4628a2a3704..27f4906a00d 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -182,11 +182,12 @@ struct fontfacecached enum font_flags { - FONT_IS_SYMBOL = 1 << 0, - FONT_IS_MONOSPACED = 1 << 1, - FONT_IS_COLORED = 1 << 2, /* CPAL/COLR support */ - FONTFACE_HAS_KERNING_PAIRS = 1 << 3, - FONTFACE_HAS_VERTICAL_VARIANTS = 1 << 4 + FONT_IS_SYMBOL = 0x00000001, + FONT_IS_MONOSPACED = 0x00000002, + FONT_IS_COLORED = 0x00000004, /* CPAL/COLR support */ + FONTFACE_HAS_KERNING_PAIRS = 0x00000008, + FONTFACE_VERTICAL_VARIANTS = 0x00000010, + FONTFACE_NO_VERTICAL_VARIANTS = 0x00000020, }; struct dwrite_cmap; @@ -257,7 +258,7 @@ struct dwrite_fontface unsigned int ascent; unsigned int descent; } typo_metrics; - UINT32 flags; + unsigned int flags; struct dwrite_cmap cmap; diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 9386e9bec3f..5a96ccc71a0 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -1217,7 +1217,7 @@ static BOOL WINAPI dwritefontface1_HasVerticalGlyphVariants(IDWriteFontFace5 *if TRACE("%p.\n", iface); - return !!(fontface->flags & FONTFACE_HAS_VERTICAL_VARIANTS); + return opentype_has_vertical_variants(fontface); } static BOOL WINAPI dwritefontface2_IsColorFont(IDWriteFontFace5 *iface) @@ -5004,8 +5004,6 @@ HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_li if (freetype_has_kerning_pairs(&fontface->IDWriteFontFace5_iface)) fontface->flags |= FONTFACE_HAS_KERNING_PAIRS; - if (opentype_has_vertical_variants(fontface)) - fontface->flags |= FONTFACE_HAS_VERTICAL_VARIANTS; fontface->glyph_image_formats = opentype_get_glyph_image_formats(&fontface->IDWriteFontFace5_iface); /* Font properties are reused from font object when 'normal' face creation path is used: diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index 39943c52c9a..45967a12f0a 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -6342,6 +6342,9 @@ BOOL opentype_has_vertical_variants(struct dwrite_fontface *fontface) struct lookups lookups = { 0 }; UINT16 format; + if (fontface->flags & (FONTFACE_VERTICAL_VARIANTS | FONTFACE_NO_VERTICAL_VARIANTS)) + return !!(fontface->flags & FONTFACE_VERTICAL_VARIANTS); + context.cache = fontface_get_shaping_cache(fontface); context.table = &context.cache->gsub; @@ -6384,7 +6387,12 @@ BOOL opentype_has_vertical_variants(struct dwrite_fontface *fontface) heap_free(lookups.lookups); - return !!count; + if (count) + fontface->flags |= FONTFACE_VERTICAL_VARIANTS; + else + fontface->flags |= FONTFACE_NO_VERTICAL_VARIANTS; + + return !!(fontface->flags & FONTFACE_VERTICAL_VARIANTS); } HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, unsigned int glyph_count, @@ -6398,7 +6406,7 @@ HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, u memcpy(glyphs, nominal_glyphs, glyph_count * sizeof(*glyphs)); - if (!(fontface->flags & FONTFACE_HAS_VERTICAL_VARIANTS)) + if (!opentype_has_vertical_variants(fontface)) return S_OK; context.cache = fontface_get_shaping_cache(fontface);