get_contour_point now takes glyph id before point_index.
get_kerning now takes a vector to fill-in.
static hb_bool_t
hb_font_get_contour_point_nil (hb_font_t *font HB_UNUSED,
const void *font_data HB_UNUSED,
- unsigned int point_index HB_UNUSED,
- hb_codepoint_t glyph HB_UNUSED,
- hb_position_t *x HB_UNUSED,
- hb_position_t *y HB_UNUSED,
+ hb_codepoint_t glyph,
+ unsigned int point_index,
+ hb_position_t *x,
+ hb_position_t *y,
const void *user_data HB_UNUSED)
{
if (font->parent) {
hb_bool_t ret;
ret = hb_font_get_contour_point (font->parent,
- point_index, glyph,
+ glyph, point_index,
x, y);
font->parent_scale_position (x, y);
return ret;
static void
hb_font_get_glyph_advance_nil (hb_font_t *font HB_UNUSED,
const void *font_data HB_UNUSED,
- hb_codepoint_t glyph HB_UNUSED,
- hb_position_t *x_advance HB_UNUSED,
- hb_position_t *y_advance HB_UNUSED,
+ hb_codepoint_t glyph,
+ hb_position_t *x_advance,
+ hb_position_t *y_advance,
const void *user_data HB_UNUSED)
{
if (font->parent) {
static void
hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
const void *font_data HB_UNUSED,
- hb_codepoint_t glyph HB_UNUSED,
- hb_glyph_extents_t *extents HB_UNUSED,
+ hb_codepoint_t glyph,
+ hb_glyph_extents_t *extents,
const void *user_data HB_UNUSED)
{
if (font->parent) {
static hb_codepoint_t
hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
const void *font_data HB_UNUSED,
- hb_codepoint_t unicode HB_UNUSED,
- hb_codepoint_t variation_selector HB_UNUSED,
+ hb_codepoint_t unicode,
+ hb_codepoint_t variation_selector,
const void *user_data HB_UNUSED)
{
if (font->parent)
return 0;
}
-static hb_position_t
+static void
hb_font_get_kerning_nil (hb_font_t *font HB_UNUSED,
const void *font_data HB_UNUSED,
- hb_codepoint_t first_glyph HB_UNUSED,
- hb_codepoint_t second_glyph HB_UNUSED,
+ hb_codepoint_t first_glyph,
+ hb_codepoint_t second_glyph,
+ hb_position_t *x_kern,
+ hb_position_t *y_kern,
const void *user_data HB_UNUSED)
{
if (font->parent) {
- hb_position_t ret;
- ret = hb_font_get_kerning (font->parent, first_glyph, second_glyph);
- ret = font->parent_scale_x_distance (ret);
- return ret;
+ hb_font_get_kerning (font->parent, first_glyph, second_glyph, x_kern, y_kern);
+ font->parent_scale_distance (x_kern, y_kern);
+ return;
}
- return 0;
+ *x_kern = *y_kern = 0;
}
hb_bool_t
hb_font_get_contour_point (hb_font_t *font,
- unsigned int point_index,
- hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y)
+ hb_codepoint_t glyph, unsigned int point_index,
+ hb_position_t *x, hb_position_t *y)
{
*x = 0; *y = 0;
return font->klass->get.contour_point (font, font->user_data,
- point_index,
- glyph, x, y,
+ glyph, point_index,
+ x, y,
font->klass->user_data.contour_point);
}
font->klass->user_data.glyph);
}
-hb_position_t
+void
hb_font_get_kerning (hb_font_t *font,
- hb_codepoint_t first_glyph, hb_codepoint_t second_glyph)
+ hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
+ hb_position_t *x_kern, hb_position_t *y_kern)
{
+ *x_kern = *y_kern = 0;
return font->klass->get.kerning (font, font->user_data,
first_glyph, second_glyph,
+ x_kern, y_kern,
font->klass->user_data.kerning);
}
typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, const void *font_data,
- unsigned int point_index, hb_codepoint_t glyph,
+ hb_codepoint_t glyph, unsigned int point_index,
hb_position_t *x, hb_position_t *y,
const void *user_data);
typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, const void *font_data,
typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, const void *font_data,
hb_codepoint_t unicode, hb_codepoint_t variation_selector,
const void *user_data);
-typedef hb_position_t (*hb_font_get_kerning_func_t) (hb_font_t *font, const void *font_data,
- hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
- const void *user_data);
+typedef void (*hb_font_get_kerning_func_t) (hb_font_t *font, const void *font_data,
+ hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
+ hb_position_t *x_kern, hb_position_t *y_kern,
+ const void *user_data);
void
hb_bool_t
hb_font_get_contour_point (hb_font_t *font,
- unsigned int point_index, hb_codepoint_t glyph,
+ hb_codepoint_t glyph, unsigned int point_index,
hb_position_t *x, hb_position_t *y);
void
hb_font_get_glyph (hb_font_t *font,
hb_codepoint_t unicode, hb_codepoint_t variation_selector);
-hb_position_t
+void
hb_font_get_kerning (hb_font_t *font,
- hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
+ hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
+ hb_position_t *x_kern, hb_position_t *y_kern);
/*
static hb_bool_t
hb_ft_get_contour_point (hb_font_t *font HB_UNUSED,
const void *font_data,
- unsigned int point_index,
hb_codepoint_t glyph,
+ unsigned int point_index,
hb_position_t *x,
hb_position_t *y,
const void *user_data HB_UNUSED)
return FT_Get_Char_Index (ft_face, unicode);
}
-static hb_position_t
+static void
hb_ft_get_kerning (hb_font_t *font HB_UNUSED,
const void *font_data,
hb_codepoint_t first_glyph,
hb_codepoint_t second_glyph,
+ hb_position_t *x_kern,
+ hb_position_t *y_kern,
const void *user_data HB_UNUSED)
{
FT_Face ft_face = (FT_Face) font_data;
/* TODO: Kern type? */
if (FT_Get_Kerning (ft_face, first_glyph, second_glyph, FT_KERNING_DEFAULT, &kerning))
- return 0;
+ return;
- return kerning.x;
+ *x_kern = kerning.x;
+ *y_kern = kerning.y;
}
static hb_font_funcs_t ft_ffuncs = {
inline int get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
{
hb_position_t x, y;
- if (hb_font_get_contour_point (font, caretValuePoint, glyph_id, &x, &y))
+ if (hb_font_get_contour_point (font, glyph_id, caretValuePoint, &x, &y))
return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
else
return 0;
hb_bool_t ret = false;
if (x_ppem || y_ppem)
- ret = hb_font_get_contour_point (font, anchorPoint, glyph_id, &cx, &cy);
+ ret = hb_font_get_contour_point (font, glyph_id, anchorPoint, &cx, &cy);
*x = x_ppem && ret ? cx : font->em_scale_x (xCoordinate);
*y = y_ppem && ret ? cy : font->em_scale_y (yCoordinate);
}
/* TODO Check for kern=0 */
unsigned int count = c->buffer->len;
for (unsigned int i = 1; i < count; i++) {
- hb_position_t kern, kern1, kern2;
- kern = hb_font_get_kerning (c->font, c->buffer->info[i - 1].codepoint, c->buffer->info[i].codepoint);
- kern1 = kern >> 1;
- kern2 = kern - kern1;
+ hb_position_t x_kern, y_kern, kern1, kern2;
+ hb_font_get_kerning (c->font, c->buffer->info[i - 1].codepoint, c->buffer->info[i].codepoint, &x_kern, &y_kern);
+
+ kern1 = x_kern >> 1;
+ kern2 = x_kern - kern1;
c->buffer->pos[i - 1].x_advance += kern1;
c->buffer->pos[i].x_advance += kern2;
c->buffer->pos[i].x_offset += kern2;
+
+ kern1 = y_kern >> 1;
+ kern2 = y_kern - kern1;
+ c->buffer->pos[i - 1].y_advance += kern1;
+ c->buffer->pos[i].y_advance += kern2;
+ c->buffer->pos[i].y_offset += kern2;
}
}