[test] Add AOTS cmap tests

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.
This commit is contained in:
Khaled Hosny 2021-07-28 16:29:43 +02:00 committed by Behdad Esfahbod
parent 50379fbb15
commit 8396c523b6
10 changed files with 110 additions and 0 deletions

View File

@ -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 \

View File

@ -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,

View File

@ -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',

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]