Starting to get there, but not without yet another round of changes.
I think I know wheere to go now.
}
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,
hb_direction_t direction,
{
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
{
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;
}
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,
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;
}
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;
}
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;
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);
}
}