[font] Respect subfont slant setting in hb-draw

Fixes https://github.com/harfbuzz/harfbuzz/issues/3890
This commit is contained in:
Behdad Esfahbod 2022-11-23 16:31:37 -07:00
parent 2e9b270a49
commit 060ecac949
1 changed files with 20 additions and 14 deletions

View File

@ -518,6 +518,7 @@ typedef struct hb_font_get_glyph_shape_default_adaptor_t {
void *draw_data;
float x_scale;
float y_scale;
float slant;
} hb_font_get_glyph_shape_default_adaptor_t;
static void
@ -530,9 +531,10 @@ hb_draw_move_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED,
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
float x_scale = adaptor->x_scale;
float y_scale = adaptor->y_scale;
float slant = adaptor->slant;
adaptor->draw_funcs->emit_move_to (adaptor->draw_data, *st,
x_scale * to_x, y_scale * to_y);
x_scale * to_x + slant * to_y, y_scale * to_y);
}
static void
@ -544,12 +546,13 @@ hb_draw_line_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
float x_scale = adaptor->x_scale;
float y_scale = adaptor->y_scale;
float slant = adaptor->slant;
st->current_x *= x_scale;
st->current_y *= y_scale;
st->current_x = st->current_x * x_scale + st->current_y * slant;
st->current_y = st->current_y * y_scale;
adaptor->draw_funcs->emit_line_to (adaptor->draw_data, *st,
x_scale * to_x, y_scale * to_y);
x_scale * to_x + slant * to_y, y_scale * to_y);
}
static void
@ -562,13 +565,14 @@ hb_draw_quadratic_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
float x_scale = adaptor->x_scale;
float y_scale = adaptor->y_scale;
float slant = adaptor->slant;
st->current_x *= x_scale;
st->current_y *= y_scale;
st->current_x = st->current_x * x_scale + st->current_y * slant;
st->current_y = st->current_y * y_scale;
adaptor->draw_funcs->emit_quadratic_to (adaptor->draw_data, *st,
x_scale * control_x, y_scale * control_y,
x_scale * to_x, y_scale * to_y);
x_scale * control_x + slant * control_y, y_scale * control_y,
x_scale * to_x + slant * to_y, y_scale * to_y);
}
static void
@ -582,14 +586,15 @@ hb_draw_cubic_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
float x_scale = adaptor->x_scale;
float y_scale = adaptor->y_scale;
float slant = adaptor->slant;
st->current_x *= x_scale;
st->current_y *= y_scale;
st->current_x = st->current_x * x_scale + st->current_y * slant;
st->current_y = st->current_y * y_scale;
adaptor->draw_funcs->emit_cubic_to (adaptor->draw_data, *st,
x_scale * control1_x, y_scale * control1_y,
x_scale * control2_x, y_scale * control2_y,
x_scale * to_x, y_scale * to_y);
x_scale * control1_x + slant * control1_y, y_scale * control1_y,
x_scale * control2_x + slant * control2_y, y_scale * control2_y,
x_scale * to_x + slant * to_y, y_scale * to_y);
}
static void
@ -624,7 +629,8 @@ hb_font_get_glyph_shape_default (hb_font_t *font,
draw_funcs,
draw_data,
(float) font->x_scale / (float) font->parent->x_scale,
(float) font->y_scale / (float) font->parent->y_scale
(float) font->y_scale / (float) font->parent->y_scale,
(font->slant - font->parent->slant) * (float) font->x_scale / (float) font->parent->y_scale
};
font->parent->get_glyph_shape (glyph,