From 3d846a8d04c1df9e1fc5ecd720ba7b9062d5e37a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 16 Mar 2024 21:49:17 -0600 Subject: [PATCH] [limits] Centralize graph edge limits --- src/OT/Color/COLR/COLR.hh | 2 +- src/OT/glyf/Glyph.hh | 2 +- src/hb-ft-colr.hh | 2 +- src/hb-limits.hh | 11 +++-------- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index 623775a77..99d49d1d0 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -72,7 +72,7 @@ public: 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; + int edge_count = HB_MAX_GRAPH_EDGE_COUNT; hb_paint_context_t (const void *base_, hb_paint_funcs_t *funcs_, diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh index 4d93a4164..e69db96ff 100644 --- a/src/OT/glyf/Glyph.hh +++ b/src/OT/glyf/Glyph.hh @@ -319,7 +319,7 @@ struct Glyph if (unlikely (depth > HB_MAX_NESTING_LEVEL)) return false; unsigned stack_edge_count = 0; if (!edge_count) edge_count = &stack_edge_count; - if (unlikely (*edge_count > HB_GLYF_MAX_EDGE_COUNT)) return false; + if (unlikely (*edge_count > HB_MAX_GRAPH_EDGE_COUNT)) return false; (*edge_count)++; hb_map_t current_glyphs_stack; diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index 1afbbbb18..8766a2a2c 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -108,7 +108,7 @@ struct hb_ft_paint_context_t 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; + int edge_count = HB_MAX_GRAPH_EDGE_COUNT; }; static unsigned diff --git a/src/hb-limits.hh b/src/hb-limits.hh index 5710c2bbc..ce01ed629 100644 --- a/src/hb-limits.hh +++ b/src/hb-limits.hh @@ -88,6 +88,9 @@ #define HB_MAX_LOOKUP_VISIT_COUNT 35000 #endif +#ifndef HB_MAX_GRAPH_EDGE_COUNT +#define HB_MAX_GRAPH_EDGE_COUNT 2048 +#endif #ifndef HB_VAR_COMPOSITE_MAX_AXES #define HB_VAR_COMPOSITE_MAX_AXES 4096 @@ -97,17 +100,9 @@ #define HB_GLYF_MAX_POINTS 20000 #endif -#ifndef HB_GLYF_MAX_EDGE_COUNT -#define HB_GLYF_MAX_EDGE_COUNT 1024 -#endif - #ifndef HB_CFF_MAX_OPS #define HB_CFF_MAX_OPS 10000 #endif -#ifndef HB_COLRV1_MAX_EDGE_COUNT -#define HB_COLRV1_MAX_EDGE_COUNT 2048 -#endif - #endif /* HB_LIMITS_HH */