Add more paint tests
These tests compare the output of the ft and ot implementations for all the glyphs in the test_glyphs font.
This commit is contained in:
parent
0275151490
commit
d0108d31a2
|
@ -1,6 +1,16 @@
|
|||
# random seed: R02S4d8792212546d80a17c24f3863c0fe64
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
start clip rectangle 0 500 500 1e+03
|
||||
start transform 1 0 0 1 0 0
|
||||
push group
|
||||
start transform 1 0 -0 1 0 0
|
||||
start clip glyph 159
|
||||
start transform 1 0 0 1 0 0
|
||||
end transform
|
||||
end clip
|
||||
end transform
|
||||
pop group mode 3
|
||||
push group
|
||||
start transform 1 0 -0 1 0 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02Sdee1b629f80ebe7cea3c793d13a31f83
|
||||
# random seed: R02Sa2bbdfa9ec2b1d4c950ba38ddcb5cea9
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02Sc0be3e63a5c3b507282531d9aac1c3f6
|
||||
# random seed: R02Sa1bbd7f567720f4aaf0abd7972c53d03
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02S80e82754b9935f344ead107f19141fd8
|
||||
# random seed: R02S0619f4e972b1d179c4e90b21eebbfbb5
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02Sa65f915f5906b4e87b390061728fa559
|
||||
# random seed: R02S5c70bbb67a556a20d62d07736c9d28f1
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02S76ed3cce2b7c61c2881fcdd4c818fd11
|
||||
# random seed: R02S9b7f7743b9d517c2b4d12512dec7cfa4
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02S6881f224d108394ed8714867c314f5ac
|
||||
# random seed: R02Se18673abb30681f00ebfae2450ceb094
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02S82402462bc1b63cdb271c35656bf0115
|
||||
# random seed: R02Sc663003d20eb403dcaeac1a576deed2d
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02S5cda42bdbc7e64fabf5ef578888a92e4
|
||||
# random seed: R02Sc5ad459f845cff7270656fc783bc0210
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02S8d1571dc3f9024010eb4bf6074127320
|
||||
# random seed: R02Sc4bee16dcf52bcb58907ac7ac5c774b7
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02S1c512dff9aebeb85f24ab3d9f6b1d47b
|
||||
# random seed: R02S4b5d19f08491119b5a167428e9bb5b6e
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02S3a00c69b6aa0945cd49054a8c5f24179
|
||||
# random seed: R02S983d28d98f64a5434cae4fd3c38c2940
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02S60be6df530a67ddecbb0a926facb59d9
|
||||
# random seed: R02S57d61b1042de59bdab938a7a7c9d7ab6
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# random seed: R02Sd9a0fc8b06b071d89cd2ec685a0ac877
|
||||
# random seed: R02Scfce8d678cf7cf2f5ad5e718435dbe37
|
||||
# Start of hb tests
|
||||
# Start of paint tests
|
||||
# Start of ot tests
|
||||
|
|
|
@ -68,7 +68,7 @@ push_transform (hb_paint_funcs_t *funcs,
|
|||
float dx, float dy,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
|
||||
print (data, "start transform %.3g %.3g %.3g %.3g %.3g %.3g", xx, yx, xy, yy, dx, dy);
|
||||
data->level++;
|
||||
|
@ -79,7 +79,7 @@ pop_transform (hb_paint_funcs_t *funcs,
|
|||
void *paint_data,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
|
||||
data->level--;
|
||||
print (data, "end transform");
|
||||
|
@ -92,7 +92,7 @@ push_clip_glyph (hb_paint_funcs_t *funcs,
|
|||
hb_font_t *font,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
|
||||
print (data, "start clip glyph %u", glyph);
|
||||
data->level++;
|
||||
|
@ -104,7 +104,7 @@ push_clip_rectangle (hb_paint_funcs_t *funcs,
|
|||
float xmin, float ymin, float xmax, float ymax,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
|
||||
print (data, "start clip rectangle %.3g %.3g %.3g %.3g", xmin, ymin, xmax, ymax);
|
||||
data->level++;
|
||||
|
@ -115,7 +115,7 @@ pop_clip (hb_paint_funcs_t *funcs,
|
|||
void *paint_data,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
|
||||
data->level--;
|
||||
print (data, "end clip");
|
||||
|
@ -128,7 +128,7 @@ paint_color (hb_paint_funcs_t *funcs,
|
|||
hb_color_t color,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
|
||||
print (data, "solid %d %d %d %d",
|
||||
hb_color_get_red (color),
|
||||
|
@ -148,7 +148,7 @@ paint_image (hb_paint_funcs_t *funcs,
|
|||
hb_glyph_extents_t *extents,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
char buf[5] = { 0, };
|
||||
|
||||
hb_tag_to_string (format, buf);
|
||||
|
@ -191,7 +191,7 @@ paint_linear_gradient (hb_paint_funcs_t *funcs,
|
|||
float x2, float y2,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
|
||||
print (data, "linear gradient");
|
||||
data->level += 1;
|
||||
|
@ -211,7 +211,7 @@ paint_radial_gradient (hb_paint_funcs_t *funcs,
|
|||
float x1, float y1, float r1,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
|
||||
print (data, "radial gradient");
|
||||
data->level += 1;
|
||||
|
@ -231,7 +231,7 @@ paint_sweep_gradient (hb_paint_funcs_t *funcs,
|
|||
float end_angle,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
|
||||
print (data, "sweep gradient");
|
||||
data->level++;
|
||||
|
@ -247,7 +247,7 @@ push_group (hb_paint_funcs_t *funcs,
|
|||
void *paint_data,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
print (data, "push group");
|
||||
data->level++;
|
||||
}
|
||||
|
@ -258,11 +258,39 @@ pop_group (hb_paint_funcs_t *funcs,
|
|||
hb_paint_composite_mode_t mode,
|
||||
void *user_data)
|
||||
{
|
||||
paint_data_t *data = user_data;
|
||||
paint_data_t *data = paint_data;
|
||||
data->level--;
|
||||
print (data, "pop group mode %d", mode);
|
||||
}
|
||||
|
||||
static hb_paint_funcs_t *
|
||||
get_test_paint_funcs (void)
|
||||
{
|
||||
static hb_paint_funcs_t *funcs = NULL;
|
||||
|
||||
if (!funcs)
|
||||
{
|
||||
funcs = hb_paint_funcs_create ();
|
||||
|
||||
hb_paint_funcs_set_push_transform_func (funcs, push_transform, NULL, NULL);
|
||||
hb_paint_funcs_set_pop_transform_func (funcs, pop_transform, NULL, NULL);
|
||||
hb_paint_funcs_set_push_clip_glyph_func (funcs, push_clip_glyph, NULL, NULL);
|
||||
hb_paint_funcs_set_push_clip_rectangle_func (funcs, push_clip_rectangle, NULL, NULL);
|
||||
hb_paint_funcs_set_pop_clip_func (funcs, pop_clip, NULL, NULL);
|
||||
hb_paint_funcs_set_push_group_func (funcs, push_group, NULL, NULL);
|
||||
hb_paint_funcs_set_pop_group_func (funcs, pop_group, NULL, NULL);
|
||||
hb_paint_funcs_set_color_func (funcs, paint_color, NULL, NULL);
|
||||
hb_paint_funcs_set_image_func (funcs, paint_image, NULL, NULL);
|
||||
hb_paint_funcs_set_linear_gradient_func (funcs, paint_linear_gradient, NULL, NULL);
|
||||
hb_paint_funcs_set_radial_gradient_func (funcs, paint_radial_gradient, NULL, NULL);
|
||||
hb_paint_funcs_set_sweep_gradient_func (funcs, paint_sweep_gradient, NULL, NULL);
|
||||
|
||||
hb_paint_funcs_make_immutable (funcs);
|
||||
}
|
||||
|
||||
return funcs;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *font_file;
|
||||
float slant;
|
||||
|
@ -325,19 +353,7 @@ test_hb_paint (gconstpointer d,
|
|||
hb_ft_font_set_funcs (font);
|
||||
#endif
|
||||
|
||||
funcs = hb_paint_funcs_create ();
|
||||
hb_paint_funcs_set_push_transform_func (funcs, push_transform, &data, NULL);
|
||||
hb_paint_funcs_set_pop_transform_func (funcs, pop_transform, &data, NULL);
|
||||
hb_paint_funcs_set_push_clip_glyph_func (funcs, push_clip_glyph, &data, NULL);
|
||||
hb_paint_funcs_set_push_clip_rectangle_func (funcs, push_clip_rectangle, &data, NULL);
|
||||
hb_paint_funcs_set_pop_clip_func (funcs, pop_clip, &data, NULL);
|
||||
hb_paint_funcs_set_push_group_func (funcs, push_group, &data, NULL);
|
||||
hb_paint_funcs_set_pop_group_func (funcs, pop_group, &data, NULL);
|
||||
hb_paint_funcs_set_color_func (funcs, paint_color, &data, NULL);
|
||||
hb_paint_funcs_set_image_func (funcs, paint_image, &data, NULL);
|
||||
hb_paint_funcs_set_linear_gradient_func (funcs, paint_linear_gradient, &data, NULL);
|
||||
hb_paint_funcs_set_radial_gradient_func (funcs, paint_radial_gradient, &data, NULL);
|
||||
hb_paint_funcs_set_sweep_gradient_func (funcs, paint_sweep_gradient, &data, NULL);
|
||||
funcs = get_test_paint_funcs ();
|
||||
|
||||
data.string = g_string_new ("");
|
||||
data.level = 0;
|
||||
|
@ -418,11 +434,57 @@ test_hb_paint (gconstpointer d,
|
|||
|
||||
g_string_free (data.string, TRUE);
|
||||
|
||||
hb_paint_funcs_destroy (funcs);
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (face);
|
||||
}
|
||||
|
||||
static void
|
||||
test_compare_ot_ft (gconstpointer d)
|
||||
{
|
||||
hb_codepoint_t glyph = GPOINTER_TO_UINT (d);
|
||||
hb_face_t *face;
|
||||
hb_font_t *font;
|
||||
hb_paint_funcs_t *funcs;
|
||||
GString *ot_str;
|
||||
paint_data_t data;
|
||||
|
||||
#ifndef HB_HAS_FREETYPE
|
||||
g_test_skip_printf ("freetype support not present");
|
||||
return;
|
||||
#endif
|
||||
|
||||
face = hb_test_open_font_file (TEST_GLYPHS);
|
||||
font = hb_font_create (face);
|
||||
|
||||
funcs = get_test_paint_funcs ();
|
||||
|
||||
data.string = g_string_new ("");
|
||||
data.level = 0;
|
||||
|
||||
hb_font_paint_glyph (font, glyph, funcs, &data, 0, HB_COLOR (0, 0, 0, 255));
|
||||
|
||||
g_assert_true (data.level == 0);
|
||||
|
||||
ot_str = data.string;
|
||||
|
||||
hb_ft_font_set_funcs (font);
|
||||
|
||||
data.string = g_string_new ("");
|
||||
data.level = 0;
|
||||
|
||||
hb_font_paint_glyph (font, glyph, funcs, &data, 0, HB_COLOR (0, 0, 0, 255));
|
||||
|
||||
g_assert_true (data.level == 0);
|
||||
|
||||
g_assert_cmpstr (ot_str->str, ==, data.string->str);
|
||||
|
||||
g_string_free (data.string, TRUE);
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (face);
|
||||
|
||||
g_string_free (ot_str, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_hb_paint_ot (gconstpointer data)
|
||||
{
|
||||
|
@ -541,6 +603,16 @@ main (int argc, char **argv)
|
|||
hb_test_add_data_flavor (&paint_tests[i], paint_tests[i].output, test_hb_paint_ot);
|
||||
hb_test_add_data_flavor (&paint_tests[i], paint_tests[i].output, test_hb_paint_ft);
|
||||
}
|
||||
|
||||
hb_face_t *face = hb_test_open_font_file (TEST_GLYPHS);
|
||||
for (unsigned int i = 1; i < hb_face_get_glyph_count (face); i++)
|
||||
{
|
||||
char buf[20];
|
||||
snprintf (buf, 20, "test-%u", i);
|
||||
hb_test_add_data_flavor (GUINT_TO_POINTER (i), buf, test_compare_ot_ft);
|
||||
}
|
||||
hb_face_destroy (face);
|
||||
|
||||
hb_test_add (test_color_stops_ot);
|
||||
hb_test_add (test_color_stops_ft);
|
||||
|
||||
|
|
Loading…
Reference in New Issue