Fix vertical glyph origin with hb-ot-font

This commit is contained in:
Behdad Esfahbod 2016-10-26 17:44:16 +02:00
parent b3b0816d5f
commit 9ee23c49a7

View File

@ -339,11 +339,8 @@ struct hb_font_t {
*y = y_scale; *y = y_scale;
} }
inline void get_glyph_origin_for_direction (hb_codepoint_t glyph, inline void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y) hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
{ {
if (!get_glyph_h_origin (glyph, x, y) && if (!get_glyph_h_origin (glyph, x, y) &&
get_glyph_v_origin (glyph, x, y)) get_glyph_v_origin (glyph, x, y))
@ -353,7 +350,8 @@ struct hb_font_t {
*x -= dx; *y -= dy; *x -= dx; *y -= dy;
} }
} }
else inline void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y)
{ {
if (!get_glyph_v_origin (glyph, x, y) && if (!get_glyph_v_origin (glyph, x, y) &&
get_glyph_h_origin (glyph, x, y)) get_glyph_h_origin (glyph, x, y))
@ -363,6 +361,15 @@ struct hb_font_t {
*x += dx; *y += dy; *x += dx; *y += dy;
} }
} }
inline void get_glyph_origin_for_direction (hb_codepoint_t glyph,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
get_glyph_h_origin_with_fallback (glyph, x, y);
else
get_glyph_v_origin_with_fallback (glyph, x, y);
} }
inline void add_glyph_h_origin (hb_codepoint_t glyph, inline void add_glyph_h_origin (hb_codepoint_t glyph,
@ -370,7 +377,7 @@ struct hb_font_t {
{ {
hb_position_t origin_x, origin_y; hb_position_t origin_x, origin_y;
get_glyph_h_origin (glyph, &origin_x, &origin_y); get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y);
*x += origin_x; *x += origin_x;
*y += origin_y; *y += origin_y;
@ -380,7 +387,7 @@ struct hb_font_t {
{ {
hb_position_t origin_x, origin_y; hb_position_t origin_x, origin_y;
get_glyph_v_origin (glyph, &origin_x, &origin_y); get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y);
*x += origin_x; *x += origin_x;
*y += origin_y; *y += origin_y;
@ -402,7 +409,7 @@ struct hb_font_t {
{ {
hb_position_t origin_x, origin_y; hb_position_t origin_x, origin_y;
get_glyph_h_origin (glyph, &origin_x, &origin_y); get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y);
*x -= origin_x; *x -= origin_x;
*y -= origin_y; *y -= origin_y;
@ -412,7 +419,7 @@ struct hb_font_t {
{ {
hb_position_t origin_x, origin_y; hb_position_t origin_x, origin_y;
get_glyph_v_origin (glyph, &origin_x, &origin_y); get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y);
*x -= origin_x; *x -= origin_x;
*y -= origin_y; *y -= origin_y;