From 1e629c35113e2460fd4a77b4fa9ae3ff6ec876ba Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sun, 12 Jan 2025 23:06:23 +0200 Subject: [PATCH] [morx] Blocklist dysfunctional morx table of AALMAGHRIBI.ttf font Fixes #4108 --- src/hb-aat-layout-morx-table.hh | 19 +++++++++++++++++-- src/hb-aat-layout.cc | 33 +++++++++++++++++++++++++++++++++ src/hb-config.hh | 1 + 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index d31834402..532766ff0 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -1298,6 +1298,12 @@ struct mortmorx hb_sanitize_context_t sc; this->table = sc.reference_table (face); + if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face))) + { + hb_blob_destroy (this->table.get_blob ()); + this->table = hb_blob_get_empty (); + } + this->chain_count = table->get_chain_count (); this->accels = (hb_atomic_ptr_t *) hb_calloc (this->chain_count, sizeof (*accels)); @@ -1428,8 +1434,17 @@ struct mortmorx DEFINE_SIZE_MIN (8); }; -struct morx : mortmorx {}; -struct mort : mortmorx {}; +struct morx : mortmorx +{ + HB_INTERNAL bool is_blocklisted (hb_blob_t *blob, + hb_face_t *face) const; +}; + +struct mort : mortmorx +{ + HB_INTERNAL bool is_blocklisted (hb_blob_t *blob, + hb_face_t *face) const; +}; struct morx_accelerator_t : morx::accelerator_t { morx_accelerator_t (hb_face_t *face) : morx::accelerator_t (face) {} diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 9da29e51c..4ce1cca71 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -37,6 +37,9 @@ #include "hb-aat-layout-trak-table.hh" #include "hb-aat-ltag-table.hh" +#include "hb-ot-layout-gsub-table.hh" +#include "hb-ot-layout-gdef-table.hh" + /* * hb_aat_apply_context_t @@ -207,6 +210,36 @@ hb_aat_layout_find_feature_mapping (hb_tag_t tag) */ +bool +AAT::morx::is_blocklisted (hb_blob_t *blob, + hb_face_t *face) const +{ +#ifdef HB_NO_AAT_LAYOUT_BLOCKLIST + return false; +#endif + + switch HB_CODEPOINT_ENCODE3 (blob->length, + face->table.GSUB->table.get_length (), + face->table.GDEF->table.get_length ()) + { + /* https://github.com/harfbuzz/harfbuzz/issues/4108 + sha1sum:a71ca6813b7e56a772cffff7c24a5166b087197c AALMAGHRIBI.ttf */ + case HB_CODEPOINT_ENCODE3 (19892, 2794, 340): + return true; + } + return false; +} + +bool +AAT::mort::is_blocklisted (hb_blob_t *blob, + hb_face_t *face) const +{ +#ifdef HB_NO_AAT_LAYOUT_BLOCKLIST + return false; +#endif + return false; +} + void hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper, hb_aat_map_t *map) diff --git a/src/hb-config.hh b/src/hb-config.hh index 09f669567..40cc2403c 100644 --- a/src/hb-config.hh +++ b/src/hb-config.hh @@ -157,6 +157,7 @@ #define HB_NO_FALLBACK_SHAPE #define HB_NO_OT_KERN #define HB_NO_OT_LAYOUT_BLOCKLIST +#define HB_NO_AAT_LAYOUT_BLOCKLIST #define HB_NO_OT_SHAPE_FALLBACK #endif