Skip to content

Commit 6039f5f

Browse files
committed
Update Shaping checks documentation
1 parent 0250b03 commit 6039f5f

File tree

4 files changed

+96
-54
lines changed

4 files changed

+96
-54
lines changed

examples/shaping.md

+23-16
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
Examples for the shaping check
2-
==============================
1+
# (Text) Shaping checks
32

4-
As well as finding structural issues with a font, openbakery contains a
5-
check profile (`openbakery.profiles.shaping`) which ensures that the
6-
font's OpenType layout rules behave as designed. To run this check, the
7-
designer must supply one or more test suites, which are represented as
8-
JSON files.
3+
In addition to helping you find structural issues in a font, OpenBakery contains
4+
a Shaping profile that can be used for validating that a font's OpenType layout
5+
features work as expected. To run the Shaping profile checks you need to provide
6+
one or more test suite files. These files are written in JSON format and include
7+
the parameters and values required by the checks.
98

10-
The `shaping/` directory contains a number of JSON files which
11-
illustrate the expected format and syntax of these test suites. They are also documented with comments to explain the intent of tests and how they can be customised. Copying and modifying these files can form a basis for your own shaping test suite.
9+
The [**shaping**](./shaping/) directory includes a few examples of such test suite
10+
files to illustrate the expected format and syntax the JSON files must follow.
11+
They are also annotated with comments that explain the intent of tests and how
12+
they can be customized. Copying and modifying these files can form the basis for
13+
your own text shaping test suite.
1214

13-
To run the shaping check, you need to tell openbakery where to find your test suite. This can be done by creating a openbakery configuration file in YAML format and specifying the directory where the JSON files can be found:
15+
To run the Shaping checks, you first need to instruct `openbakery` where your test
16+
suite files are located. This can be done by creating a configuration file in YAML
17+
format. Its contents will specify the directory where the JSON files can be found:
1418

1519
```
1620
com.google.fonts/check/shaping:
1721
test_directory: examples/shaping
1822
```
1923

20-
If this file is saved as (e.g.) `openbakery.yml`, then the shaping check can be run with the following command:
24+
After saving this file — as `shaping.yml`, for example — you can then run
25+
the Shaping profile checks using the following command:
2126

22-
```
23-
openbakery check-profile --config openbakery.yml openbakery.profiles.shaping Font.ttf
24-
```
27+
openbakery shaping --config shaping.yml Font.ttf
28+
29+
For best results, generate an HTML report using the `--html` option.
30+
31+
openbakery shaping --config shaping.yml --html shaping.html Font.ttf
2532

26-
For best results, generate a HTML report using the `--html report.html` flag to openbakery, as this will contain SVG illustrations for failing tests.
33+
The report will include SVG illustrations for any failing tests.
2734

28-
For more information on the shaping check, see https://simoncozens.github.io/tdd-for-otl/
35+
For more information on the Shaping checks, see https://simoncozens.github.io/tdd-for-otl/

examples/shaping/01-regression.json

+40-17
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,56 @@
11
{
2+
"configuration": {
3+
"comment": "This is a basic configuration file for using with the Shaping profile.",
4+
"comment2": "It contains examples of text shaping tests that can be used for validating",
5+
"comment3": "that a font's OpenType layout features work as expected. A configuration",
6+
"comment4": "file of this kind can also be assembled to represent a snapshot of a font's",
7+
"comment5": "OpenType layout functionality, and be used to test if any changes occur",
8+
"comment6": "whenever a new version of the font is produced.",
9+
"comment7": "At a minimum, this file must contain a key named 'tests' whose value",
10+
"comment8": "is an array of test blocks. Each of these blocks must include at least",
11+
"comment9": "two keys named 'input' and 'expectation'.",
12+
"comment10": "These comments as well as the whole 'configuration' block are not required",
13+
"comment11": "for running the text shaping tests and can be removed."
14+
},
215
"tests": [
316
{
17+
"comment": "A simple test using only glyph names (without positions)",
418
"input": "fi",
5-
"expectation": "f_i",
6-
"comment": "A simple test with only glyph names, not positions"
19+
"expectation": "f_i"
720
},
821
{
22+
"comment": "Expected positions may be specified using Harfbuzz's hb-shape syntax",
23+
"comment2": "(see https://harfbuzz.github.io/utilities.html#utilities-command-line-hbshape)",
24+
"input": "AVḲ",
25+
"expectation": "A=0+679|V=1+676|K=2+707|dotbelowcomb.case=2@-250,0+0"
26+
},
27+
{
28+
"comment": "Depending on your platform, the subshapers supported by",
29+
"comment2": "'uharfbuzz' may be invoked using the 'shaper' key.",
30+
"comment3": "'directwrite' and 'uniscribe' are available on Windows,",
31+
"comment4": "and 'coretext' is available on macOS",
32+
"input": "AVḲ",
33+
"shaper": "coretext",
34+
"expectation": "A=0+679|V=1+676|K=2+707|dotbelowcomb.case=2@-250,0+0"
35+
},
36+
{
37+
"comment": "Features may be specified using the 'features' key",
38+
"comment2": "(see https://learn.microsoft.com/typography/opentype/spec/featurelist)",
939
"input": "pi",
1040
"features": { "smcp": true },
11-
"expectation": "p.sc|i.sc",
12-
"comment": "Features may be specified using the features key"
41+
"expectation": "p.sc|i.sc"
1342
},
1443
{
44+
"comment": "Languages may be specified using the 'language' key",
45+
"comment2": "(see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)",
46+
"comment3": "It's also possible to specify the 'script'",
47+
"comment4": "(see https://learn.microsoft.com/typography/opentype/spec/scripttags)",
48+
"comment5": "and the 'direction'; supported values are 'LTR' (left-to-right),",
49+
"comment6": "'RTL' (right-to-left), 'TTB' (top-to-bottom), and 'BTT'.",
1550
"input": "pi",
1651
"features": { "smcp": true },
1752
"language": "tr",
18-
"expectation": "p.sc|i.sc.loclTRK",
19-
"comment": "Languages may be specified using the language key"
20-
},
21-
{
22-
"input": "AVḲ",
23-
"expectation": "A=0+679|V=1+676|K=2+707|dotbelowcomb.case=2@-250,0+0",
24-
"comment": "Expected positions may be specified using Harfbuzz hb-shape syntax"
25-
},
26-
{
27-
"input": "AVḲ",
28-
"expectation": "A=0+679|V=1+676|K=2+707|dotbelowcomb.case=2@-250,0+0",
29-
"shaper": "coretext",
30-
"comment": "If your uharfbuzz is compiled with other subshapers, these can be accessed through the shaper key."
53+
"expectation": "p.sc|i.sc.loclTRK"
3154
}
3255
]
3356
}
+16-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
{
22
"configuration": {
3+
"comment": "(For context, read the comments in '01-regression.json' first)",
4+
"comment1": "This is another example of a configuration file to be used with the Shaping profile.",
5+
"comment2": "In this example, the 'forbidden_glyphs' mode is activated (by using the corresponding",
6+
"comment3": "key and an array of glyph names as the value). This mode will mark as FAIL any tests",
7+
"comment4": "whose shaping results include a forbidden glyph. In this mode the test blocks are not",
8+
"comment5": "required to include a 'expectation' key to yield results.",
9+
"comment6": "In sum, this kind of configuration can be used for checking if any glyphs declared as",
10+
"comment7": "forbidden are found in the shaping results.",
311
"forbidden_glyphs": [".notdef", "uni25CC"]
412
},
513
"tests": [
614
{
15+
"comment": "Basic tests will work as before...",
716
"input": "fi",
8-
"expectation": "f_i",
9-
"comment": "Ordinary tests will be run as before..."
17+
"expectation": "f_i"
1018
},
1119
{
12-
"input": "世界",
13-
"comment": "...but now any test (even without an expectation) which shapes a .notdef will fail"
20+
"comment": "...but now any tests (even without an 'expectation') whose shaping results include",
21+
"comment1": "a forbidden glyph, will be marked as FAIL. (NOTE: for this example to yield FAIL",
22+
"comment2": "it's necessary to use a font that does NOT support the characters shown below.",
23+
"comment3": "The FAIL occurs because the text shaper will render any unsupported characters",
24+
"comment4": "as a '.notdef' glyph — which the configuration specifies as being forbidden)",
25+
"input": "世界"
1426
}
1527
]
1628
}

examples/shaping/03-collisions.json

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"configuration": {
33
"collidoscope": {
4+
"comment": "The parameters in this block are passed to the Python 'collidoscope' module.",
5+
"comment2": "The set of parameters specified below should detect all collisions.",
6+
"comment3": "If these are too strict for your needs, try changing or removing them.",
47
"area": 0,
58
"marks": true,
6-
"faraway": true,
7-
"comment": "The parameters in this block are passed to the Python collidoscope module.",
8-
"comment2": "The set of parameters specified above should detect all collisions.",
9-
"comment3": "If these are too strict for your needs, try changing or removing them."
9+
"faraway": true
1010
},
1111
"ingredients": {
1212
"vowel": "[aeiou]",
1313
"lowercase": "[a-z]",
1414
"accented_glyph": "[\u00e0-\u017e]"
1515
},
1616
"defaults": {
17-
"comment": "The contents of the defaults block is added to every test dictionary",
17+
"comment": "The contents of the 'defaults' block are added to all of the test blocks below",
1818
"allowedcollisions": [
1919
"medialYa-myanmar/aaSign-myanmar",
2020
"medialWa-myanmar/medialYa-myanmar.bt1"
@@ -23,27 +23,27 @@
2323
},
2424
"tests": [
2525
{
26+
"comment": "Again, tests with expectations are treated as (basic) regression tests.",
2627
"input": "fi",
27-
"expectation": "f_i",
28-
"comment": "Again, tests with expectations are treated as regression tests."
28+
"expectation": "f_i"
2929
},
3030
{
31-
"input": "ïï",
32-
"comment": "But tests (even without expectations) are now checked for collisions."
31+
"comment": "But tests (even without expectations) are now checked for collisions.",
32+
"input": "ïï"
3333
},
3434
{
35+
"comment": "If the value of 'input_type' is 'pattern', the input is interpreted as a set of 'ingredients'.",
36+
"comment2": "This means that all possible inputs matching the pattern are then checked for collisions.",
37+
"comment3": "In this case, 'aa', 'ae', 'ai', 'ao', 'ao', 'au', 'ea', ... will be shaped and checked.",
3538
"input_type": "pattern",
36-
"input": "vowel vowel",
37-
"comment": "If input_type is set to pattern, the input is interpreted as a set of *ingredients*",
38-
"comment2": "All possible inputs matching the pattern are then checked for collisions.",
39-
"comment3": "In this case, 'aa', 'ae', 'ai', 'ao', 'ao', 'au', 'ea', ... will be shaped and checked."
39+
"input": "vowel vowel"
4040
},
4141
{
42+
"comment": "Ingredients are based on Python regular expressions.",
43+
"comment2": "In this example all two- and three-character sequences of all accented glyphs will be checked.",
44+
"comment3": "For more information see the Python 'stringbrewer' module.",
4245
"input_type": "pattern",
43-
"input": "accented_glyph{2,3}",
44-
"comment": "Ingredients are based on Python regular expressions",
45-
"comment2": "This checks all two- and three-character sequences of all accented glyphs",
46-
"comment3": "For more information see the Python stringbrewer module"
46+
"input": "accented_glyph{2,3}"
4747
}
4848
]
4949
}

0 commit comments

Comments
 (0)