diff --git a/src/hb-draw.cc b/src/hb-draw.cc index 7b50b2b1e..5eabb8329 100644 --- a/src/hb-draw.cc +++ b/src/hb-draw.cc @@ -119,20 +119,20 @@ hb_draw_funcs_set_close_path_func (hb_draw_funcs_t *funcs, } static void -_move_to_nil (hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, void *user_data HB_UNUSED) {} +_move_to_nil (float to_x HB_UNUSED, float to_y HB_UNUSED, void *user_data HB_UNUSED) {} static void -_line_to_nil (hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, void *user_data HB_UNUSED) {} +_line_to_nil (float to_x HB_UNUSED, float to_y HB_UNUSED, void *user_data HB_UNUSED) {} static void -_quadratic_to_nil (hb_position_t control_x HB_UNUSED, hb_position_t control_y HB_UNUSED, - hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, +_quadratic_to_nil (float control_x HB_UNUSED, float control_y HB_UNUSED, + float to_x HB_UNUSED, float to_y HB_UNUSED, void *user_data HB_UNUSED) {} static void -_cubic_to_nil (hb_position_t control1_x HB_UNUSED, hb_position_t control1_y HB_UNUSED, - hb_position_t control2_x HB_UNUSED, hb_position_t control2_y HB_UNUSED, - hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, +_cubic_to_nil (float control1_x HB_UNUSED, float control1_y HB_UNUSED, + float control2_x HB_UNUSED, float control2_y HB_UNUSED, + float to_x HB_UNUSED, float to_y HB_UNUSED, void *user_data HB_UNUSED) {} static void diff --git a/src/hb-draw.h b/src/hb-draw.h index 3649eee3a..8a4668fac 100644 --- a/src/hb-draw.h +++ b/src/hb-draw.h @@ -33,14 +33,14 @@ HB_BEGIN_DECLS -typedef void (*hb_draw_move_to_func_t) (hb_position_t to_x, hb_position_t to_y, void *user_data); -typedef void (*hb_draw_line_to_func_t) (hb_position_t to_x, hb_position_t to_y, void *user_data); -typedef void (*hb_draw_quadratic_to_func_t) (hb_position_t control_x, hb_position_t control_y, - hb_position_t to_x, hb_position_t to_y, +typedef void (*hb_draw_move_to_func_t) (float to_x, float to_y, void *user_data); +typedef void (*hb_draw_line_to_func_t) (float to_x, float to_y, void *user_data); +typedef void (*hb_draw_quadratic_to_func_t) (float control_x, float control_y, + float to_x, float to_y, void *user_data); -typedef void (*hb_draw_cubic_to_func_t) (hb_position_t control1_x, hb_position_t control1_y, - hb_position_t control2_x, hb_position_t control2_y, - hb_position_t to_x, hb_position_t to_y, +typedef void (*hb_draw_cubic_to_func_t) (float control1_x, float control1_y, + float control2_x, float control2_y, + float to_x, float to_y, void *user_data); typedef void (*hb_draw_close_path_func_t) (void *user_data); diff --git a/src/hb-draw.hh b/src/hb-draw.hh index 6cf30fc61..8b2dfbcd3 100644 --- a/src/hb-draw.hh +++ b/src/hb-draw.hh @@ -50,14 +50,14 @@ struct draw_helper_t } ~draw_helper_t () { end_path (); } - void move_to (hb_position_t x, hb_position_t y) + void move_to (float x, float y) { if (path_open) end_path (); current_x = path_start_x = x; current_y = path_start_y = y; } - void line_to (hb_position_t x, hb_position_t y) + void line_to (float x, float y) { if (equal_to_current (x, y)) return; if (!path_open) start_path (); @@ -67,8 +67,8 @@ struct draw_helper_t } void - quadratic_to (hb_position_t control_x, hb_position_t control_y, - hb_position_t to_x, hb_position_t to_y) + quadratic_to (float control_x, float control_y, + float to_x, float to_y) { if (equal_to_current (control_x, control_y) && equal_to_current (to_x, to_y)) return; @@ -86,9 +86,9 @@ struct draw_helper_t } void - cubic_to (hb_position_t control1_x, hb_position_t control1_y, - hb_position_t control2_x, hb_position_t control2_y, - hb_position_t to_x, hb_position_t to_y) + cubic_to (float control1_x, float control1_y, + float control2_x, float control2_y, + float to_x, float to_y) { if (equal_to_current (control1_x, control1_y) && equal_to_current (control2_x, control2_y) && @@ -113,7 +113,7 @@ struct draw_helper_t } protected: - bool equal_to_current (hb_position_t x, hb_position_t y) + bool equal_to_current (float x, float y) { return current_x == x && current_y == y; } void start_path () @@ -123,11 +123,11 @@ struct draw_helper_t funcs->move_to (path_start_x, path_start_y, user_data); } - hb_position_t path_start_x; - hb_position_t path_start_y; + float path_start_x; + float path_start_y; - hb_position_t current_x; - hb_position_t current_y; + float current_x; + float current_y; bool path_open; const hb_draw_funcs_t *funcs; diff --git a/src/hb-ot-cff1-table.cc b/src/hb-ot-cff1-table.cc index efaadbc4f..aac955ed6 100644 --- a/src/hb-ot-cff1-table.cc +++ b/src/hb-ot-cff1-table.cc @@ -457,14 +457,14 @@ struct cff1_path_param_t { point_t point = p; if (delta) point.move (*delta); - draw_helper->move_to (font->em_scalef_x (point.x.to_real ()), font->em_scalef_y (point.y.to_real ())); + draw_helper->move_to (font->em_fscalef_x (point.x.to_real ()), font->em_fscalef_y (point.y.to_real ())); } void line_to (const point_t &p) { point_t point = p; if (delta) point.move (*delta); - draw_helper->line_to (font->em_scalef_x (point.x.to_real ()), font->em_scalef_y (point.y.to_real ())); + draw_helper->line_to (font->em_fscalef_x (point.x.to_real ()), font->em_fscalef_y (point.y.to_real ())); } void cubic_to (const point_t &p1, const point_t &p2, const point_t &p3) @@ -476,9 +476,9 @@ struct cff1_path_param_t point2.move (*delta); point3.move (*delta); } - draw_helper->cubic_to (font->em_scalef_x (point1.x.to_real ()), font->em_scalef_y (point1.y.to_real ()), - font->em_scalef_x (point2.x.to_real ()), font->em_scalef_y (point2.y.to_real ()), - font->em_scalef_x (point3.x.to_real ()), font->em_scalef_y (point3.y.to_real ())); + draw_helper->cubic_to (font->em_fscalef_x (point1.x.to_real ()), font->em_fscalef_y (point1.y.to_real ()), + font->em_fscalef_x (point2.x.to_real ()), font->em_fscalef_y (point2.y.to_real ()), + font->em_fscalef_x (point3.x.to_real ()), font->em_fscalef_y (point3.y.to_real ())); } void end_path () { draw_helper->end_path (); } diff --git a/src/hb-ot-cff2-table.cc b/src/hb-ot-cff2-table.cc index 6da4d011d..3a90dcade 100644 --- a/src/hb-ot-cff2-table.cc +++ b/src/hb-ot-cff2-table.cc @@ -152,16 +152,16 @@ struct cff2_path_param_t } void move_to (const point_t &p) - { draw_helper->move_to (font->em_scalef_x (p.x.to_real ()), font->em_scalef_y (p.y.to_real ())); } + { draw_helper->move_to (font->em_fscalef_x (p.x.to_real ()), font->em_fscalef_y (p.y.to_real ())); } void line_to (const point_t &p) - { draw_helper->line_to (font->em_scalef_x (p.x.to_real ()), font->em_scalef_y (p.y.to_real ())); } + { draw_helper->line_to (font->em_fscalef_x (p.x.to_real ()), font->em_fscalef_y (p.y.to_real ())); } void cubic_to (const point_t &p1, const point_t &p2, const point_t &p3) { - draw_helper->cubic_to (font->em_scalef_x (p1.x.to_real ()), font->em_scalef_y (p1.y.to_real ()), - font->em_scalef_x (p2.x.to_real ()), font->em_scalef_y (p2.y.to_real ()), - font->em_scalef_x (p3.x.to_real ()), font->em_scalef_y (p3.y.to_real ())); + draw_helper->cubic_to (font->em_fscalef_x (p1.x.to_real ()), font->em_fscalef_y (p1.y.to_real ()), + font->em_fscalef_x (p2.x.to_real ()), font->em_fscalef_y (p2.y.to_real ()), + font->em_fscalef_x (p3.x.to_real ()), font->em_fscalef_y (p3.y.to_real ())); } protected: diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index 7cb5ada9a..bf0a9ec39 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -1194,7 +1194,7 @@ struct glyf if (is_on_curve) { first_oncurve = p; - draw_helper->move_to (font->em_scalef_x (p.x), font->em_scalef_y (p.y)); + draw_helper->move_to (font->em_fscalef_x (p.x), font->em_fscalef_y (p.y)); } else { @@ -1203,7 +1203,7 @@ struct glyf optional_point_t mid = first_offcurve.lerp (p, .5f); first_oncurve = mid; last_offcurve = p; - draw_helper->move_to (font->em_scalef_x (mid.x), font->em_scalef_y (mid.y)); + draw_helper->move_to (font->em_fscalef_x (mid.x), font->em_fscalef_y (mid.y)); } else first_offcurve = p; @@ -1215,22 +1215,22 @@ struct glyf { if (is_on_curve) { - draw_helper->quadratic_to (font->em_scalef_x (last_offcurve.x), font->em_scalef_y (last_offcurve.y), - font->em_scalef_x (p.x), font->em_scalef_y (p.y)); + draw_helper->quadratic_to (font->em_fscalef_x (last_offcurve.x), font->em_fscalef_y (last_offcurve.y), + font->em_fscalef_x (p.x), font->em_fscalef_y (p.y)); last_offcurve = optional_point_t (); } else { optional_point_t mid = last_offcurve.lerp (p, .5f); - draw_helper->quadratic_to (font->em_scalef_x (last_offcurve.x), font->em_scalef_y (last_offcurve.y), - font->em_scalef_x (mid.x), font->em_scalef_y (mid.y)); + draw_helper->quadratic_to (font->em_fscalef_x (last_offcurve.x), font->em_fscalef_y (last_offcurve.y), + font->em_fscalef_x (mid.x), font->em_fscalef_y (mid.y)); last_offcurve = p; } } else { if (is_on_curve) - draw_helper->line_to (font->em_scalef_x (p.x), font->em_scalef_y (p.y)); + draw_helper->line_to (font->em_fscalef_x (p.x), font->em_fscalef_y (p.y)); else last_offcurve = p; } @@ -1241,20 +1241,20 @@ struct glyf if (first_offcurve.has_data && last_offcurve.has_data) { optional_point_t mid = last_offcurve.lerp (first_offcurve, .5f); - draw_helper->quadratic_to (font->em_scalef_x (last_offcurve.x), font->em_scalef_y (last_offcurve.y), - font->em_scalef_x (mid.x), font->em_scalef_y (mid.y)); + draw_helper->quadratic_to (font->em_fscalef_x (last_offcurve.x), font->em_fscalef_y (last_offcurve.y), + font->em_fscalef_x (mid.x), font->em_fscalef_y (mid.y)); last_offcurve = optional_point_t (); /* now check the rest */ } if (first_offcurve.has_data && first_oncurve.has_data) - draw_helper->quadratic_to (font->em_scalef_x (first_offcurve.x), font->em_scalef_y (first_offcurve.y), - font->em_scalef_x (first_oncurve.x), font->em_scalef_y (first_oncurve.y)); + draw_helper->quadratic_to (font->em_fscalef_x (first_offcurve.x), font->em_fscalef_y (first_offcurve.y), + font->em_fscalef_x (first_oncurve.x), font->em_fscalef_y (first_oncurve.y)); else if (last_offcurve.has_data && first_oncurve.has_data) - draw_helper->quadratic_to (font->em_scalef_x (last_offcurve.x), font->em_scalef_y (last_offcurve.y), - font->em_scalef_x (first_oncurve.x), font->em_scalef_y (first_oncurve.y)); + draw_helper->quadratic_to (font->em_fscalef_x (last_offcurve.x), font->em_fscalef_y (last_offcurve.y), + font->em_fscalef_x (first_oncurve.x), font->em_fscalef_y (first_oncurve.y)); else if (first_oncurve.has_data) - draw_helper->line_to (font->em_scalef_x (first_oncurve.x), font->em_scalef_y (first_oncurve.y)); + draw_helper->line_to (font->em_fscalef_x (first_oncurve.x), font->em_fscalef_y (first_oncurve.y)); /* Getting ready for the next contour */ first_oncurve = first_offcurve = last_offcurve = optional_point_t (); diff --git a/src/main.cc b/src/main.cc index 96b7c3f63..82135fbeb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -136,33 +136,33 @@ struct user_data_t }; static void -move_to (hb_position_t to_x, hb_position_t to_y, user_data_t &user_data) +move_to (float to_x, float to_y, user_data_t &user_data) { - fprintf (user_data.f, "M%d,%d", to_x, user_data.ascender - to_y); + fprintf (user_data.f, "M%g,%g", to_x, user_data.ascender - to_y); } static void -line_to (hb_position_t to_x, hb_position_t to_y, user_data_t &user_data) +line_to (float to_x, float to_y, user_data_t &user_data) { - fprintf (user_data.f, "L%d,%d", to_x, user_data.ascender - to_y); + fprintf (user_data.f, "L%g,%g", to_x, user_data.ascender - to_y); } static void -quadratic_to (hb_position_t control_x, hb_position_t control_y, - hb_position_t to_x, hb_position_t to_y, +quadratic_to (float control_x, float control_y, + float to_x, float to_y, user_data_t &user_data) { - fprintf (user_data.f, "Q%d,%d %d,%d", control_x, user_data.ascender - control_y, + fprintf (user_data.f, "Q%g,%g %g,%g", control_x, user_data.ascender - control_y, to_x, user_data.ascender - to_y); } static void -cubic_to (hb_position_t control1_x, hb_position_t control1_y, - hb_position_t control2_x, hb_position_t control2_y, - hb_position_t to_x, hb_position_t to_y, +cubic_to (float control1_x, float control1_y, + float control2_x, float control2_y, + float to_x, float to_y, user_data_t &user_data) { - fprintf (user_data.f, "C%d,%d %d,%d %d,%d", control1_x, user_data.ascender - control1_y, + fprintf (user_data.f, "C%g,%g %g,%g %g,%g", control1_x, user_data.ascender - control1_y, control2_x, user_data.ascender - control2_y, to_x, user_data.ascender - to_y); }