From 06ff3bcb8db2ac9eac80bef21644c4d70f60573a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 15 Aug 2023 14:41:18 -0600 Subject: [PATCH] [COLR,glyf] Use map instead of set for tracking current glyphs / layers --- src/OT/Color/COLR/COLR.hh | 4 ++-- src/OT/glyf/Glyph.hh | 4 ++-- src/hb-ft-colr.hh | 4 ++-- src/hb-map.hh | 5 +++++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index 3618a02a9..012c38146 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -69,8 +69,8 @@ public: unsigned int palette_index; hb_color_t foreground; VarStoreInstancer &instancer; - hb_set_t current_glyphs; - hb_set_t current_layers; + hb_map_t current_glyphs; + hb_map_t current_layers; int depth_left = HB_MAX_NESTING_LEVEL; int edge_count = HB_COLRV1_MAX_EDGE_COUNT; diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh index 9117fe82a..1aed3ae47 100644 --- a/src/OT/glyf/Glyph.hh +++ b/src/OT/glyf/Glyph.hh @@ -293,7 +293,7 @@ struct Glyph bool use_my_metrics = true, bool phantom_only = false, hb_array_t coords = hb_array_t (), - hb_set_t *current_glyphs = nullptr, + hb_map_t *current_glyphs = nullptr, unsigned int depth = 0, unsigned *edge_count = nullptr) const { @@ -303,7 +303,7 @@ struct Glyph if (unlikely (*edge_count > HB_GLYF_MAX_EDGE_COUNT)) return false; (*edge_count)++; - hb_set_t current_glyphs_stack; + hb_map_t current_glyphs_stack; if (current_glyphs == nullptr) current_glyphs = ¤t_glyphs_stack; diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index 26903164a..1afbbbb18 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -105,8 +105,8 @@ struct hb_ft_paint_context_t FT_Color *palette; unsigned palette_index; hb_color_t foreground; - hb_set_t current_glyphs; - hb_set_t current_layers; + hb_map_t current_glyphs; + hb_map_t current_layers; int depth_left = HB_MAX_NESTING_LEVEL; int edge_count = HB_COLRV1_MAX_EDGE_COUNT; }; diff --git a/src/hb-map.hh b/src/hb-map.hh index 42604ef7c..6ea416658 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -276,6 +276,11 @@ struct hb_hashmap_t uint32_t hash = hb_hash (key); return set_with_hash (std::move (key), hash, std::forward (value), overwrite); } + bool add (const K &key) + { + uint32_t hash = hb_hash (key); + return set_with_hash (key, hash, item_t::default_value ()); + } const V& get_with_hash (const K &key, uint32_t hash) const {