[ot-glyph] noop->nil, fix close path
This commit is contained in:
parent
79fed9a1e4
commit
684ff3e0cd
|
@ -345,9 +345,9 @@ bool OT::cff1::accelerator_t::get_extents (hb_font_t *font, hb_codepoint_t glyph
|
|||
|
||||
struct cff1_path_param_t
|
||||
{
|
||||
void init (const OT::cff1::accelerator_t *cff_, hb_font_t *font_,
|
||||
const hb_ot_glyph_decompose_funcs_t *funcs_, void *user_data_,
|
||||
point_t *delta_)
|
||||
cff1_path_param_t (const OT::cff1::accelerator_t *cff_, hb_font_t *font_,
|
||||
const hb_ot_glyph_decompose_funcs_t *funcs_, void *user_data_,
|
||||
point_t *delta_)
|
||||
{
|
||||
path_open = false;
|
||||
cff = cff_;
|
||||
|
@ -356,6 +356,7 @@ struct cff1_path_param_t
|
|||
user_data = user_data_;
|
||||
delta = delta_;
|
||||
}
|
||||
~cff1_path_param_t () { end_path (); }
|
||||
|
||||
void start_path () { funcs->open_path (user_data); path_open = true; }
|
||||
void end_path () { if (path_open) funcs->close_path (user_data); path_open = false; }
|
||||
|
@ -457,8 +458,7 @@ bool _get_path (const OT::cff1::accelerator_t *cff, hb_font_t *font, hb_codepoin
|
|||
const byte_str_t str = (*cff->charStrings)[glyph];
|
||||
interp.env.init (str, *cff, fd);
|
||||
interp.env.set_in_seac (in_seac);
|
||||
cff1_path_param_t param;
|
||||
param.init (cff, font, funcs, user_data, delta);
|
||||
cff1_path_param_t param (cff, font, funcs, user_data, delta);
|
||||
if (unlikely (!interp.interpret (param))) return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -145,13 +145,14 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
|
|||
|
||||
struct cff2_path_param_t
|
||||
{
|
||||
void init (hb_font_t *font_, const hb_ot_glyph_decompose_funcs_t *funcs_, void *user_data_)
|
||||
cff2_path_param_t (hb_font_t *font_, const hb_ot_glyph_decompose_funcs_t *funcs_, void *user_data_)
|
||||
{
|
||||
path_open = false;
|
||||
font = font_;
|
||||
funcs = funcs_;
|
||||
user_data = user_data_;
|
||||
}
|
||||
~cff2_path_param_t () { end_path (); }
|
||||
|
||||
void start_path () { funcs->open_path (user_data); path_open = true; }
|
||||
void end_path () { if (path_open) funcs->close_path (user_data); path_open = false; }
|
||||
|
@ -223,8 +224,7 @@ bool OT::cff2::accelerator_t::get_path (hb_font_t *font, hb_codepoint_t glyph,
|
|||
cff2_cs_interpreter_t<cff2_cs_opset_path_t, cff2_path_param_t> interp;
|
||||
const byte_str_t str = (*charStrings)[glyph];
|
||||
interp.env.init (str, *this, fd, font->coords, font->num_coords);
|
||||
cff2_path_param_t param;
|
||||
param.init (font, funcs, user_data);
|
||||
cff2_path_param_t param (font, funcs, user_data);
|
||||
if (unlikely (!interp.interpret (param))) return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -135,23 +135,20 @@ hb_ot_glyph_decompose_funcs_set_close_path_func (hb_ot_glyph_decompose_funcs_t
|
|||
}
|
||||
|
||||
static void
|
||||
_move_to_noop (hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, void *user_data HB_UNUSED) {}
|
||||
_move_line_to_nil (hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, void *user_data HB_UNUSED) {}
|
||||
|
||||
static void
|
||||
_line_to_noop (hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, void *user_data HB_UNUSED) {}
|
||||
|
||||
static void
|
||||
_conic_to_noop (hb_position_t control_x HB_UNUSED, hb_position_t control_y HB_UNUSED,
|
||||
_conic_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,
|
||||
void *user_data HB_UNUSED) {}
|
||||
static void
|
||||
_cubic_to_noop (hb_position_t control1_x HB_UNUSED, hb_position_t control1_y HB_UNUSED,
|
||||
_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,
|
||||
void *user_data HB_UNUSED) {}
|
||||
|
||||
static void
|
||||
_open_close_path_noop (void *user_data HB_UNUSED) {}
|
||||
_open_close_path_nil (void *user_data HB_UNUSED) {}
|
||||
|
||||
/**
|
||||
* hb_ot_glyph_decompose_funcs_create:
|
||||
|
@ -167,12 +164,12 @@ hb_ot_glyph_decompose_funcs_create ()
|
|||
if (unlikely (!(funcs = hb_object_create<hb_ot_glyph_decompose_funcs_t> ())))
|
||||
return const_cast<hb_ot_glyph_decompose_funcs_t *> (&Null (hb_ot_glyph_decompose_funcs_t));
|
||||
|
||||
funcs->move_to = (hb_ot_glyph_decompose_move_to_func_t) _move_to_noop;
|
||||
funcs->line_to = (hb_ot_glyph_decompose_line_to_func_t) _line_to_noop;
|
||||
funcs->conic_to = (hb_ot_glyph_decompose_conic_to_func_t) _conic_to_noop;
|
||||
funcs->cubic_to = (hb_ot_glyph_decompose_cubic_to_func_t) _cubic_to_noop;
|
||||
funcs->open_path = (hb_ot_glyph_decompose_open_path_func_t) _open_close_path_noop;
|
||||
funcs->close_path = (hb_ot_glyph_decompose_close_path_func_t) _open_close_path_noop;
|
||||
funcs->move_to = (hb_ot_glyph_decompose_move_to_func_t) _move_line_to_nil;
|
||||
funcs->line_to = (hb_ot_glyph_decompose_line_to_func_t) _move_line_to_nil;
|
||||
funcs->conic_to = (hb_ot_glyph_decompose_conic_to_func_t) _conic_to_nil;
|
||||
funcs->cubic_to = (hb_ot_glyph_decompose_cubic_to_func_t) _cubic_to_nil;
|
||||
funcs->open_path = (hb_ot_glyph_decompose_open_path_func_t) _open_close_path_nil;
|
||||
funcs->close_path = (hb_ot_glyph_decompose_close_path_func_t) _open_close_path_nil;
|
||||
return funcs;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@ open_path (user_data_t *user_data HB_UNUSED) {}
|
|||
static void
|
||||
close_path (user_data_t *user_data)
|
||||
{
|
||||
if (!user_data->consumed) return; /* XXX: CFF tables are inserting an Z in the beginning, we should resolve it */
|
||||
user_data->consumed += snprintf (user_data->str + user_data->consumed,
|
||||
user_data->size - user_data->consumed,
|
||||
"Z");
|
||||
|
@ -154,9 +153,9 @@ test_hb_ot_glyph_cff1 (void)
|
|||
.consumed = 0
|
||||
};
|
||||
g_assert (hb_ot_glyph_decompose (font, 3, funcs, &user_data));
|
||||
char expected[] = "M203,367C227,440 248,512 268,588L272,588C293,512 314,440 338,367L369,267"
|
||||
"L172,267ZM3,0L88,0L151,200L390,200L452,0L541,0L319,656"
|
||||
"L225,656ZM300,653L342,694L201,861L143,806";
|
||||
char expected[] = "M203,367C227,440 248,512 268,588L272,588C293,512 314,440 338,367L369,267L172,267Z"
|
||||
"M3,0L88,0L151,200L390,200L452,0L541,0L319,656L225,656Z"
|
||||
"M300,653L342,694L201,861L143,806Z";
|
||||
g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1);
|
||||
|
||||
hb_font_destroy (font);
|
||||
|
@ -178,9 +177,9 @@ test_hb_ot_glyph_cff2 (void)
|
|||
g_assert (hb_ot_glyph_decompose (font, 3, funcs, &user_data));
|
||||
char expected[] = "M275,442C303,442 337,435 371,417L325,454L350,366"
|
||||
"C357,341 370,321 403,321C428,321 443,333 448,358"
|
||||
"C435,432 361,487 272,487C153,487 43,393 43,236C43,83 129,-13 266,-13"
|
||||
"C360,-13 424,33 451,116L427,128C396,78 345,50 287,50"
|
||||
"C193,50 126,119 126,245C126,373 188,442 275,442";
|
||||
"C435,432 361,487 272,487C153,487 43,393 43,236"
|
||||
"C43,83 129,-13 266,-13C360,-13 424,33 451,116L427,128"
|
||||
"C396,78 345,50 287,50C193,50 126,119 126,245C126,373 188,442 275,442Z";
|
||||
g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1);
|
||||
|
||||
hb_variation_t var;
|
||||
|
@ -195,10 +194,11 @@ test_hb_ot_glyph_cff2 (void)
|
|||
.consumed = 0
|
||||
};
|
||||
g_assert (hb_ot_glyph_decompose (font, 3, funcs, &user_data2));
|
||||
char expected2[] = "M323,448C356,448 380,441 411,427L333,469L339,401C343,322 379,297 420,297"
|
||||
"C458,297 480,314 492,352C486,433 412,501 303,501C148,501 25,406 25,241"
|
||||
"C25,70 143,-16 279,-16C374,-16 447,22 488,103L451,137C423,107 390,86 344,86"
|
||||
"C262,86 209,148 209,261C209,398 271,448 323,448";
|
||||
char expected2[] = "M323,448C356,448 380,441 411,427L333,469L339,401"
|
||||
"C343,322 379,297 420,297C458,297 480,314 492,352"
|
||||
"C486,433 412,501 303,501C148,501 25,406 25,241"
|
||||
"C25,70 143,-16 279,-16C374,-16 447,22 488,103L451,137"
|
||||
"C423,107 390,86 344,86C262,86 209,148 209,261C209,398 271,448 323,448Z";
|
||||
g_assert_cmpmem (str2, user_data2.consumed, expected2, sizeof (expected2) - 1);
|
||||
|
||||
hb_font_destroy (font);
|
||||
|
|
Loading…
Reference in New Issue