From 8396c523b6715893c67163c947521c9b1408f594 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 28 Jul 2021 16:29:43 +0200 Subject: [PATCH] [test] Add AOTS cmap tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uses https://github.com/adobe-type-tools/aots/pull/3 Related to https://github.com/unicode-org/text-rendering-tests/issues/70 We don’t support format 4 or 8, so these tests are disabled. We support format 4 but most of the tests are failing, investigating. --- test/shaping/data/aots/Makefile.sources | 7 ++ test/shaping/data/aots/hb-aots-tester.cpp | 82 +++++++++++++++++++++++ test/shaping/data/aots/meson.build | 7 ++ test/shaping/data/aots/tests/cmap0.tests | 1 + test/shaping/data/aots/tests/cmap10.tests | 2 + test/shaping/data/aots/tests/cmap12.tests | 1 + test/shaping/data/aots/tests/cmap2.tests | 1 + test/shaping/data/aots/tests/cmap4.tests | 6 ++ test/shaping/data/aots/tests/cmap6.tests | 2 + test/shaping/data/aots/tests/cmap8.tests | 1 + 10 files changed, 110 insertions(+) create mode 100644 test/shaping/data/aots/tests/cmap0.tests create mode 100644 test/shaping/data/aots/tests/cmap10.tests create mode 100644 test/shaping/data/aots/tests/cmap12.tests create mode 100644 test/shaping/data/aots/tests/cmap2.tests create mode 100644 test/shaping/data/aots/tests/cmap4.tests create mode 100644 test/shaping/data/aots/tests/cmap6.tests create mode 100644 test/shaping/data/aots/tests/cmap8.tests diff --git a/test/shaping/data/aots/Makefile.sources b/test/shaping/data/aots/Makefile.sources index 93396824a..ffa311b15 100644 --- a/test/shaping/data/aots/Makefile.sources +++ b/test/shaping/data/aots/Makefile.sources @@ -7,6 +7,13 @@ TESTS = \ tests/classdef2_multiple.tests \ tests/classdef2_single.tests \ tests/classdef2.tests \ + tests/cmap0.tests \ + tests/cmap10.tests \ + tests/cmap12.tests \ + tests/cmap2.tests \ + tests/cmap4.tests \ + tests/cmap6.tests \ + tests/cmap8.tests \ tests/gpos_chaining1_boundary.tests \ tests/gpos_chaining1_lookupflag.tests \ tests/gpos_chaining1_multiple_subrules.tests \ diff --git a/test/shaping/data/aots/hb-aots-tester.cpp b/test/shaping/data/aots/hb-aots-tester.cpp index 37079abc0..430bad3f7 100644 --- a/test/shaping/data/aots/hb-aots-tester.cpp +++ b/test/shaping/data/aots/hb-aots-tester.cpp @@ -203,6 +203,88 @@ bool gsub_test(const char *testName, return ok; } +bool cmap_test(const char *testName, + const char *fontfileName, + int nbIn, unsigned int *in, + int nbSelect, unsigned int *select, + int nbExpected, unsigned int *expected) +{ + hb_buffer_t *buffer = runTest(testName, + fontfileName, + in, nbIn, + select, nbSelect); + + // verify + hb_glyph_info_t *actual = hb_buffer_get_glyph_infos(buffer, 0); + unsigned int nbActual = hb_buffer_get_length(buffer); + + bool ok = true; + + if (nbActual != nbExpected) + ok = false; + else { + for (int i = 0; i < nbActual; i++) { + if (actual[i].codepoint != expected [i]) { + ok = false; + break; + } + } + } + + + char test_name[255]; + sprintf (test_name, "../../tests/%.*s.tests", (int) (strrchr (testName, '_') - testName), testName); + FILE *tests_file = fopen (test_name, "a+"); + if (!ok) fprintf (tests_file, "#"); + fprintf (tests_file, "../fonts/%s:--features=\"", fontfileName + 9); + for (unsigned int i = 0; i < gNbFeatures; i++) + { + if (i != 0) fprintf (tests_file, ","); + char buf[255]; + hb_feature_to_string (&gFeatures[i], buf, sizeof (buf)); + fprintf (tests_file, "%s", buf); + } + free (gFeatures); + fprintf (tests_file, "\" --no-clusters --no-glyph-names --no-positions:"); + + for (unsigned int i = 0; i < nbIn; i++) + { + if (i != 0) fprintf (tests_file, ","); + fprintf (tests_file, "U+%04X", in[i]); + } + + fprintf (tests_file, ":["); + for (unsigned int i = 0; i < nbActual; i++) + { + if (i != 0) fprintf (tests_file, "|"); + fprintf (tests_file, "%d", expected[i]); + } + fprintf (tests_file, "]"); + + fprintf (tests_file, "\n"); + fclose (tests_file); + + + if (! ok) { + printf ("******* cmap %s\n", testName); + + printf ("expected %d:", nbExpected); + for (int i = 0; i < nbExpected; i++) { + printf (" %d", expected[i]); } + printf ("\n"); + + printf (" actual %d:", nbActual); + for (int i = 0; i < nbActual; i++) { + printf (" %d", actual[i].codepoint); } + printf ("\n"); + + } + + hb_buffer_destroy(buffer); + + return ok; +} + bool gpos_test(const char *testName, const char *fontfileName, int nbIn, diff --git a/test/shaping/data/aots/meson.build b/test/shaping/data/aots/meson.build index 7e3c64b77..bda27112b 100644 --- a/test/shaping/data/aots/meson.build +++ b/test/shaping/data/aots/meson.build @@ -7,6 +7,13 @@ aots_tests = [ 'classdef2_multiple.tests', 'classdef2_single.tests', 'classdef2.tests', + 'cmap0.tests', + 'cmap10.tests', + 'cmap12.tests', + 'cmap2.tests', + 'cmap4.tests', + 'cmap6.tests', + 'cmap8.tests', 'gpos_chaining1_boundary.tests', 'gpos_chaining1_lookupflag.tests', 'gpos_chaining1_multiple_subrules.tests', diff --git a/test/shaping/data/aots/tests/cmap0.tests b/test/shaping/data/aots/tests/cmap0.tests new file mode 100644 index 000000000..89d2a2195 --- /dev/null +++ b/test/shaping/data/aots/tests/cmap0.tests @@ -0,0 +1 @@ +../fonts/cmap0_font1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0033,U+0034,U+0035,U+0036,U+0037,U+FFFF:[0|0|0|17|56|12|0|0] diff --git a/test/shaping/data/aots/tests/cmap10.tests b/test/shaping/data/aots/tests/cmap10.tests new file mode 100644 index 000000000..be83c27a8 --- /dev/null +++ b/test/shaping/data/aots/tests/cmap10.tests @@ -0,0 +1,2 @@ +../fonts/cmap10_font1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+9232,U+109422,U+109423,U+109424,U+109425,U+FFFF:[0|0|0|0|26|27|32|0] +../fonts/cmap10_font2.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0021,U+0022,U+0023,U+0024,U+0025,U+FFFF:[0|0|0|0|0|0|0|0] diff --git a/test/shaping/data/aots/tests/cmap12.tests b/test/shaping/data/aots/tests/cmap12.tests new file mode 100644 index 000000000..8591976ba --- /dev/null +++ b/test/shaping/data/aots/tests/cmap12.tests @@ -0,0 +1 @@ +../fonts/cmap12_font1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0010,U+101723,U+101724,U+101727,U+101728,U+102522,U+102523,U+102527,U+102528,U+FFFF:[0|0|0|23|24|27|0|0|53|57|0|0] diff --git a/test/shaping/data/aots/tests/cmap2.tests b/test/shaping/data/aots/tests/cmap2.tests new file mode 100644 index 000000000..250936d5e --- /dev/null +++ b/test/shaping/data/aots/tests/cmap2.tests @@ -0,0 +1 @@ +#../fonts/cmap2_font1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0033,U+0034,U+0035,U+0036,U+0037,U+8431,U+8432,U+8434,U+9232,U+FFFF:[0|0|0|17|56|12|0|0|20|22|23|0] diff --git a/test/shaping/data/aots/tests/cmap4.tests b/test/shaping/data/aots/tests/cmap4.tests new file mode 100644 index 000000000..5eaefdd9e --- /dev/null +++ b/test/shaping/data/aots/tests/cmap4.tests @@ -0,0 +1,6 @@ +#../fonts/cmap4_font1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0010,U+0011,U+0012,U+001E,U+001F,U+00C7,U+00C8,U+00CD,U+00D2,U+00D3,U+FFFF:[0|0|0|40|41|53|0|0|256|261|266|0|0] +../fonts/cmap4_font2.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0010,U+0011,U+0012,U+001E,U+001F,U+00C7,U+00C8,U+00CD,U+00D2,U+00D3,U+FFFF:[0|0|0|0|0|0|0|0|0|0|0|0|0] +#../fonts/cmap4_font3.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0010,U+0011,U+0012,U+001E,U+001F,U+00C7,U+00C8,U+00CD,U+00D2,U+00D3,U+FFFF:[0|0|0|0|0|0|0|0|0|0|0|0|65534] +#../fonts/cmap4_font4.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+AFC7,U+AFC8,U+AFC9,U+B02B,U+B02C,U+B02D:[0|0|44500|44501|44599|44600|0] +#../fonts/cmap4_font4.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+FDE7,U+FDE8,U+FDE9,U+FE0B,U+FE0C,U+FE0D,U+FE4C,U+FE4D:[0|0|65500|65501|65535|0] +#../fonts/cmap4_font4.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0063,U+0064,U+01F3,U+01F4,U+01F5,U+03E8,U+03E9:[0|0|65136|65535|0|1|500|0] diff --git a/test/shaping/data/aots/tests/cmap6.tests b/test/shaping/data/aots/tests/cmap6.tests new file mode 100644 index 000000000..cb64f55f0 --- /dev/null +++ b/test/shaping/data/aots/tests/cmap6.tests @@ -0,0 +1,2 @@ +../fonts/cmap6_font1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0021,U+0022,U+0023,U+0024,U+0025,U+FFFF:[0|0|0|17|56|12|0|0] +../fonts/cmap6_font2.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0021,U+0022,U+0023,U+0024,U+0025,U+FFFF:[0|0|0|0|0|0|0|0] diff --git a/test/shaping/data/aots/tests/cmap8.tests b/test/shaping/data/aots/tests/cmap8.tests new file mode 100644 index 000000000..128e7612e --- /dev/null +++ b/test/shaping/data/aots/tests/cmap8.tests @@ -0,0 +1 @@ +#../fonts/cmap8_font1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+0000,U+0001,U+0033,U+0034,U+0035,U+0036,U+0037,U+8431,U+8432,U+8434,U+9232,U+109422,U+109423,U+109424,U+109425,U+FFFF:[0|0|0|17|56|12|0|0|20|22|23|0|26|27|32|0]