Fix HarfBuzz support on MS-Windows

* src/w32uniscribe.c [HAVE_HARFBUZZ]: Include hb-ot.h.
(fn_hb_ot_font_set_funcs, hb_ot_font_set_funcs): Define.
(w32hb_get_font): Call hb_ot_font_set_funcs after creating the
hb_font_t object, to make the code work with versions of
HarfBuzz before 2.0.0.  Problem reported by Stephen Leake
<stephen_leake@stephe-leake.org>.  Solution suggested by
Khaled Hosny <dr.khaled.hosny@gmail.com> in
https://lists.freedesktop.org/archives/harfbuzz/2019-July/007412.html.
This commit is contained in:
Eli Zaretskii 2019-07-25 19:47:56 +03:00
parent 9c1ecca333
commit 28d231dbbb

View file

@ -32,6 +32,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <usp10.h>
#ifdef HAVE_HARFBUZZ
# include <hb.h>
# include <hb-ot.h> /* for hb_ot_font_set_funcs */
# if GNUC_PREREQ (4, 3, 0)
# define bswap_32(v) __builtin_bswap32(v)
# else
@ -87,6 +88,7 @@ DEF_DLL_FN (hb_bool_t, hb_font_get_nominal_glyph,
(hb_font_t *, hb_codepoint_t, hb_codepoint_t *));
DEF_DLL_FN (hb_bool_t, hb_font_get_variation_glyph,
(hb_font_t *, hb_codepoint_t, hb_codepoint_t, hb_codepoint_t *));
DEF_DLL_FN (void, hb_ot_font_set_funcs, (hb_font_t *));
#define hb_blob_create fn_hb_blob_create
#define hb_face_create_for_tables fn_hb_face_create_for_tables
@ -97,6 +99,7 @@ DEF_DLL_FN (hb_bool_t, hb_font_get_variation_glyph,
#define hb_face_get_upem fn_hb_face_get_upem
#define hb_font_get_nominal_glyph fn_hb_font_get_nominal_glyph
#define hb_font_get_variation_glyph fn_hb_font_get_variation_glyph
#define hb_ot_font_set_funcs fn_hb_ot_font_set_funcs
#endif
/* Used by uniscribe_otf_capability. */
@ -1305,7 +1308,12 @@ w32hb_get_font (struct font *font, double *scale)
hb_face_t *hb_face =
hb_face_create_for_tables (w32hb_get_font_table, font_handle, NULL);
if (hb_face_get_glyph_count (hb_face) > 0)
hb_font = hb_font_create (hb_face);
{
hb_font = hb_font_create (hb_face);
/* This is needed for HarfBuzz before 2.0.0; it is the default
in later versions. */
hb_ot_font_set_funcs (hb_font);
}
struct uniscribe_font_info *uniscribe_font =
(struct uniscribe_font_info *) font;
@ -1486,6 +1494,7 @@ load_harfbuzz_funcs (HMODULE library)
LOAD_DLL_FN (library, hb_face_destroy);
LOAD_DLL_FN (library, hb_font_get_nominal_glyph);
LOAD_DLL_FN (library, hb_font_get_variation_glyph);
LOAD_DLL_FN (library, hb_ot_font_set_funcs);
return hbfont_init_w32_funcs (library);
}
#endif /* HAVE_HARFBUZZ */