[API] One last font-funcs API change

Now that vertical text works correctly, I'm doing a last round
modification of the font-funcs API to simplify.  Expect no more
changes around here.
This commit is contained in:
Behdad Esfahbod 2011-05-25 11:27:33 -04:00
parent d31691296f
commit 2d8ebcb9d0
5 changed files with 91 additions and 140 deletions

View File

@ -56,40 +56,28 @@ hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
return FALSE; return FALSE;
} }
static void static hb_position_t
hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *advance,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent)
hb_font_get_glyph_h_advance (font->parent, return font->parent_scale_x_distance (hb_font_get_glyph_h_advance (font->parent, glyph));
glyph,
advance);
*advance = font->parent_scale_x_distance (*advance);
return;
}
*advance = font->x_scale; return font->x_scale;
} }
static void static hb_position_t
hb_font_get_glyph_v_advance_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_v_advance_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *advance,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent)
hb_font_get_glyph_v_advance (font->parent, return font->parent_scale_y_distance (hb_font_get_glyph_v_advance (font->parent, glyph));
glyph,
advance);
*advance = font->parent_scale_y_distance (*advance);
return;
}
*advance = font->y_scale; return font->y_scale;
} }
static hb_bool_t static hb_bool_t
@ -134,42 +122,30 @@ hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
return FALSE; return FALSE;
} }
static void static hb_position_t
hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t left_glyph, hb_codepoint_t left_glyph,
hb_codepoint_t right_glyph, hb_codepoint_t right_glyph,
hb_position_t *kerning,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent)
hb_font_get_glyph_h_kerning (font->parent, return font->parent_scale_x_distance (hb_font_get_glyph_h_kerning (font->parent, left_glyph, right_glyph));
left_glyph, right_glyph,
kerning);
*kerning = font->parent_scale_x_distance (*kerning);
return;
}
*kerning = 0; return 0;
} }
static void static hb_position_t
hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t top_glyph, hb_codepoint_t top_glyph,
hb_codepoint_t bottom_glyph, hb_codepoint_t bottom_glyph,
hb_position_t *kerning,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent)
hb_font_get_glyph_v_kerning (font->parent, return font->parent_scale_y_distance (hb_font_get_glyph_v_kerning (font->parent, top_glyph, bottom_glyph));
top_glyph, bottom_glyph,
kerning);
*kerning = font->parent_scale_y_distance (*kerning);
return;
}
*kerning = 0; return 0;
} }
static hb_bool_t static hb_bool_t
@ -340,26 +316,22 @@ hb_font_get_glyph (hb_font_t *font,
font->klass->user_data.glyph); font->klass->user_data.glyph);
} }
void hb_position_t
hb_font_get_glyph_h_advance (hb_font_t *font, hb_font_get_glyph_h_advance (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph)
hb_position_t *advance)
{ {
*advance = 0; return font->klass->get.glyph_h_advance (font, font->user_data,
font->klass->get.glyph_h_advance (font, font->user_data, glyph,
glyph, advance, font->klass->user_data.glyph_h_advance);
font->klass->user_data.glyph_h_advance);
} }
void hb_position_t
hb_font_get_glyph_v_advance (hb_font_t *font, hb_font_get_glyph_v_advance (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph)
hb_position_t *advance)
{ {
*advance = 0; return font->klass->get.glyph_v_advance (font, font->user_data,
font->klass->get.glyph_v_advance (font, font->user_data, glyph,
glyph, advance, font->klass->user_data.glyph_v_advance);
font->klass->user_data.glyph_v_advance);
} }
hb_bool_t hb_bool_t
@ -384,27 +356,21 @@ hb_font_get_glyph_v_origin (hb_font_t *font,
font->klass->user_data.glyph_v_origin); font->klass->user_data.glyph_v_origin);
} }
void hb_position_t
hb_font_get_glyph_h_kerning (hb_font_t *font, hb_font_get_glyph_h_kerning (hb_font_t *font,
hb_codepoint_t left_glyph, hb_codepoint_t right_glyph, hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
hb_position_t *kerning)
{ {
*kerning = 0;
return font->klass->get.glyph_h_kerning (font, font->user_data, return font->klass->get.glyph_h_kerning (font, font->user_data,
left_glyph, right_glyph, left_glyph, right_glyph,
kerning,
font->klass->user_data.glyph_h_kerning); font->klass->user_data.glyph_h_kerning);
} }
void hb_position_t
hb_font_get_glyph_v_kerning (hb_font_t *font, hb_font_get_glyph_v_kerning (hb_font_t *font,
hb_codepoint_t left_glyph, hb_codepoint_t right_glyph, hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
hb_position_t *kerning)
{ {
*kerning = 0;
return font->klass->get.glyph_v_kerning (font, font->user_data, return font->klass->get.glyph_v_kerning (font, font->user_data,
left_glyph, right_glyph, left_glyph, right_glyph,
kerning,
font->klass->user_data.glyph_v_kerning); font->klass->user_data.glyph_v_kerning);
} }
@ -442,11 +408,11 @@ hb_font_get_glyph_advance_for_direction (hb_font_t *font,
hb_position_t *x, hb_position_t *y) hb_position_t *x, hb_position_t *y)
{ {
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
*x = hb_font_get_glyph_h_advance (font, glyph);
*y = 0; *y = 0;
hb_font_get_glyph_h_advance (font, glyph, x);
} else { } else {
*x = 0; *x = 0;
hb_font_get_glyph_v_advance (font, glyph, y); *y = hb_font_get_glyph_v_advance (font, glyph);
} }
} }
@ -455,10 +421,7 @@ guess_v_origin_minus_h_origin (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y) hb_position_t *x, hb_position_t *y)
{ {
*x = *y = 0; *x = hb_font_get_glyph_h_advance (font, glyph) / 2;
hb_font_get_glyph_h_advance (font, glyph, x);
*x /= 2;
/* TODO use font_metics.ascent */ /* TODO use font_metics.ascent */
*y = font->y_scale; *y = font->y_scale;
@ -523,11 +486,11 @@ hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
hb_position_t *x, hb_position_t *y) hb_position_t *x, hb_position_t *y)
{ {
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
*x = hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph);
*y = 0; *y = 0;
hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph, x);
} else { } else {
*x = 0; *x = 0;
hb_font_get_glyph_v_kerning (font, first_glyph, second_glyph, y); *y = hb_font_get_glyph_v_kerning (font, first_glyph, second_glyph);
} }
} }

View File

@ -142,10 +142,9 @@ typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data,
void *user_data); void *user_data);
typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data, typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *advance, void *user_data);
void *user_data);
typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t; typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t; typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
@ -156,10 +155,9 @@ typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *fon
typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t; typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t; typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
typedef void (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data, typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
hb_position_t *kerning, void *user_data);
void *user_data);
typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t; typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t; typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
@ -183,38 +181,38 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
void void
hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs, hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_advance_func_t glyph_advance_func, hb_font_get_glyph_h_advance_func_t func,
void *user_data, hb_destroy_func_t destroy); void *user_data, hb_destroy_func_t destroy);
void void
hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs, hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_advance_func_t glyph_advance_func, hb_font_get_glyph_v_advance_func_t func,
void *user_data, hb_destroy_func_t destroy); void *user_data, hb_destroy_func_t destroy);
void void
hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs, hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_origin_func_t glyph_advance_func, hb_font_get_glyph_h_origin_func_t func,
void *user_data, hb_destroy_func_t destroy); void *user_data, hb_destroy_func_t destroy);
void void
hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs, hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_origin_func_t glyph_advance_func, hb_font_get_glyph_v_origin_func_t func,
void *user_data, hb_destroy_func_t destroy); void *user_data, hb_destroy_func_t destroy);
void void
hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs, hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_kerning_func_t kerning_func, hb_font_get_glyph_h_kerning_func_t func,
void *user_data, hb_destroy_func_t destroy); void *user_data, hb_destroy_func_t destroy);
void void
hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs, hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_kerning_func_t kerning_func, hb_font_get_glyph_v_kerning_func_t func,
void *user_data, hb_destroy_func_t destroy); void *user_data, hb_destroy_func_t destroy);
void void
hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs, hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_extents_func_t glyph_extents_func, hb_font_get_glyph_extents_func_t func,
void *user_data, hb_destroy_func_t destroy); void *user_data, hb_destroy_func_t destroy);
void void
hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs, hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_contour_point_func_t glyph_contour_point_func, hb_font_get_glyph_contour_point_func_t func,
void *user_data, hb_destroy_func_t destroy); void *user_data, hb_destroy_func_t destroy);
@ -225,14 +223,12 @@ hb_font_get_glyph (hb_font_t *font,
hb_codepoint_t unicode, hb_codepoint_t variation_selector, hb_codepoint_t unicode, hb_codepoint_t variation_selector,
hb_codepoint_t *glyph); hb_codepoint_t *glyph);
void hb_position_t
hb_font_get_glyph_h_advance (hb_font_t *font, hb_font_get_glyph_h_advance (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph);
hb_position_t *advance); hb_position_t
void
hb_font_get_glyph_v_advance (hb_font_t *font, hb_font_get_glyph_v_advance (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph);
hb_position_t *advance);
hb_bool_t hb_bool_t
hb_font_get_glyph_h_origin (hb_font_t *font, hb_font_get_glyph_h_origin (hb_font_t *font,
@ -243,14 +239,12 @@ hb_font_get_glyph_v_origin (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y); hb_position_t *x, hb_position_t *y);
void hb_position_t
hb_font_get_glyph_h_kerning (hb_font_t *font, hb_font_get_glyph_h_kerning (hb_font_t *font,
hb_codepoint_t left_glyph, hb_codepoint_t right_glyph, hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
hb_position_t *kerning); hb_position_t
void
hb_font_get_glyph_v_kerning (hb_font_t *font, hb_font_get_glyph_v_kerning (hb_font_t *font,
hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph, hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph);
hb_position_t *kerning);
hb_bool_t hb_bool_t
hb_font_get_glyph_extents (hb_font_t *font, hb_font_get_glyph_extents (hb_font_t *font,

View File

@ -78,38 +78,36 @@ hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
return *glyph != 0; return *glyph != 0;
} }
static void static hb_position_t
hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED,
void *font_data, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *advance,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
FT_Face ft_face = (FT_Face) font_data; FT_Face ft_face = (FT_Face) font_data;
int load_flags = FT_LOAD_DEFAULT; int load_flags = FT_LOAD_DEFAULT;
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
return; return 0;
*advance = ft_face->glyph->metrics.horiAdvance; return ft_face->glyph->metrics.horiAdvance;
} }
static void static hb_position_t
hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED,
void *font_data, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *advance,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
FT_Face ft_face = (FT_Face) font_data; FT_Face ft_face = (FT_Face) font_data;
int load_flags = FT_LOAD_DEFAULT; int load_flags = FT_LOAD_DEFAULT;
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
return; return 0;
/* Note: FreeType's vertical metrics grows downward while other FreeType coordinates /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates
* have a Y growing upward. Hence the extra negation. */ * have a Y growing upward. Hence the extra negation. */
*advance = -ft_face->glyph->metrics.vertAdvance; return -ft_face->glyph->metrics.vertAdvance;
} }
static hb_bool_t static hb_bool_t
@ -146,33 +144,31 @@ hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED,
return TRUE; return TRUE;
} }
static void static hb_position_t
hb_ft_get_glyph_h_kerning (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_h_kerning (hb_font_t *font HB_UNUSED,
void *font_data, void *font_data,
hb_codepoint_t left_glyph, hb_codepoint_t left_glyph,
hb_codepoint_t right_glyph, hb_codepoint_t right_glyph,
hb_position_t *kerning,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
FT_Face ft_face = (FT_Face) font_data; FT_Face ft_face = (FT_Face) font_data;
FT_Vector kerningv; FT_Vector kerningv;
if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, FT_KERNING_DEFAULT, &kerningv)) if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, FT_KERNING_DEFAULT, &kerningv))
return; return 0;
*kerning = kerningv.x; return kerningv.x;
} }
static void static hb_position_t
hb_ft_get_glyph_v_kerning (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_v_kerning (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t top_glyph HB_UNUSED, hb_codepoint_t top_glyph HB_UNUSED,
hb_codepoint_t bottom_glyph HB_UNUSED, hb_codepoint_t bottom_glyph HB_UNUSED,
hb_position_t *kerning HB_UNUSED,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
/* FreeType API doesn't support vertical kerning */ /* FreeType API doesn't support vertical kerning */
return; return 0;
} }
static hb_bool_t static hb_bool_t

View File

@ -121,8 +121,7 @@ _test_font_nil_funcs (hb_font_t *font)
g_assert_cmpint (x, ==, 0); g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0); g_assert_cmpint (y, ==, 0);
x = 13; x = hb_font_get_glyph_h_advance (font, 17);
hb_font_get_glyph_h_advance (font, 17, &x);
g_assert_cmpint (x, ==, 0); g_assert_cmpint (x, ==, 0);
extents.x_bearing = extents.y_bearing = 13; extents.x_bearing = extents.y_bearing = 13;
@ -138,7 +137,7 @@ _test_font_nil_funcs (hb_font_t *font)
g_assert_cmpint (glyph, ==, 0); g_assert_cmpint (glyph, ==, 0);
x = 13; x = 13;
hb_font_get_glyph_h_kerning (font, 17, 19, &x); x = hb_font_get_glyph_h_kerning (font, 17, 19);
g_assert_cmpint (x, ==, 0); g_assert_cmpint (x, ==, 0);
} }
@ -236,15 +235,15 @@ contour_point_func2 (hb_font_t *font, void *font_data,
glyph, point_index, x, y); glyph, point_index, x, y);
} }
static void static hb_position_t
glyph_h_advance_func1 (hb_font_t *font, void *font_data, glyph_h_advance_func1 (hb_font_t *font, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *advance,
void *user_data) void *user_data)
{ {
if (glyph == 1) { if (glyph == 1)
*advance = 8; return 8;
}
return 0;
} }
static void static void
@ -287,9 +286,9 @@ test_fontfuncs_subclassing (void)
g_assert (!hb_font_get_glyph_contour_point_for_origin (font1, 3, 7, HB_DIRECTION_RTL, &x, &y)); g_assert (!hb_font_get_glyph_contour_point_for_origin (font1, 3, 7, HB_DIRECTION_RTL, &x, &y));
g_assert_cmpint (x, ==, 0); g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0); g_assert_cmpint (y, ==, 0);
hb_font_get_glyph_h_advance (font1, 1, &x); x = hb_font_get_glyph_h_advance (font1, 1);
g_assert_cmpint (x, ==, 8); g_assert_cmpint (x, ==, 8);
hb_font_get_glyph_h_advance (font1, 2, &x); x = hb_font_get_glyph_h_advance (font1, 2);
g_assert_cmpint (x, ==, 0); g_assert_cmpint (x, ==, 0);
@ -313,9 +312,9 @@ test_fontfuncs_subclassing (void)
g_assert (!hb_font_get_glyph_contour_point_for_origin (font2, 3, 7, HB_DIRECTION_LTR, &x, &y)); g_assert (!hb_font_get_glyph_contour_point_for_origin (font2, 3, 7, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 0); g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0); g_assert_cmpint (y, ==, 0);
hb_font_get_glyph_h_advance (font2, 1, &x); x = hb_font_get_glyph_h_advance (font2, 1);
g_assert_cmpint (x, ==, 8); g_assert_cmpint (x, ==, 8);
hb_font_get_glyph_h_advance (font2, 2, &x); x = hb_font_get_glyph_h_advance (font2, 2);
g_assert_cmpint (x, ==, 0); g_assert_cmpint (x, ==, 0);
@ -336,9 +335,9 @@ test_fontfuncs_subclassing (void)
g_assert (!hb_font_get_glyph_contour_point_for_origin (font3, 3, 7, HB_DIRECTION_LTR, &x, &y)); g_assert (!hb_font_get_glyph_contour_point_for_origin (font3, 3, 7, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 0*2); g_assert_cmpint (x, ==, 0*2);
g_assert_cmpint (y, ==, 0*3); g_assert_cmpint (y, ==, 0*3);
hb_font_get_glyph_h_advance (font3, 1, &x); x = hb_font_get_glyph_h_advance (font3, 1);
g_assert_cmpint (x, ==, 8*2); g_assert_cmpint (x, ==, 8*2);
hb_font_get_glyph_h_advance (font3, 2, &x); x = hb_font_get_glyph_h_advance (font3, 2);
g_assert_cmpint (x, ==, 0*2); g_assert_cmpint (x, ==, 0*2);

View File

@ -37,17 +37,17 @@
static const char test_data[] = "test\0data"; static const char test_data[] = "test\0data";
static void static hb_position_t
glyph_h_advance_func (hb_font_t *font, void *font_data, glyph_h_advance_func (hb_font_t *font, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *advance,
void *user_data) void *user_data)
{ {
switch (glyph) { switch (glyph) {
case 1: *advance = 10; return; case 1: return 10;
case 2: *advance = 6; return; case 2: return 6;
case 3: *advance = 5; return; case 3: return 5;
} }
return 0;
} }
static hb_bool_t static hb_bool_t
@ -61,19 +61,18 @@ glyph_func (hb_font_t *font, void *font_data,
case 'e': *glyph = 2; return TRUE; case 'e': *glyph = 2; return TRUE;
case 's': *glyph = 3; return TRUE; case 's': *glyph = 3; return TRUE;
} }
return FALSE; return FALSE;
} }
static void static hb_position_t
glyph_h_kerning_func (hb_font_t *font, void *font_data, glyph_h_kerning_func (hb_font_t *font, void *font_data,
hb_codepoint_t left, hb_codepoint_t right, hb_codepoint_t left, hb_codepoint_t right,
hb_position_t *kerning,
void *user_data) void *user_data)
{ {
if (left == 1 && right == 2) { if (left == 1 && right == 2)
*kerning = -2; return -2;
}
return 0;
} }
static const char TesT[] = "TesT"; static const char TesT[] = "TesT";