From c988b119994ef78d400bc7d3139785312da0be75 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 2 Aug 2018 20:04:37 -0700 Subject: [PATCH] Move code around --- src/hb-ot-font.cc | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 8b41d4e74..48934b1b7 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -41,6 +41,30 @@ struct hb_ot_font_t { + inline void init (hb_face_t *face) + { + cmap.init (face); + h_metrics.init (face); + v_metrics.init (face, h_metrics.ascender - h_metrics.descender); /* TODO Can we do this lazily? */ + + this->face = face; + glyf.init (); + cbdt.init (); + post.init (); + kern.init (); + } + inline void fini (void) + { + cmap.fini (); + h_metrics.fini (); + v_metrics.fini (); + + glyf.fini (); + cbdt.fini (); + post.fini (); + kern.fini (); + } + OT::cmap::accelerator_t cmap; OT::hmtx::accelerator_t h_metrics; OT::vmtx::accelerator_t v_metrics; @@ -61,14 +85,7 @@ _hb_ot_font_create (hb_face_t *face) if (unlikely (!ot_font)) return nullptr; - ot_font->cmap.init (face); - ot_font->h_metrics.init (face); - ot_font->v_metrics.init (face, ot_font->h_metrics.ascender - ot_font->h_metrics.descender); /* TODO Can we do this lazily? */ - ot_font->face = face; - ot_font->glyf.init (); - ot_font->cbdt.init (); - ot_font->post.init (); - ot_font->kern.init (); + ot_font->init (face); return ot_font; } @@ -78,13 +95,7 @@ _hb_ot_font_destroy (void *data) { hb_ot_font_t *ot_font = (hb_ot_font_t *) data; - ot_font->cmap.fini (); - ot_font->h_metrics.fini (); - ot_font->v_metrics.fini (); - ot_font->glyf.fini (); - ot_font->cbdt.fini (); - ot_font->post.fini (); - ot_font->kern.fini (); + ot_font->fini (); free (ot_font); }