[draw] Merge consequent move-to commands of CFF/CFF2
This commit is contained in:
parent
86bd5a0ba1
commit
0cf050a7b1
|
@ -365,6 +365,8 @@ struct cff1_path_param_t
|
|||
void start_path ()
|
||||
{
|
||||
path_open = true;
|
||||
funcs->move_to (font->em_scalef_x (path_start_x), font->em_scalef_y (path_start_y),
|
||||
user_data);
|
||||
}
|
||||
bool is_path_open () const { return path_open; }
|
||||
|
||||
|
@ -374,8 +376,6 @@ struct cff1_path_param_t
|
|||
if (delta) point.move (*delta);
|
||||
path_last_x = path_start_x = point.x.to_real ();
|
||||
path_last_y = path_start_y = point.y.to_real ();
|
||||
funcs->move_to (font->em_scalef_x (path_start_x), font->em_scalef_y (path_start_y),
|
||||
user_data);
|
||||
}
|
||||
|
||||
void line_to (const point_t &p)
|
||||
|
|
|
@ -161,6 +161,8 @@ struct cff2_path_param_t
|
|||
void start_path ()
|
||||
{
|
||||
path_open = true;
|
||||
funcs->move_to (font->em_scalef_x (path_start_x), font->em_scalef_y (path_start_y),
|
||||
user_data);
|
||||
}
|
||||
bool is_path_open () const { return path_open; }
|
||||
|
||||
|
@ -168,8 +170,6 @@ struct cff2_path_param_t
|
|||
{
|
||||
path_last_x = path_start_x = p.x.to_real ();
|
||||
path_last_y = path_start_y = p.y.to_real ();
|
||||
funcs->move_to (font->em_scalef_x (path_start_x), font->em_scalef_y (path_start_y),
|
||||
user_data);
|
||||
}
|
||||
|
||||
void line_to (const point_t &p)
|
||||
|
@ -211,9 +211,6 @@ struct cff2_path_param_t
|
|||
hb_font_t *font;
|
||||
const hb_draw_funcs_t *funcs;
|
||||
void *user_data;
|
||||
point_t *delta;
|
||||
|
||||
const OT::cff2::accelerator_t *cff;
|
||||
};
|
||||
|
||||
struct cff2_path_procs_path_t : path_procs_t<cff2_path_procs_path_t, cff2_cs_interp_env_t, cff2_path_param_t>
|
||||
|
|
Binary file not shown.
|
@ -243,7 +243,6 @@ test_hb_draw_cff1 (void)
|
|||
.consumed = 0
|
||||
};
|
||||
g_assert (hb_font_draw_glyph (font, 3, funcs, &user_data));
|
||||
puts (str);
|
||||
char expected[] = "M203,367C227,440 248,512 268,588L272,588C293,512 314,440 338,367L369,267L172,267L203,367Z"
|
||||
"M3,0L88,0L151,200L390,200L452,0L541,0L319,656L225,656L3,0Z"
|
||||
"M300,653L342,694L201,861L143,806L300,653Z";
|
||||
|
@ -763,6 +762,7 @@ test_hb_draw_stroking (void)
|
|||
.size = sizeof (str)
|
||||
};
|
||||
{
|
||||
/* See https://github.com/google/skia/blob/d38f00a1/gm/stroketext.cpp#L115-L124 */
|
||||
hb_face_t *face = hb_test_open_font_file ("fonts/Stroking.ttf");
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
hb_face_destroy (face);
|
||||
|
@ -800,6 +800,30 @@ test_hb_draw_stroking (void)
|
|||
"Q256,1342 256,1528Z";
|
||||
g_assert_cmpmem (str, user_data.consumed, expected2, sizeof (expected2) - 1);
|
||||
|
||||
hb_font_destroy (font);
|
||||
}
|
||||
{
|
||||
/* https://github.com/google/skia/blob/d38f00a1/gm/stroketext.cpp#L131-L138 */
|
||||
hb_face_t *face = hb_test_open_font_file ("fonts/Stroking.otf");
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
hb_face_destroy (face);
|
||||
|
||||
user_data.consumed = 0;
|
||||
g_assert (hb_font_draw_glyph (font, 4, funcs, &user_data));
|
||||
char expected[] = "M397,372L397,372Z" /* TODO: Do we like to fold this path? */
|
||||
"M106,372C106,532 237,662 397,662C557,662 688,532 688,372C688,212 557,81 397,81C237,81 106,212 106,372Z"
|
||||
"M62,373C62,188 212,39 397,39C582,39 731,188 731,373C731,558 582,708 397,708C212,708 62,558 62,373Z";
|
||||
g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1);
|
||||
|
||||
user_data.consumed = 0;
|
||||
g_assert (hb_font_draw_glyph (font, 5, funcs, &user_data));
|
||||
/* Fold consequent move-to commands */
|
||||
char expected2[] = "M106,372C106,532 237,662 397,662C557,662 688,532 688,372"
|
||||
"C688,212 557,81 397,81C237,81 106,212 106,372ZM62,373"
|
||||
"C62,188 212,39 397,39C582,39 731,188 731,373"
|
||||
"C731,558 582,708 397,708C212,708 62,558 62,373Z";
|
||||
g_assert_cmpmem (str, user_data.consumed, expected2, sizeof (expected2) - 1);
|
||||
|
||||
hb_font_destroy (font);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue