[coretext] Fix shaping with varying font size
Fixes https://github.com/libass/libass/issues/212
This commit is contained in:
parent
27847cab12
commit
061105ec44
|
@ -143,7 +143,6 @@ hb_coretext_face_get_cg_font (hb_face_t *face)
|
||||||
|
|
||||||
struct hb_coretext_shaper_font_data_t {
|
struct hb_coretext_shaper_font_data_t {
|
||||||
CTFontRef ct_font;
|
CTFontRef ct_font;
|
||||||
CGFloat x_mult, y_mult; /* From CT space to HB space. */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
hb_coretext_shaper_font_data_t *
|
hb_coretext_shaper_font_data_t *
|
||||||
|
@ -167,8 +166,6 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font)
|
||||||
|
|
||||||
if (font_size < 0)
|
if (font_size < 0)
|
||||||
font_size = -font_size;
|
font_size = -font_size;
|
||||||
data->x_mult = (CGFloat) font->x_scale / font_size;
|
|
||||||
data->y_mult = (CGFloat) font->y_scale / font_size;
|
|
||||||
data->ct_font = CTFontCreateWithGraphicsFont (face_data, font_size, NULL, NULL);
|
data->ct_font = CTFontCreateWithGraphicsFont (face_data, font_size, NULL, NULL);
|
||||||
if (unlikely (!data->ct_font)) {
|
if (unlikely (!data->ct_font)) {
|
||||||
DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
|
DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
|
||||||
|
@ -483,6 +480,10 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
||||||
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
|
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
|
||||||
hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
|
hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
|
||||||
|
|
||||||
|
CGFloat ct_font_size = CTFontGetSize (font_data->ct_font);
|
||||||
|
CGFloat x_mult = (CGFloat) font->x_scale / ct_font_size;
|
||||||
|
CGFloat y_mult = (CGFloat) font->y_scale / ct_font_size;
|
||||||
|
|
||||||
/* Attach marks to their bases, to match the 'ot' shaper.
|
/* Attach marks to their bases, to match the 'ot' shaper.
|
||||||
* Adapted from hb-ot-shape:hb_form_clusters().
|
* Adapted from hb-ot-shape:hb_form_clusters().
|
||||||
* Note that this only makes us be closer to the 'ot' shaper,
|
* Note that this only makes us be closer to the 'ot' shaper,
|
||||||
|
@ -1028,7 +1029,6 @@ resize_and_retry:
|
||||||
positions = position_buf;
|
positions = position_buf;
|
||||||
}
|
}
|
||||||
hb_glyph_info_t *info = run_info;
|
hb_glyph_info_t *info = run_info;
|
||||||
CGFloat x_mult = font_data->x_mult, y_mult = font_data->y_mult;
|
|
||||||
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
|
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
|
||||||
{
|
{
|
||||||
hb_position_t x_offset = (positions[0].x - advances_so_far) * x_mult;
|
hb_position_t x_offset = (positions[0].x - advances_so_far) * x_mult;
|
||||||
|
|
Loading…
Reference in New Issue