Skip to content

Commit

Permalink
Add support for OpenType.js font engine. (#31)
Browse files Browse the repository at this point in the history
This includes OpenType.js as a Git submodule, and calls the new
`test-render` command in check.py.

The build step will call `npm install`.
  • Loading branch information
fdb authored and brawer committed Apr 26, 2017
1 parent c917b9e commit 489fd48
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "src/third_party/raqm/libraqm"]
path = src/third_party/raqm/libraqm
url = https://github.com/HOST-Oman/libraqm.git
[submodule "src/third_party/opentypejs/opentype.js"]
path = src/third_party/opentypejs/opentype.js
url = https://github.com/nodebox/opentype.js.git
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ python check.py --output=report.html --engine=FreeStack

## Supported Platforms

Currently, the test suite supports only two OpenType implementations:
Currently, the test suite supports only three 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 All @@ -31,6 +31,9 @@ are used by Linux, Android, ChromeOS, and many other systems.
* With `--engine=CoreText`, the tests are run on Apple’s CoreText.
This option will work only if you run the test suite on MacOS X.

* With `--engine=OpenType.js`, the tests are run using [OpenType.js](https://github.com/nodebox/opentype.js).
This option requires Node.js to be installed.

If you’d like to test another OpenType implementation, please go ahead.


Expand Down
23 changes: 15 additions & 8 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
class ConformanceChecker:
def __init__(self, engine):
self.engine = engine
if self.engine == 'OpenType.js':
self.command = 'src/third_party/opentypejs/opentype.js/bin/test-render'
else:
self.command = 'build/out/Default/fonttest'
self.datestr = self.make_datestr()
self.reports = {} # filename --> HTML ElementTree
self.conformance = {} # testcase -> True|False
Expand All @@ -51,7 +55,7 @@ def check(self, testfile):
variation = e.attrib.get(FONTTEST_VARIATION)
expected_svg = e.find('svg')
self.normalize_svg(expected_svg)
command = ['build/out/Default/fonttest', '--font=' + font,
command = [self.command, '--font=' + font,
'--testcase=' + testcase, '--engine=' + self.engine]
if render: command.append('--render=' + render)
if variation: command.append('--variation=' + variation)
Expand Down Expand Up @@ -127,23 +131,26 @@ def write_report(self, path):
outfile.write(xml)


def build():
subprocess.check_call(
'./src/third_party/gyp/gyp -f make --depth . '
'--generator-output build src/fonttest/fonttest.gyp'.split())
subprocess.check_call(['make', '-s', '--directory', 'build'])
def build(engine):
if engine == 'OpenType.js':
subprocess.check_call(['npm', 'install'], cwd='./src/third_party/opentypejs/opentype.js')
else:
subprocess.check_call(
'./src/third_party/gyp/gyp -f make --depth . '
'--generator-output build src/fonttest/fonttest.gyp'.split())
subprocess.check_call(['make', '-s', '--directory', 'build'])


def main():
etree.register_namespace('svg', 'http://www.w3.org/2000/svg')
etree.register_namespace('xlink', 'http://www.w3.org/1999/xlink')
parser = argparse.ArgumentParser()
parser.add_argument('--engine',
choices=['FreeStack', 'CoreText', 'DirectWrite'],
choices=['FreeStack', 'CoreText', 'DirectWrite', 'OpenType.js'],
default='FreeStack')
parser.add_argument('--output', help='path to report file being written')
args = parser.parse_args()
build()
build(engine=args.engine)
checker = ConformanceChecker(engine=args.engine)
for filename in os.listdir('testcases'):
if (filename == 'index.html'
Expand Down
1 change: 1 addition & 0 deletions src/third_party/opentypejs/opentype.js
Submodule opentype.js added at 220f78

0 comments on commit 489fd48

Please sign in to comment.