From c2901d60fa98874d4a36cf1ab57a03cb80fde038 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 28 Sep 2016 19:58:53 +0100 Subject: Uncouple font shaper data from harfbuzz. The fz_font structure now doesn't know anything about harfbuzz at all, it merely offers an abstract 'fz_shaper_data_t' entry. --- source/html/html-layout.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'source/html') diff --git a/source/html/html-layout.c b/source/html/html-layout.c index 2fe6de82..2211ea4f 100644 --- a/source/html/html-layout.c +++ b/source/html/html-layout.c @@ -837,7 +837,13 @@ static void init_string_walker(fz_context *ctx, string_walker *walker, hb_buffer walker->next_font = NULL; } -typedef void (fz_hb_font_destructor_t)(void *); +static void +destroy_hb_shaper_data(fz_context *ctx, void *handle) +{ + hb_lock(ctx); + hb_font_destroy(handle); + hb_unlock(ctx); +} static int walk_string(string_walker *walker) { @@ -899,12 +905,12 @@ static int walk_string(string_walker *walker) if (!quickshape) { - fz_hb_t *hb = fz_font_hb(walker->font); - if (hb->font == NULL) + fz_shaper_data_t *hb = fz_font_shaper_data(walker->font); + if (hb->shaper_handle == NULL) { Memento_startLeaking(); /* HarfBuzz leaks harmlessly */ - hb->destroy = (fz_hb_font_destructor_t *)hb_font_destroy; - hb->font = hb_ft_font_create(face, NULL); + hb->destroy = destroy_hb_shaper_data; + hb->shaper_handle = hb_ft_font_create(face, NULL); Memento_stopLeaking(); } @@ -912,7 +918,7 @@ static int walk_string(string_walker *walker) hb_buffer_guess_segment_properties(walker->hb_buf); Memento_stopLeaking(); - hb_shape(hb->font, walker->hb_buf, NULL, 0); + hb_shape(hb->shaper_handle, walker->hb_buf, NULL, 0); } walker->glyph_pos = hb_buffer_get_glyph_positions(walker->hb_buf, &walker->glyph_count); -- cgit v1.2.3