[draw] Another try at a stable draw moveto semantic

This commit is contained in:
Behdad Esfahbod 2022-02-10 19:04:52 -06:00
parent 151f205819
commit 57aa8c3b3a
3 changed files with 11 additions and 7 deletions

View File

@ -97,7 +97,6 @@ struct hb_draw_funcs_t
float to_x, float to_y)
{
if (st.path_open) close_path (draw_data, st);
emit_move_to (draw_data, st, to_x, to_y);
st.current_x = to_x;
st.current_y = to_y;
}
@ -152,6 +151,7 @@ struct hb_draw_funcs_t
void start_path (void *draw_data, hb_draw_state_t &st)
{
assert (!st.path_open);
emit_move_to (draw_data, st, st.current_x, st.current_y);
st.path_open = true;
st.path_start_x = st.current_x;
st.path_start_y = st.current_y;

View File

@ -531,12 +531,6 @@ hb_draw_move_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED,
float x_scale = adaptor->x_scale;
float y_scale = adaptor->y_scale;
st->path_start_x *= x_scale;
st->path_start_y *= y_scale;
st->current_x *= x_scale;
st->current_y *= y_scale;
adaptor->draw_funcs->emit_move_to (adaptor->draw_data, *st,
x_scale * to_x, y_scale * to_y);
}

View File

@ -113,7 +113,17 @@ render_glyph (cairo_scaled_font_t *scaled_font,
hb_font_get_scale (font, &x_scale, &y_scale);
cairo_scale (cr, +1./x_scale, -1./y_scale);
#if 0
// Test sub-font scaling...
// TODO: Turn this into a util-wide feature...
hb_font_t *font2 = hb_font_create_sub_font (font);
signed x, y;
hb_font_get_scale (font, &x, &y);
hb_font_set_scale (font2, x/2, y/2);
hb_font_get_glyph_shape (font2, glyph, get_cairo_draw_funcs (), cr);
#else
hb_font_get_glyph_shape (font, glyph, get_cairo_draw_funcs (), cr);
#endif
cairo_fill (cr);
return CAIRO_STATUS_SUCCESS;