From d59ae5836d1349b885db980cbb741da33caebfde Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Tue, 29 Oct 2019 21:30:04 +0330 Subject: [PATCH] [glyf] Refactor contour_bounds_t use to make its fields protected --- src/hb-ot-glyf-table.hh | 47 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index 6be1b3869..ab7edb97a 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -820,6 +820,31 @@ struct glyf bool empty () const { return (min_x >= max_x) || (min_y >= max_y); } + void get_extents (hb_font_t *font, hb_glyph_extents_t *extents) + { + if (min_x > max_x) + { + extents->width = 0; + extents->x_bearing = 0; + } + else + { + extents->x_bearing = font->em_scalef_x (min_x); + extents->width = font->em_scalef_x (max_x - min_x); + } + if (min_y > max_y) + { + extents->height = 0; + extents->y_bearing = 0; + } + else + { + extents->y_bearing = font->em_scalef_y (max_y); + extents->height = font->em_scalef_y (min_y - max_y); + } + } + + protected: float min_x, min_y, max_x, max_y; }; @@ -918,27 +943,7 @@ struct glyf contour_bounds_t bounds; for (unsigned int i = 0; i + PHANTOM_COUNT < all_points.length; i++) bounds.add (all_points[i]); - - if (bounds.min_x > bounds.max_x) - { - extents->width = 0; - extents->x_bearing = 0; - } - else - { - extents->x_bearing = font->em_scalef_x (bounds.min_x); - extents->width = font->em_scalef_x (bounds.max_x - bounds.min_x); - } - if (bounds.min_y > bounds.max_y) - { - extents->height = 0; - extents->y_bearing = 0; - } - else - { - extents->y_bearing = font->em_scalef_y (bounds.max_y); - extents->height = font->em_scalef_y (bounds.min_y - bounds.max_y); - } + bounds.get_extents (font, extents); } if (phantoms) for (unsigned int i = 0; i < PHANTOM_COUNT; i++)