From 68b07475a7515166b308c21807f13a57fb68aedb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 8 Mar 2025 12:41:50 -0700 Subject: [PATCH] [font-funcs] Support HB_FONT_FUNCS env var --- src/hb-font.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/hb-font.cc b/src/hb-font.cc index 561f3c06a..6d4032aac 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1867,10 +1867,19 @@ hb_font_create (hb_face_t *face) { hb_font_t *font = _hb_font_create (face); -#ifndef HB_NO_OT_FONT - /* Install our in-house, very lightweight, funcs. */ - hb_ot_font_set_funcs (font); -#endif + static hb_atomic_ptr_t static_funcs_name; + const char *funcs_name = static_funcs_name.get_acquire (); + if (!funcs_name) + { + funcs_name = getenv ("HB_FONT_FUNCS"); + if (!funcs_name) + funcs_name = ""; + if (!static_funcs_name.cmpexch (nullptr, funcs_name)) + funcs_name = static_funcs_name.get_acquire (); + } + + if (unlikely (!hb_font_set_funcs_using (font, funcs_name))) + hb_font_set_funcs_using (font, nullptr); #ifndef HB_NO_VAR if (face && face->index >> 16) @@ -2310,7 +2319,9 @@ static struct supported_font_funcs_t { void (*func) (hb_font_t *); } supported_font_funcs[] = { +#ifndef HB_NO_OT_FONT {"ot", hb_ot_font_set_funcs}, +#endif #ifdef HAVE_FREETYPE {"ft", hb_ft_font_set_funcs}, #endif