diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/text_server_adv/bitmap_font_adv.cpp | 14 | ||||
-rw-r--r-- | modules/text_server_adv/bitmap_font_adv.h | 3 | ||||
-rw-r--r-- | modules/text_server_adv/text_server_adv.cpp | 2 |
3 files changed, 15 insertions, 4 deletions
diff --git a/modules/text_server_adv/bitmap_font_adv.cpp b/modules/text_server_adv/bitmap_font_adv.cpp index 10c3732fd7..f743000bc1 100644 --- a/modules/text_server_adv/bitmap_font_adv.cpp +++ b/modules/text_server_adv/bitmap_font_adv.cpp @@ -175,8 +175,9 @@ static hb_bool_t hb_bmp_get_font_h_extents(hb_font_t *font, void *font_data, hb_ return true; } -static hb_font_funcs_t *_hb_bmp_get_font_funcs() { - hb_font_funcs_t *funcs = hb_font_funcs_create(); +static hb_font_funcs_t *funcs = nullptr; +void hb_bmp_create_font_funcs() { + funcs = hb_font_funcs_create(); hb_font_funcs_set_font_h_extents_func(funcs, hb_bmp_get_font_h_extents, nullptr, nullptr); //hb_font_funcs_set_font_v_extents_func (funcs, hb_bmp_get_font_v_extents, nullptr, nullptr); @@ -194,12 +195,17 @@ static hb_font_funcs_t *_hb_bmp_get_font_funcs() { //hb_font_funcs_set_glyph_from_name_func (funcs, hb_bmp_get_glyph_from_name, nullptr, nullptr); hb_font_funcs_make_immutable(funcs); +} - return funcs; +void hb_bmp_free_font_funcs() { + if (funcs != nullptr) { + hb_font_funcs_destroy(funcs); + funcs = nullptr; + } } static void _hb_bmp_font_set_funcs(hb_font_t *p_font, BitmapFontDataAdvanced *p_face, int p_size, bool p_unref) { - hb_font_set_funcs(p_font, _hb_bmp_get_font_funcs(), _hb_bmp_font_create(p_face, p_size, p_unref), _hb_bmp_font_destroy); + hb_font_set_funcs(p_font, funcs, _hb_bmp_font_create(p_face, p_size, p_unref), _hb_bmp_font_destroy); } hb_font_t *hb_bmp_font_create(BitmapFontDataAdvanced *p_face, int p_size, hb_destroy_func_t p_destroy) { diff --git a/modules/text_server_adv/bitmap_font_adv.h b/modules/text_server_adv/bitmap_font_adv.h index b2fe7f43af..cb1a726f76 100644 --- a/modules/text_server_adv/bitmap_font_adv.h +++ b/modules/text_server_adv/bitmap_font_adv.h @@ -33,6 +33,9 @@ #include "font_adv.h" +void hb_bmp_create_font_funcs(); +void hb_bmp_free_font_funcs(); + struct BitmapFontDataAdvanced : public FontDataAdvanced { _THREAD_SAFE_CLASS_ diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index d2f6369f08..a82251d5c1 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -2507,9 +2507,11 @@ void TextServerAdvanced::register_server() { } TextServerAdvanced::TextServerAdvanced() { + hb_bmp_create_font_funcs(); } TextServerAdvanced::~TextServerAdvanced() { + hb_bmp_free_font_funcs(); u_cleanup(); #ifndef ICU_STATIC_DATA if (icu_data != nullptr) { |