• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2
3# Pre-generates the expected output subset files (via fonttools) for
4# specified subset test suite(s).
5
6import os
7import sys
8
9from subprocess import check_call
10from subset_test_suite import SubsetTestSuite
11
12
13def usage():
14	print("Usage: generate-expected-outputs.py <test suite file> ...")
15
16
17def generate_expected_output(input_file, unicodes, profile_flags, output_path):
18	args = ["fonttools", "subset", input_file]
19	args.extend(["--notdef-outline",
20		     "--layout-features=*",
21		     "--drop-tables+=DSIG",
22		     "--drop-tables-=sbix",
23		     "--unicodes=%s" % unicodes,
24		     "--output-file=%s" % output_path])
25	args.extend(profile_flags)
26	check_call(args)
27
28
29args = sys.argv[1:]
30if not args:
31	usage()
32
33for path in args:
34	with open(path, mode="r", encoding="utf-8") as f:
35		test_suite = SubsetTestSuite(path, f.read())
36		output_directory = test_suite.get_output_directory()
37
38		print("Generating output files for %s" % output_directory)
39		for test in test_suite.tests():
40			unicodes = test.unicodes()
41			font_name = test.get_font_name()
42			print("Creating subset %s/%s" % (output_directory, font_name))
43			generate_expected_output(test.font_path, unicodes, test.get_profile_flags(),
44						 os.path.join(output_directory,
45							      font_name))
46