summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/fitz/font.h1
-rw-r--r--source/fitz/font.c9
-rw-r--r--source/html/html-layout.c3
3 files changed, 10 insertions, 3 deletions
diff --git a/include/mupdf/fitz/font.h b/include/mupdf/fitz/font.h
index 2d3a8100..f45f32fc 100644
--- a/include/mupdf/fitz/font.h
+++ b/include/mupdf/fitz/font.h
@@ -37,6 +37,7 @@ struct fz_font_s
void *ft_face; /* has an FT_Face if used */
void *hb_font; /* hb_font for shaping */
+ void (*hb_destroy)(void *); /* Destructor for hb_font */
int ft_substitute; /* ... substitute metrics */
int ft_stretch; /* ... and stretch to match PDF metrics */
diff --git a/source/fitz/font.c b/source/fitz/font.c
index 07476235..6cc80d0e 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -156,9 +156,12 @@ fz_drop_font(fz_context *ctx, fz_font *font)
fz_free(ctx, font->bbox_table);
fz_free(ctx, font->width_table);
fz_free(ctx, font->advance_cache);
- hb_lock(ctx);
- hb_font_destroy(font->hb_font);
- hb_unlock(ctx);
+ if (font->hb_destroy && font->hb_font)
+ {
+ hb_lock(ctx);
+ font->hb_destroy(font->hb_font);
+ hb_unlock(ctx);
+ }
fz_free(ctx, font);
}
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index ae3f9f21..93f1905b 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -827,6 +827,8 @@ 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 int walk_string(string_walker *walker)
{
fz_context *ctx = walker->ctx;
@@ -885,6 +887,7 @@ static int walk_string(string_walker *walker)
if (walker->font->hb_font == NULL)
{
Memento_startLeaking(); /* HarfBuzz leaks harmlessly */
+ walker->font->hb_destroy = (fz_hb_font_destructor_t *)hb_font_destroy;
walker->font->hb_font = hb_ft_font_create(face, NULL);
Memento_stopLeaking();
}