Skip to content

Add Swash test harness #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
[submodule "src/third_party/allsorts/allsorts-tools"]
path = src/third_party/allsorts/allsorts-tools
url = https://github.com/yeslogic/allsorts-tools
[submodule "src/third_party/swash/swash"]
path = src/third_party/swash/swash
url = https://github.com/dfrg/swash
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $ for engine in CoreText FreeStack TehreerStack fontkit OpenType.js Allsorts ; d

## Supported Platforms

Currently, the test suite supports six OpenType implementations:
Currently, the test suite supports seven OpenType implementations:

* With `--engine=FreeStack`, the tests are run on the free/libre
open-source text rendering stack with [FreeType](https://www.freetype.org/),
Expand Down Expand Up @@ -45,12 +45,21 @@ text rendering stack consisting of [FreeType](https://www.freetype.org/),
a parsing and shaping engine implemented in [Rust](https://www.rust-lang.org/).
— [Test report for Allsorts](https://rawgit.com/unicode-org/text-rendering-tests/master/reports/Allsorts.html).

It’s trivial to test other implementations; simply write a small
wrapper tool. For the [Go font
* With `--engine=Swash`, the tests are run using [Swash](https://github.com/dfrg/swash),
a parsing, shaping, and scaling/rendering engine also implemented in [Rust](https://www.rust-lang.org/).
— [Test report for Swash](https://rawgit.com/unicode-org/text-rendering-tests/master/reports/Swash.html).

It’s trivial to test other implementations; simply write a small wrapper
tool:

- For the [Go font
library](https://godoc.org/golang.org/x/image/font/sfnt), see
[here](https://github.com/golang/go/issues/20208). For the [Rust font
library](https://github.com/google/font-rs), see
[here](https://github.com/google/font-rs/issues/17).
[here](https://github.com/golang/go/issues/20208).

- For the [Rust font library](https://github.com/google/font-rs), see
[here](https://github.com/google/font-rs/issues/17). You may be able to
reuse (or factor out) the argument parsing and SVG-writing parts of the
[Swash test harness](./src/fonttest-swash-harness/) as a starting point.


## Test Cases
Expand Down
17 changes: 16 additions & 1 deletion check.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def __init__(self, engine):
self.command = (
"src/third_party/allsorts/allsorts-tools/target/release/allsorts"
)
elif self.engine == "Swash":
self.command = (
"src/fonttest-swash-harness/target/release/fonttest-swash-harness"
)
else:
self.command = "build/fonttest/fonttest"
self.datestr = self.make_datestr()
Expand All @@ -54,7 +58,7 @@ def __init__(self, engine):
self.observed = {} # testcase --> SVG ElementTree

def get_version(self):
if self.engine in {"CoreText", "FreeStack", "TehreerStack", "Allsorts"}:
if self.engine in {"CoreText", "FreeStack", "TehreerStack", "Allsorts", "Swash"}:
return subprocess.check_output(
[self.command, "--version", "--engine=" + self.engine]
).decode("utf-8")
Expand Down Expand Up @@ -237,6 +241,16 @@ def build(engine):
"src/third_party/allsorts/allsorts-tools/Cargo.toml",
]
)
elif engine == "Swash":
subprocess.check_call(
[
"cargo",
"build",
"--release",
"--manifest-path",
"src/fonttest-swash-harness/Cargo.toml",
]
)
else:
if not os.path.exists("build"):
os.mkdir("build")
Expand All @@ -258,6 +272,7 @@ def main():
"OpenType.js",
"fontkit",
"Allsorts",
"Swash"
],
default="FreeStack",
)
Expand Down
7,626 changes: 7,626 additions & 0 deletions reports/Swash.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/fonttest-swash-harness/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
152 changes: 152 additions & 0 deletions src/fonttest-swash-harness/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/fonttest-swash-harness/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "fonttest-swash-harness"
version = "0.1.0"
edition = "2024"

[dependencies]
# If you update swash, be sure to update the version number in src/main.rs as well!
swash = { path = "../third_party/swash/swash" }
lexopt = "0.3"
quick-xml = "0.37"
ttf-parser = "0.25"
unicode-bidi = "0.3"
Loading