diff --git a/src/hb-cff-interp-cs-common.hh b/src/hb-cff-interp-cs-common.hh index dad7f6ddd..965603f96 100644 --- a/src/hb-cff-interp-cs-common.hh +++ b/src/hb-cff-interp-cs-common.hh @@ -408,21 +408,21 @@ struct PathProcs const Number &dy = env.argStack.pop (); const Number &dx = env.argStack.pop (); pt1.move (dx, dy); - env.moveto (pt1); + PATH::moveto (env, param, pt1); } static inline void hmoveto (ENV &env, PARAM& param) { Point pt1 = env.get_pt (); pt1.move_x (env.argStack.pop ()); - env.moveto (pt1); + PATH::moveto (env, param, pt1); } static inline void vmoveto (ENV &env, PARAM& param) { Point pt1 = env.get_pt (); pt1.move_y (env.argStack.pop ()); - env.moveto (pt1); + PATH::moveto (env, param, pt1); } static inline void rlineto (ENV &env, PARAM& param) diff --git a/src/hb-ot-cff1-table.cc b/src/hb-ot-cff1-table.cc index 93fc47cc0..e14c9314a 100644 --- a/src/hb-ot-cff1-table.cc +++ b/src/hb-ot-cff1-table.cc @@ -136,12 +136,17 @@ struct ExtentsParam { inline void init (void) { + path_open = false; min_x.set_int (0x7FFFFFFF); min_y.set_int (0x7FFFFFFF); max_x.set_int (-0x80000000); max_y.set_int (-0x80000000); } + inline void start_path (void) { path_open = true; } + inline void end_path (void) { path_open = false; } + inline bool is_path_open (void) const { return path_open; } + inline void update_bounds (const Point &pt) { if (pt.x < min_x) min_x = pt.x; @@ -150,6 +155,7 @@ struct ExtentsParam if (pt.y > max_y) max_y = pt.y; } + bool path_open; Number min_x; Number min_y; Number max_x; @@ -158,16 +164,33 @@ struct ExtentsParam struct CFF1PathProcs_Extents : PathProcs { + static inline void moveto (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt) + { + param.end_path (); + env.moveto (pt); + } + static inline void line (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt1) { - param.update_bounds (env.get_pt ()); + if (!param.is_path_open ()) + { + param.start_path (); + param.update_bounds (env.get_pt ()); + } env.moveto (pt1); param.update_bounds (env.get_pt ()); } static inline void curve (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt1, const Point &pt2, const Point &pt3) { - param.update_bounds (env.get_pt ()); + if (!param.is_path_open ()) + { + param.start_path (); + param.update_bounds (env.get_pt ()); + } + /* include control points */ + param.update_bounds (pt1); + param.update_bounds (pt2); env.moveto (pt3); param.update_bounds (env.get_pt ()); }