diff --git a/test/api/fonts/test_glyphs-glyf_colr_1_variable.ttf b/test/api/fonts/test_glyphs-glyf_colr_1_variable.ttf new file mode 100644 index 000000000..9cc723015 Binary files /dev/null and b/test/api/fonts/test_glyphs-glyf_colr_1_variable.ttf differ diff --git a/test/api/results/testvf-10 b/test/api/results/testvf-10 new file mode 100644 index 000000000..9b399db29 --- /dev/null +++ b/test/api/results/testvf-10 @@ -0,0 +1,22 @@ +# random seed: R02S4cc6a292019f2eefbbaf24127cc6b053 +# Start of hb tests +# Start of paint tests +# Start of ot tests +start clip rectangle 0 0 1e+03 1e+03 + start transform 1 0 0 1 0 0 + start transform 1 0 -0 1 0 0 + start clip glyph 174 + start transform 1 0 0 1 0 0 + sweep gradient + center 500 600 + angles 0 6.28 + colors 0 + 0.25 250 240 230 255 + 0.417 0 0 255 255 + 0.583 255 0 0 255 + 0.75 47 79 79 255 + end transform + end clip + end transform + end transform +end clip diff --git a/test/api/results/testvf-106 b/test/api/results/testvf-106 new file mode 100644 index 000000000..58f65f897 --- /dev/null +++ b/test/api/results/testvf-106 @@ -0,0 +1,30 @@ +# random seed: R02Sa8358a35595768d4b3f0424c492c70f9 +# Start of hb tests +# Start of paint tests +# Start of ot tests +start clip rectangle 250 250 882 1.02e+03 + start transform 1 0 0 1 0 0 + start transform 1 0 -0 1 0 0 + start clip glyph 3 + start transform 1 0 0 1 0 0 + solid 0 0 255 127 + end transform + end clip + end transform + push group + start transform 1 0 0 1 1e+03 1e+03 + start transform 1 -0.364 -0.176 1 0 0 + start transform 1 0 0 1 -1e+03 -1e+03 + start transform 1 0 -0 1 0 0 + start clip glyph 3 + start transform 1 0 0 1 0 0 + solid 255 165 0 178 + end transform + end clip + end transform + end transform + end transform + end transform + pop group mode 4 + end transform +end clip diff --git a/test/api/results/testvf-116 b/test/api/results/testvf-116 new file mode 100644 index 000000000..9ac2926bf --- /dev/null +++ b/test/api/results/testvf-116 @@ -0,0 +1,26 @@ +# random seed: R02S5710187ea075c431f16412c38d1f7407 +# Start of hb tests +# Start of paint tests +# Start of ot tests +start clip rectangle 250 250 950 950 + start transform 1 0 0 1 0 0 + start transform 1 0 -0 1 0 0 + start clip glyph 3 + start transform 1 0 0 1 0 0 + solid 0 0 255 127 + end transform + end clip + end transform + push group + start transform 1 0 0 1 200 200 + start transform 1 0 -0 1 0 0 + start clip glyph 3 + start transform 1 0 0 1 0 0 + solid 255 165 0 178 + end transform + end clip + end transform + end transform + pop group mode 4 + end transform +end clip diff --git a/test/api/results/testvf-123 b/test/api/results/testvf-123 new file mode 100644 index 000000000..d2d8b6747 --- /dev/null +++ b/test/api/results/testvf-123 @@ -0,0 +1,47 @@ +# random seed: R02S486e6425a6369f1d079b0c273210d642 +# Start of hb tests +# Start of paint tests +# Start of ot tests +start clip rectangle 0 0 1e+03 1e+03 + start transform 1 0 0 1 0 0 + push group + start transform 1 0 -0 1 0 0 + start clip glyph 3 + start transform 1 0 0 1 0 0 + solid 0 0 0 255 + end transform + end clip + end transform + pop group mode 3 + push group + start transform 1 0 0 1 333 667 + start transform 0.5 0 0 0.5 0 0 + start transform 1 0 0 1 -333 -667 + start transform 1 0 -0 1 0 0 + start clip glyph 2 + start transform 1 0 0 1 0 0 + solid 255 220 1 255 + end transform + end clip + end transform + end transform + end transform + end transform + push group + start transform 1 0 0 1 667 333 + start transform 0.5 0 0 0.5 0 0 + start transform 1 0 0 1 -667 -333 + start transform 1 0 -0 1 0 0 + start clip glyph 2 + start transform 1 0 0 1 0 0 + solid 104 199 232 255 + end transform + end clip + end transform + end transform + end transform + end transform + pop group mode 5 + pop group mode 3 + end transform +end clip diff --git a/test/api/results/testvf-154 b/test/api/results/testvf-154 new file mode 100644 index 000000000..03eb4bcd9 --- /dev/null +++ b/test/api/results/testvf-154 @@ -0,0 +1,30 @@ +# random seed: R02S3997a362a4af7aea0e7c6f803c91771c +# 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 + start transform 1 0 -0 1 0 0 + start clip glyph 2 + start transform 1 0 0 1 0 0 + radial gradient + p0 166 768 radius 0 + p1 166 768 radius 256 + colors 2 + 0 0 128 0 255 + 0.5 255 255 255 255 + 1 255 0 0 255 + end transform + end clip + end transform + push group + start transform 1 0 -0 1 0 0 + start clip glyph 159 + start transform 1 0 0 1 0 0 + solid 128 128 128 102 + end transform + end clip + end transform + pop group mode 3 + end transform +end clip diff --git a/test/api/results/testvf-165 b/test/api/results/testvf-165 new file mode 100644 index 000000000..94de0b720 --- /dev/null +++ b/test/api/results/testvf-165 @@ -0,0 +1,22 @@ +# random seed: R02S4f2af10d205b3b3052f5a575490a2686 +# Start of hb tests +# Start of paint tests +# Start of ot tests +start clip rectangle 100 250 1.2e+03 950 + start transform 1 0 0 1 0 0 + start transform 1 0 -0 1 0 0 + start clip glyph 165 + start transform 1 0 0 1 0 0 + linear gradient + p0 100 950 + p1 2.3e+03 950 + p2 -1e+03 250 + colors 0 + 0 255 0 0 255 + 0.5 0 0 255 255 + 1 255 255 0 255 + end transform + end clip + end transform + end transform +end clip diff --git a/test/api/results/testvf-175 b/test/api/results/testvf-175 new file mode 100644 index 000000000..f0b6e9acb --- /dev/null +++ b/test/api/results/testvf-175 @@ -0,0 +1,36 @@ +# random seed: R02S4c022e014005a52e2898416210be4ddf +# Start of hb tests +# Start of paint tests +# Start of ot tests +start clip rectangle 0 0 1e+03 1e+03 + start transform 1 0 0 1 0 0 + push group + start transform 1 0 0 1 150 0 + start transform 1 0 -0 1 0 0 + start clip glyph 174 + start transform 1 0 0 1 0 0 + solid 0 128 0 255 + end transform + end clip + end transform + end transform + pop group mode 3 + push group + start transform 1 0 0 1 -150 0 + start transform 1 0 -0 1 0 0 + start clip glyph 174 + start transform 1 0 0 1 0 0 + linear gradient + p0 500 250 + p1 500 950 + p2 600 250 + colors 1 + 0 255 0 0 255 + 1 0 0 255 255 + end transform + end clip + end transform + end transform + pop group mode 3 + end transform +end clip diff --git a/test/api/results/testvf-6 b/test/api/results/testvf-6 new file mode 100644 index 000000000..73c70edf6 --- /dev/null +++ b/test/api/results/testvf-6 @@ -0,0 +1,21 @@ +# random seed: R02Sc96e8c0cb2d824e493d9a1088730d188 +# Start of hb tests +# Start of paint tests +# Start of ot tests +start clip rectangle 100 250 900 950 + start transform 1 0 0 1 0 0 + start transform 1 0 -0 1 0 0 + start clip glyph 6 + start transform 1 0 0 1 0 0 + linear gradient + p0 100 250 + p1 900 250 + p2 100 300 + colors 1 + 0 255 0 0 255 + 1 0 0 255 255 + end transform + end clip + end transform + end transform +end clip diff --git a/test/api/results/testvf-92 b/test/api/results/testvf-92 new file mode 100644 index 000000000..382d1ac77 --- /dev/null +++ b/test/api/results/testvf-92 @@ -0,0 +1,21 @@ +# random seed: R02See3981a17ce77670e1392178e6b57952 +# Start of hb tests +# Start of paint tests +# Start of ot tests +start clip rectangle 0 0 1e+03 1e+03 + start transform 1 0 0 1 0 0 + start transform 1 0 -0 1 0 0 + start clip glyph 2 + start transform 1 0 0 1 0 0 + radial gradient + p0 166 768 radius 0 + p1 166 768 radius 256 + colors 1 + 0 0 128 0 255 + 0.5 255 255 255 255 + 1 255 0 0 255 + end transform + end clip + end transform + end transform +end clip diff --git a/test/api/test-paint.c b/test/api/test-paint.c index d147027f8..22a851259 100644 --- a/test/api/test-paint.c +++ b/test/api/test-paint.c @@ -29,9 +29,20 @@ #ifdef HB_HAS_FREETYPE #include + #if (FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH) >= 21101 -#define HAVE_FT_COLRv1 +#include FT_COLOR_H #endif + +static inline hb_bool_t +have_ft_colrv1 (void) +{ +#if (FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH) >= 21101 + // https://github.com/harfbuzz/harfbuzz/issues/4013 + return sizeof (FT_ColorStop) == 8; +#endif + return FALSE; +} #endif /* Unit tests for hb-paint.h */ @@ -304,12 +315,13 @@ typedef struct { #define NOTO_HAND "fonts/noto_handwriting-cff2_colr_1.otf" #define TEST_GLYPHS "fonts/test_glyphs-glyf_colr_1.ttf" +#define TEST_GLYPHS_VF "fonts/test_glyphs-glyf_colr_1_variable.ttf" #define BAD_COLRV1 "fonts/bad_colrv1.ttf" #define ROCHER_ABC "fonts/RocherColorGX.abc.ttf" /* To verify the rendering visually, use * - * hb-view --font-size SCALE --font-slant SLANT --font-palette PALETTE FONT --glyphs [gidGID=0+1000] + * hb-view --font-slant SLANT --font-palette PALETTE FONT --glyphs [gidGID=0+1000] * * where GID is the glyph value of the test. */ @@ -317,6 +329,7 @@ static paint_test_t paint_tests[] = { /* COLRv1 */ { NOTO_HAND, 0., 10, 0, "hand-10" }, { NOTO_HAND, 0.2, 10, 0, "hand-10.2" }, + { TEST_GLYPHS, 0, 6, 0, "test-6" }, // linear gradient { TEST_GLYPHS, 0, 10, 0, "test-10" }, // sweep gradient { TEST_GLYPHS, 0, 92, 0, "test-92" }, // radial gradient @@ -326,7 +339,19 @@ static paint_test_t paint_tests[] = { { TEST_GLYPHS, 0, 154, 0, "test-154" }, { TEST_GLYPHS, 0, 165, 0, "test-165" }, // linear gradient { TEST_GLYPHS, 0, 175, 0, "test-175" }, // layers + + { TEST_GLYPHS_VF, 0, 6, 0, "testvf-6" }, + { TEST_GLYPHS_VF, 0, 10, 0, "testvf-10" }, + { TEST_GLYPHS_VF, 0, 92, 0, "testvf-92" }, + { TEST_GLYPHS_VF, 0, 106, 0, "testvf-106" }, + { TEST_GLYPHS_VF, 0, 116, 0, "testvf-116" }, + { TEST_GLYPHS_VF, 0, 123, 0, "testvf-123" }, + { TEST_GLYPHS_VF, 0, 154, 0, "testvf-154" }, + { TEST_GLYPHS_VF, 0, 165, 0, "testvf-165" }, + { TEST_GLYPHS_VF, 0, 175, 0, "testvf-175" }, + { BAD_COLRV1, 0, 154, 0, "bad-154" }, // recursion + /* COLRv0 */ { ROCHER_ABC, 0.3, 1, 0, "rocher-1" }, { ROCHER_ABC, 0.3, 2, 2, "rocher-2" }, @@ -352,7 +377,7 @@ test_hb_paint (gconstpointer d, hb_font_set_synthetic_slant (font, test->slant); -#ifdef HAVE_FT_COLRv1 +#ifdef HB_HAS_FREETYPE if (use_ft) hb_ft_font_set_funcs (font); #endif @@ -443,21 +468,15 @@ test_hb_paint (gconstpointer d, } static void -test_compare_ot_ft (gconstpointer d) +test_compare_ot_ft (const char *file, hb_codepoint_t glyph) { - 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 HAVE_FT_COLRv1 - g_test_skip ("FreeType COLRv1 support not present"); - return; -#endif - - face = hb_test_open_font_file (TEST_GLYPHS); + face = hb_test_open_font_file (file); font = hb_font_create (face); funcs = get_test_paint_funcs (); @@ -471,7 +490,9 @@ test_compare_ot_ft (gconstpointer d) ot_str = data.string; +#ifdef HB_HAS_FREETYPE hb_ft_font_set_funcs (font); +#endif data.string = g_string_new (""); data.level = 0; @@ -498,11 +519,28 @@ test_hb_paint_ot (gconstpointer data) static void test_hb_paint_ft (gconstpointer data) { -#ifdef HAVE_FT_COLRv1 - test_hb_paint (data, 1); -#else - g_test_skip ("FreeType COLRv1 support not present"); -#endif + if (have_ft_colrv1 ()) + test_hb_paint (data, 1); + else + g_test_skip ("FreeType COLRv1 support not present"); +} + +static void +test_compare_ot_ft_novf (gconstpointer d) +{ + if (have_ft_colrv1 ()) + test_compare_ot_ft (TEST_GLYPHS, GPOINTER_TO_UINT (d)); + else + g_test_skip ("FreeType COLRv1 support not present"); +} + +static void +test_compare_ot_ft_vf (gconstpointer d) +{ + if (have_ft_colrv1 ()) + test_compare_ot_ft (TEST_GLYPHS_VF, GPOINTER_TO_UINT (d)); + else + g_test_skip ("FreeType COLRv1 support not present"); } static void @@ -567,7 +605,7 @@ test_color_stops (hb_bool_t use_ft) face = hb_test_open_font_file (NOTO_HAND); font = hb_font_create (face); -#ifdef HAVE_FT_COLRv1 +#ifdef HB_HAS_FREETYPE if (use_ft) hb_ft_font_set_funcs (font); #endif @@ -593,11 +631,10 @@ test_color_stops_ot (void) static void test_color_stops_ft (void) { -#ifdef HAVE_FT_COLRv1 - test_color_stops (1); -#else - g_test_skip ("FreeType COLRv1 support not present"); -#endif + if (have_ft_colrv1 ()) + test_color_stops (1); + else + g_test_skip ("FreeType COLRv1 support not present"); } int @@ -613,11 +650,13 @@ main (int argc, char **argv) } hb_face_t *face = hb_test_open_font_file (TEST_GLYPHS); - for (unsigned int i = 1; i < hb_face_get_glyph_count (face); i++) + unsigned glyph_count = hb_face_get_glyph_count (face); + for (unsigned int i = 1; i < glyph_count; 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_test_add_data_flavor (GUINT_TO_POINTER (i), buf, test_compare_ot_ft_novf); + hb_test_add_data_flavor (GUINT_TO_POINTER (i), buf, test_compare_ot_ft_vf); } hb_face_destroy (face);