More vertical
Starting to get there, but not without yet another round of changes. I think I know wheere to go now.
This commit is contained in:
parent
e609aeb1e2
commit
8b38faeede
@ -471,6 +471,34 @@ hb_font_get_glyph_origin_for_direction (hb_font_t *font,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
hb_font_add_glyph_origin_for_direction (hb_font_t *font,
|
||||
hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
hb_position_t origin_x, origin_y;
|
||||
|
||||
hb_font_get_glyph_origin_for_direction (font, glyph, direction, &origin_x, &origin_y);
|
||||
|
||||
*x += origin_x;
|
||||
*y += origin_y;
|
||||
}
|
||||
|
||||
void
|
||||
hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
|
||||
hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
hb_position_t origin_x, origin_y;
|
||||
|
||||
hb_font_get_glyph_origin_for_direction (font, glyph, direction, &origin_x, &origin_y);
|
||||
|
||||
*x -= origin_x;
|
||||
*y -= origin_y;
|
||||
}
|
||||
|
||||
void
|
||||
hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
|
||||
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
|
||||
@ -502,12 +530,8 @@ hb_font_get_glyph_extents_for_direction (hb_font_t *font,
|
||||
{
|
||||
hb_bool_t ret = hb_font_get_glyph_extents (font, glyph, extents);
|
||||
|
||||
if (ret) {
|
||||
hb_position_t origin_x, origin_y;
|
||||
hb_font_get_glyph_origin_for_direction (font, glyph, direction, &origin_x, &origin_y);
|
||||
extents->x_bearing += origin_x;
|
||||
extents->y_bearing += origin_y;
|
||||
}
|
||||
if (ret)
|
||||
hb_font_subtract_glyph_origin_for_direction (font, glyph, direction, &extents->x_bearing, &extents->y_bearing);
|
||||
}
|
||||
|
||||
hb_bool_t
|
||||
@ -518,12 +542,8 @@ hb_font_get_glyph_contour_point_for_direction (hb_font_t *font,
|
||||
{
|
||||
hb_bool_t ret = hb_font_get_glyph_contour_point (font, glyph, point_index, x, y);
|
||||
|
||||
if (ret) {
|
||||
hb_position_t origin_x, origin_y;
|
||||
hb_font_get_glyph_origin_for_direction (font, glyph, direction, &origin_x, &origin_y);
|
||||
*x += origin_x;
|
||||
*y += origin_y;
|
||||
}
|
||||
if (ret)
|
||||
hb_font_subtract_glyph_origin_for_direction (font, glyph, direction, x, y);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -275,6 +275,16 @@ hb_font_get_glyph_origin_for_direction (hb_font_t *font,
|
||||
hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y);
|
||||
void
|
||||
hb_font_add_glyph_origin_for_direction (hb_font_t *font,
|
||||
hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y);
|
||||
void
|
||||
hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
|
||||
hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y);
|
||||
|
||||
void
|
||||
hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
|
||||
|
14
src/hb-ft.cc
14
src/hb-ft.cc
@ -110,6 +110,8 @@ hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED,
|
||||
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
|
||||
return FALSE;
|
||||
|
||||
/* Note: FreeType's vertical metrics grows downward while other FreeType coordinates
|
||||
* have a Y growing upward. Hence the extra negation. */
|
||||
*y = -ft_face->glyph->metrics.vertAdvance;
|
||||
return TRUE;
|
||||
}
|
||||
@ -140,7 +142,16 @@ hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED,
|
||||
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
|
||||
return FALSE;
|
||||
|
||||
/* XXX */*y = ft_face->glyph->metrics.vertAdvance;
|
||||
/* Note: FreeType's vertical metrics grows downward while other FreeType coordinates
|
||||
* have a Y growing upward. Hence the extra negation. */
|
||||
*x = ft_face->glyph->metrics.horiBearingX - ft_face->glyph->metrics.vertBearingX;
|
||||
*y = ft_face->glyph->metrics.horiBearingY - (-ft_face->glyph->metrics.vertBearingY);
|
||||
|
||||
/* TODO ??
|
||||
if (glyph->format == FT_GLYPH_FORMAT_OUTLINE)
|
||||
FT_Vector_Transform (&vector, &scaled_font->unscaled->Current_Shape);
|
||||
*/
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -190,7 +201,6 @@ hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED,
|
||||
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
|
||||
return FALSE;
|
||||
|
||||
/* XXX: A few negations should be in order here, not sure. */
|
||||
extents->x_bearing = ft_face->glyph->metrics.horiBearingX;
|
||||
extents->y_bearing = ft_face->glyph->metrics.horiBearingY;
|
||||
extents->width = ft_face->glyph->metrics.width;
|
||||
|
@ -262,6 +262,10 @@ hb_position_default (hb_ot_shape_context_t *c)
|
||||
c->buffer->props.direction,
|
||||
&c->buffer->pos[i].x_advance,
|
||||
&c->buffer->pos[i].y_advance);
|
||||
hb_font_subtract_glyph_origin_for_direction (c->font, c->buffer->info[i].codepoint,
|
||||
c->buffer->props.direction,
|
||||
&c->buffer->pos[i].x_offset,
|
||||
&c->buffer->pos[i].y_offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user