Blame test/shaping/README.md

Packit Service 5bcba8
Adding tests
Packit Service 5bcba8
============
Packit Service 5bcba8
Packit Service 5bcba8
You can test shaping of a unicode sequence against a font like this:
Packit Service 5bcba8
```sh
Packit Service 5bcba8
$ ./hb-unicode-encode 41 42 43 627 | ../../util/hb-shape font.ttf
Packit Service 5bcba8
```
Packit Service 5bcba8
assuming an in-tree build.  The 41 42 43 627 here is a sequence of
Packit Service 5bcba8
Unicode codepoints: U+0041,0042,0043,0627.  When you are happy with
Packit Service 5bcba8
the shape results, you can use the `record-test.sh` script to add
Packit Service 5bcba8
this to the test suite.  `record-test.sh` requires `pyftsubset` to
Packit Service 5bcba8
be installed.  You can get `pyftsubset` by installing
Packit Service 5bcba8
FontTools from <https://github.com/behdad/fonttools>.
Packit Service 5bcba8
Packit Service 5bcba8
To use `record-test.sh`, just put it right before the `hb-shape` invocation:
Packit Service 5bcba8
```sh
Packit Service 5bcba8
$ ./hb-unicode-encode 41 42 43 627 | ./record-test.sh ../../util/hb-shape font.ttf
Packit Service 5bcba8
```
Packit Service 5bcba8
what this does is:
Packit Service 5bcba8
  * Subset the font for the sequence of Unicode characters requested,
Packit Service 5bcba8
  * Compare the `hb-shape` output of the original font versus the subset
Packit Service 5bcba8
    font for the input sequence,
Packit Service 5bcba8
  * If the outputs differ, perhaps it is because the font does not have
Packit Service 5bcba8
    glyph names; it then compares the output of `hb-view` for both fonts.
Packit Service 5bcba8
  * If the outputs differ, recording fails.  Otherwise, it will move the
Packit Service 5bcba8
    subset font file into `fonts/sha1sum` and name it after its hash,
Packit Service 5bcba8
    and prints out the test case input, which you can then redirect to
Packit Service 5bcba8
    an existing or new test file in `tests`, eg.:
Packit Service 5bcba8
```sh
Packit Service 5bcba8
$ ./hb-unicode-encode 41 42 43 627 | ./record-test.sh ../../util/hb-shape font.ttf >> tests/test-name.test
Packit Service 5bcba8
```
Packit Service 5bcba8
Packit Service 5bcba8
If you created a new test file, add it to `Makefile.am` so it is run.
Packit Service 5bcba8
Check that `make check` does indeed run it, and that the test passes.
Packit Service 5bcba8
When everything looks good, `git add` the new font as well as new
Packit Service 5bcba8
test file if you created any.  You can see what new files are there
Packit Service 5bcba8
by running `git status tests fonts/sha1sum`.  And commit!
Packit Service 5bcba8
Packit Service 5bcba8
*Note!*  Please only add tests using Open Source fonts, preferably under
Packit Service 5bcba8
OFL or similar license.