diff --git a/util/font-options.hh b/util/font-options.hh index fd63a3ceb..84fe53634 100644 --- a/util/font-options.hh +++ b/util/font-options.hh @@ -51,7 +51,7 @@ struct font_options_t : face_options_t void add_options (option_parser_t *parser); - hb_font_t *get_font () const; + void post_parse (GError **error); hb_variation_t *variations = nullptr; unsigned int num_variations = 0; @@ -64,8 +64,7 @@ struct font_options_t : face_options_t char *font_funcs = nullptr; int ft_load_flags = 2; - private: - mutable hb_font_t *font = nullptr; + hb_font_t *font = nullptr; }; @@ -80,12 +79,10 @@ static struct supported_font_funcs_t { {"ot", hb_ot_font_set_funcs}, }; -hb_font_t * -font_options_t::get_font () const -{ - if (font) - return font; +void +font_options_t::post_parse (GError **error) +{ font = hb_font_create (face); if (font_size_x == FONT_SIZE_UPEM) @@ -137,8 +134,6 @@ font_options_t::get_font () const #ifdef HAVE_FREETYPE hb_ft_font_set_load_flags (font, ft_load_flags); #endif - - return font; } diff --git a/util/hb-ot-shape-closure.cc b/util/hb-ot-shape-closure.cc index 90f29d989..874ddd728 100644 --- a/util/hb-ot-shape-closure.cc +++ b/util/hb-ot-shape-closure.cc @@ -57,7 +57,7 @@ struct shape_closure_consumer_t void init (const font_options_t *font_opts) { glyphs = hb_set_create (); - font = hb_font_reference (font_opts->get_font ()); + font = hb_font_reference (font_opts->font); failed = false; buffer = hb_buffer_create (); } diff --git a/util/hb-shape.cc b/util/hb-shape.cc index 62ed23346..06bb0adac 100644 --- a/util/hb-shape.cc +++ b/util/hb-shape.cc @@ -49,7 +49,7 @@ struct output_buffer_t : output_options_t get_file_handle (); gs = g_string_new (nullptr); line_no = 0; - font = hb_font_reference (font_opts->get_font ()); + font = hb_font_reference (font_opts->font); if (!output_format) serialize_format = HB_BUFFER_SERIALIZE_FORMAT_TEXT; diff --git a/util/helper-cairo.hh b/util/helper-cairo.hh index 19651b23b..948747da5 100644 --- a/util/helper-cairo.hh +++ b/util/helper-cairo.hh @@ -79,7 +79,7 @@ void free_ft_library () static inline cairo_scaled_font_t * helper_cairo_create_scaled_font (const font_options_t *font_opts) { - hb_font_t *font = hb_font_reference (font_opts->get_font ()); + hb_font_t *font = hb_font_reference (font_opts->font); cairo_font_face_t *cairo_face; /* We cannot use the FT_Face from hb_font_t, as doing so will confuse hb_font_t because diff --git a/util/shape-consumer.hh b/util/shape-consumer.hh index 760756432..cbbac2202 100644 --- a/util/shape-consumer.hh +++ b/util/shape-consumer.hh @@ -42,7 +42,7 @@ struct shape_consumer_t : shape_options_t void init (const font_options_t *font_opts) { - font = hb_font_reference (font_opts->get_font ()); + font = hb_font_reference (font_opts->font); failed = false; buffer = hb_buffer_create (); diff --git a/util/view-cairo.hh b/util/view-cairo.hh index bfe4e2a0c..6e85b927f 100644 --- a/util/view-cairo.hh +++ b/util/view-cairo.hh @@ -100,7 +100,7 @@ view_cairo_t::render (const font_options_t *font_opts) int x_sign = font_opts->font_size_x < 0 ? -1 : +1; int y_sign = font_opts->font_size_y < 0 ? -1 : +1; - hb_font_t *font = font_opts->get_font(); + hb_font_t *font = font_opts->font; if (!have_font_extents) {