[test] Update to API changes

This commit is contained in:
Behdad Esfahbod 2011-05-25 11:01:32 -04:00
parent 7403e055cd
commit d31691296f
2 changed files with 44 additions and 63 deletions

View File

@ -117,18 +117,17 @@ _test_font_nil_funcs (hb_font_t *font)
hb_glyph_extents_t extents;
x = y = 13;
g_assert (!hb_font_get_contour_point (font, 17, 2, HB_DIRECTION_LTR, &x, &y));
g_assert (!hb_font_get_glyph_contour_point (font, 17, 2, &x, &y));
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
x = y = 13;
hb_font_get_glyph_h_advance (font, 17, &x, &y);
x = 13;
hb_font_get_glyph_h_advance (font, 17, &x);
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
extents.x_bearing = extents.y_bearing = 13;
extents.width = extents.height = 15;
hb_font_get_glyph_extents (font, 17, HB_DIRECTION_LTR, &extents);
hb_font_get_glyph_extents (font, 17, &extents);
g_assert_cmpint (extents.x_bearing, ==, 0);
g_assert_cmpint (extents.y_bearing, ==, 0);
g_assert_cmpint (extents.width, ==, 0);
@ -138,10 +137,9 @@ _test_font_nil_funcs (hb_font_t *font)
g_assert (!hb_font_get_glyph (font, 17, 2, &glyph));
g_assert_cmpint (glyph, ==, 0);
x = y = 13;
hb_font_get_h_kerning (font, 17, 19, &x, &y);
x = 13;
hb_font_get_glyph_h_kerning (font, 17, 19, &x);
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
}
static void
@ -205,12 +203,9 @@ test_fontfuncs_nil (void)
static hb_bool_t
contour_point_func1 (hb_font_t *font, void *font_data,
hb_codepoint_t glyph, unsigned int point_index,
hb_bool_t *vertical,
hb_position_t *x, hb_position_t *y,
void *user_data)
{
*vertical = FALSE;
if (glyph == 1) {
*x = 2;
*y = 3;
@ -228,7 +223,6 @@ contour_point_func1 (hb_font_t *font, void *font_data,
static hb_bool_t
contour_point_func2 (hb_font_t *font, void *font_data,
hb_codepoint_t glyph, unsigned int point_index,
hb_bool_t *vertical,
hb_position_t *x, hb_position_t *y,
void *user_data)
{
@ -238,23 +232,19 @@ contour_point_func2 (hb_font_t *font, void *font_data,
return TRUE;
}
return hb_font_get_contour_point (hb_font_get_parent (font),
glyph, point_index, vertical, x, y);
return hb_font_get_glyph_contour_point (hb_font_get_parent (font),
glyph, point_index, x, y);
}
static hb_bool_t
static void
glyph_h_advance_func1 (hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance,
hb_position_t *advance,
void *user_data)
{
if (glyph == 1) {
*x_advance = 8;
*y_advance = 9;
return TRUE;
*advance = 8;
}
return FALSE;
}
static void
@ -282,27 +272,25 @@ test_fontfuncs_subclassing (void)
/* setup font1 */
ffuncs1 = hb_font_funcs_create ();
hb_font_funcs_set_contour_point_func (ffuncs1, contour_point_func1, NULL, NULL);
hb_font_funcs_set_glyph_contour_point_func (ffuncs1, contour_point_func1, NULL, NULL);
hb_font_funcs_set_glyph_h_advance_func (ffuncs1, glyph_h_advance_func1, NULL, NULL);
hb_font_set_funcs (font1, ffuncs1, NULL, NULL);
hb_font_funcs_destroy (ffuncs1);
x = y = 1;
g_assert (hb_font_get_contour_point_for_direction (font1, 1, 2, HB_DIRECTION_LTR, &x, &y));
g_assert (hb_font_get_glyph_contour_point_for_origin (font1, 1, 2, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 2);
g_assert_cmpint (y, ==, 3);
g_assert (hb_font_get_contour_point_for_direction (font1, 2, 5, HB_DIRECTION_LTR, &x, &y));
g_assert (hb_font_get_glyph_contour_point_for_origin (font1, 2, 5, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 4);
g_assert_cmpint (y, ==, 5);
g_assert (!hb_font_get_contour_point_for_direction (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 (y, ==, 0);
hb_font_get_glyph_h_advance (font1, 1, &x, &y);
hb_font_get_glyph_h_advance (font1, 1, &x);
g_assert_cmpint (x, ==, 8);
g_assert_cmpint (y, ==, 9);
hb_font_get_glyph_h_advance (font1, 2, &x, &y);
hb_font_get_glyph_h_advance (font1, 2, &x);
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
font2 = hb_font_create_sub_font (font1);
@ -311,26 +299,24 @@ test_fontfuncs_subclassing (void)
/* setup font2 to override some funcs */
ffuncs2 = hb_font_funcs_create ();
hb_font_funcs_set_contour_point_func (ffuncs2, contour_point_func2, NULL, NULL);
hb_font_funcs_set_glyph_contour_point_func (ffuncs2, contour_point_func2, NULL, NULL);
hb_font_set_funcs (font2, ffuncs2, NULL, NULL);
hb_font_funcs_destroy (ffuncs2);
x = y = 1;
g_assert (hb_font_get_contour_point_for_direction (font2, 1, 2, HB_DIRECTION_LTR, &x, &y));
g_assert (hb_font_get_glyph_contour_point_for_origin (font2, 1, 2, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 6);
g_assert_cmpint (y, ==, 7);
g_assert (hb_font_get_contour_point_for_direction (font2, 2, 5, HB_DIRECTION_RTL, &x, &y));
g_assert (hb_font_get_glyph_contour_point_for_origin (font2, 2, 5, HB_DIRECTION_RTL, &x, &y));
g_assert_cmpint (x, ==, 4);
g_assert_cmpint (y, ==, 5);
g_assert (!hb_font_get_contour_point_for_direction (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 (y, ==, 0);
hb_font_get_glyph_h_advance (font2, 1, &x, &y);
hb_font_get_glyph_h_advance (font2, 1, &x);
g_assert_cmpint (x, ==, 8);
g_assert_cmpint (y, ==, 9);
hb_font_get_glyph_h_advance (font2, 2, &x, &y);
hb_font_get_glyph_h_advance (font2, 2, &x);
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
font3 = hb_font_create_sub_font (font2);
@ -341,21 +327,19 @@ test_fontfuncs_subclassing (void)
hb_font_set_scale (font3, 20, 30);
x = y = 1;
g_assert (hb_font_get_contour_point_for_direction (font3, 1, 2, HB_DIRECTION_RTL, &x, &y));
g_assert (hb_font_get_glyph_contour_point_for_origin (font3, 1, 2, HB_DIRECTION_RTL, &x, &y));
g_assert_cmpint (x, ==, 6*2);
g_assert_cmpint (y, ==, 7*3);
g_assert (hb_font_get_contour_point_for_direction (font3, 2, 5, HB_DIRECTION_LTR, &x, &y));
g_assert (hb_font_get_glyph_contour_point_for_origin (font3, 2, 5, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 4*2);
g_assert_cmpint (y, ==, 5*3);
g_assert (!hb_font_get_contour_point_for_direction (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 (y, ==, 0*3);
hb_font_get_glyph_h_advance (font3, 1, &x, &y);
hb_font_get_glyph_h_advance (font3, 1, &x);
g_assert_cmpint (x, ==, 8*2);
g_assert_cmpint (y, ==, 9*3);
hb_font_get_glyph_h_advance (font3, 2, &x, &y);
hb_font_get_glyph_h_advance (font3, 2, &x);
g_assert_cmpint (x, ==, 0*2);
g_assert_cmpint (y, ==, 0*3);
hb_font_destroy (font3);

View File

@ -37,18 +37,17 @@
static const char test_data[] = "test\0data";
static hb_bool_t
glyph_advance_func (hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance,
void *user_data)
static void
glyph_h_advance_func (hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
hb_position_t *advance,
void *user_data)
{
switch (glyph) {
case 1: *x_advance = 10; return TRUE;
case 2: *x_advance = 6; return TRUE;
case 3: *x_advance = 5; return TRUE;
case 1: *advance = 10; return;
case 2: *advance = 6; return;
case 3: *advance = 5; return;
}
return FALSE;
}
static hb_bool_t
@ -66,17 +65,15 @@ glyph_func (hb_font_t *font, void *font_data,
return FALSE;
}
static hb_bool_t
kerning_func (hb_font_t *font, void *font_data,
hb_codepoint_t left, hb_codepoint_t right,
hb_position_t *x_kern, hb_position_t *y_kern,
void *user_data)
static void
glyph_h_kerning_func (hb_font_t *font, void *font_data,
hb_codepoint_t left, hb_codepoint_t right,
hb_position_t *kerning,
void *user_data)
{
if (left == 1 && right == 2) {
*x_kern = -2;
return TRUE;
*kerning = -2;
}
return FALSE;
}
static const char TesT[] = "TesT";
@ -101,9 +98,9 @@ test_shape (void)
hb_font_set_scale (font, 10, 10);
ffuncs = hb_font_funcs_create ();
hb_font_funcs_set_glyph_h_advance_func (ffuncs, glyph_advance_func, NULL, NULL);
hb_font_funcs_set_glyph_h_advance_func (ffuncs, glyph_h_advance_func, NULL, NULL);
hb_font_funcs_set_glyph_func (ffuncs, glyph_func, NULL, NULL);
hb_font_funcs_set_h_kerning_func (ffuncs, kerning_func, NULL, NULL);
hb_font_funcs_set_glyph_h_kerning_func (ffuncs, glyph_h_kerning_func, NULL, NULL);
hb_font_set_funcs (font, ffuncs, NULL, NULL);
hb_font_funcs_destroy (ffuncs);