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