diff --git a/util/face-options.hh b/util/face-options.hh index eae6d0dd9..9c8d40f2c 100644 --- a/util/face-options.hh +++ b/util/face-options.hh @@ -48,12 +48,10 @@ struct face_options_t ~cache_t () { g_free (font_path); - hb_blob_destroy (blob); hb_face_destroy (face); } char *font_path = nullptr; - hb_blob_t *blob = nullptr; unsigned face_index = (unsigned) -1; hb_face_t *face = nullptr; } cache; @@ -61,7 +59,6 @@ struct face_options_t char *font_file = nullptr; unsigned face_index = 0; - hb_blob_t *blob = nullptr; hb_face_t *face = nullptr; }; @@ -92,34 +89,26 @@ face_options_t::post_parse (GError **error) #endif } - if (!cache.font_path || 0 != strcmp (cache.font_path, font_path)) + if (!cache.font_path || + 0 != strcmp (cache.font_path, font_path) || + cache.face_index != face_index) { - hb_blob_destroy (cache.blob); - cache.blob = hb_blob_create_from_file_or_fail (font_path); + hb_face_destroy (cache.face); + cache.face = hb_face_create_from_file_or_fail (font_path, + face_index); + cache.face_index = face_index; free ((char *) cache.font_path); cache.font_path = g_strdup (font_path); - if (!cache.blob) + if (!cache.face) { g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, - "%s: Failed reading file", font_path); + "%s: Failed loading font face", font_path); return; } - - hb_face_destroy (cache.face); - cache.face = nullptr; - cache.face_index = (unsigned) -1; } - if (cache.face_index != face_index) - { - hb_face_destroy (cache.face); - cache.face = hb_face_create (cache.blob, face_index); - cache.face_index = face_index; - } - - blob = cache.blob; face = cache.face; } diff --git a/util/hb-info.cc b/util/hb-info.cc index 49bc96304..0bfc2e9ed 100644 --- a/util/hb-info.cc +++ b/util/hb-info.cc @@ -349,7 +349,9 @@ struct info_t : void _show_face_count () { + hb_blob_t *blob = hb_face_reference_table (face, HB_TAG_NONE); printf ("Face count: %u\n", hb_face_count (blob)); + hb_blob_destroy (blob); } void diff --git a/util/helper-cairo-ft.hh b/util/helper-cairo-ft.hh index 8ec372812..386cd9e0a 100644 --- a/util/helper-cairo-ft.hh +++ b/util/helper-cairo-ft.hh @@ -43,13 +43,6 @@ void free_ft_library () } #endif -static void -_release_blob (void *arg) -{ - FT_Face ft_face = (FT_Face) arg; - hb_blob_destroy ((hb_blob_t *) ft_face->generic.data); -} - static inline cairo_font_face_t * helper_cairo_create_ft_font_face (const font_options_t *font_opts) { @@ -68,15 +61,11 @@ helper_cairo_create_ft_font_face (const font_options_t *font_opts) #endif } - unsigned int blob_length; - const char *blob_data = hb_blob_get_data (font_opts->blob, &blob_length); - - if (FT_New_Memory_Face (ft_library, - (const FT_Byte *) blob_data, - blob_length, - font_opts->face_index, - &ft_face)) - fail (false, "FT_New_Memory_Face fail"); + if (FT_New_Face (ft_library, + font_opts->font_file, + font_opts->face_index, + &ft_face)) + fail (false, "FT_New_Face fail"); } if (!ft_face) { @@ -87,9 +76,6 @@ helper_cairo_create_ft_font_face (const font_options_t *font_opts) } else { - ft_face->generic.data = hb_blob_reference (font_opts->blob); - ft_face->generic.finalizer = _release_blob; - #if !defined(HB_NO_VAR) && defined(HAVE_FT_SET_VAR_BLEND_COORDINATES) unsigned int num_coords; const float *coords = hb_font_get_var_coords_design (font_opts->font, &num_coords); diff --git a/util/test-hb-subset-parsing.c b/util/test-hb-subset-parsing.c index b6b923a79..a0348d00d 100644 --- a/util/test-hb-subset-parsing.c +++ b/util/test-hb-subset-parsing.c @@ -7,11 +7,8 @@ static hb_face_t* open_font(const char* path) { - hb_blob_t *blob = hb_blob_create_from_file_or_fail (path); - g_assert(blob); - hb_face_t* face = hb_face_create(blob, 0); - hb_blob_destroy(blob); - + hb_face_t *face = hb_face_create_from_file_or_fail (path, 0); + g_assert (face); return face; }