diff --git a/Tests/varLib/data/Build2.designspace b/Tests/varLib/data/Build2.designspace
new file mode 100644
index 000000000..64f9de7b8
--- /dev/null
+++ b/Tests/varLib/data/Build2.designspace
@@ -0,0 +1,294 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/varLib/data/InterpolateLayout2.designspace b/Tests/varLib/data/InterpolateLayout2.designspace
new file mode 100644
index 000000000..b686c08a0
--- /dev/null
+++ b/Tests/varLib/data/InterpolateLayout2.designspace
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/varLib/data/InterpolateLayout3.designspace b/Tests/varLib/data/InterpolateLayout3.designspace
new file mode 100644
index 000000000..37645293d
--- /dev/null
+++ b/Tests/varLib/data/InterpolateLayout3.designspace
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/varLib/data/test_results/Build3.ttx b/Tests/varLib/data/test_results/Build3.ttx
new file mode 100644
index 000000000..b6819b9bb
--- /dev/null
+++ b/Tests/varLib/data/test_results/Build3.ttx
@@ -0,0 +1,768 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ wght
+ 0.0
+ 0.0
+ 1000.0
+ 257
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/varLib/data/test_results/BuildMain.ttx b/Tests/varLib/data/test_results/BuildMain.ttx
new file mode 100644
index 000000000..9d56a414e
--- /dev/null
+++ b/Tests/varLib/data/test_results/BuildMain.ttx
@@ -0,0 +1,2197 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Weight
+
+
+ Contrast
+
+
+ ExtraLight
+
+
+ TestFamily-ExtraLight
+
+
+ Light
+
+
+ TestFamily-Light
+
+
+ Regular
+
+
+ TestFamily-Regular
+
+
+ Semibold
+
+
+ TestFamily-Semibold
+
+
+ Bold
+
+
+ TestFamily-Bold
+
+
+ Black
+
+
+ TestFamily-Black
+
+
+ Black Medium Contrast
+
+
+ TestFamily-BlackMediumContrast
+
+
+ Black High Contrast
+
+
+ TestFamily-BlackHighContrast
+
+
+ Test Family
+
+
+ Regular
+
+
+ Version 1.001;ADBO;Test Family Regular
+
+
+ Test Family
+
+
+ Version 1.001
+
+
+ TestFamily-Master1
+
+
+ Frank Grießhammer
+
+
+ Master 1
+
+
+ Weight
+
+
+ Contrast
+
+
+ ExtraLight
+
+
+ TestFamily-ExtraLight
+
+
+ Light
+
+
+ TestFamily-Light
+
+
+ Regular
+
+
+ TestFamily-Regular
+
+
+ Semibold
+
+
+ TestFamily-Semibold
+
+
+ Bold
+
+
+ TestFamily-Bold
+
+
+ Black
+
+
+ TestFamily-Black
+
+
+ Black Medium Contrast
+
+
+ TestFamily-BlackMediumContrast
+
+
+ Black High Contrast
+
+
+ TestFamily-BlackHighContrast
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ wght
+ 0.0
+ 368.0
+ 1000.0
+ 256
+
+
+
+
+ cntr
+ 0.0
+ 0.0
+ 100.0
+ 257
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/varLib/data/test_results/InterpolateLayout2.ttx b/Tests/varLib/data/test_results/InterpolateLayout2.ttx
new file mode 100644
index 000000000..37461c4be
--- /dev/null
+++ b/Tests/varLib/data/test_results/InterpolateLayout2.ttx
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/Tests/varLib/data/test_results/InterpolateLayoutMain.ttx b/Tests/varLib/data/test_results/InterpolateLayoutMain.ttx
new file mode 100644
index 000000000..dc6caf7e2
--- /dev/null
+++ b/Tests/varLib/data/test_results/InterpolateLayoutMain.ttx
@@ -0,0 +1,478 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Test Family
+
+
+ Regular
+
+
+ Version 1.001;ADBO;Test Family Regular
+
+
+ Test Family
+
+
+ Version 1.001
+
+
+ TestFamily-Master1
+
+
+ Frank Grießhammer
+
+
+ Master 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/varLib/interpolate_layout_test.py b/Tests/varLib/interpolate_layout_test.py
index e1351f7a6..90bcb340f 100644
--- a/Tests/varLib/interpolate_layout_test.py
+++ b/Tests/varLib/interpolate_layout_test.py
@@ -1,7 +1,9 @@
from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from fontTools.ttLib import TTFont
+from fontTools.varLib import build
from fontTools.varLib.interpolate_layout import interpolate_layout
+from fontTools.varLib.interpolate_layout import main as interpolate_layout_main
import difflib
import os
import shutil
@@ -37,10 +39,13 @@ class InterpolateLayoutTest(unittest.TestCase):
return os.path.join(path, "data", "test_results", test_file_or_folder)
@staticmethod
- def get_file_list(folder, suffix):
+ def get_file_list(folder, suffix, prefix=''):
all_files = os.listdir(folder)
- return [os.path.abspath(os.path.join(folder, p)) for p in all_files
- if p.endswith(suffix)]
+ file_list = []
+ for p in all_files:
+ if p.startswith(prefix) and p.endswith(suffix):
+ file_list.append(os.path.abspath(os.path.join(folder, p)))
+ return file_list
def temp_path(self, suffix):
self.temp_dir()
@@ -104,8 +109,8 @@ class InterpolateLayoutTest(unittest.TestCase):
ufo_dir = self.get_test_input('master_ufo')
ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf')
- ttx_paths = self.get_file_list(ttx_dir, '.ttx')
self.temp_dir()
+ ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily2-')
for path in ttx_paths:
self.compile_font(path, suffix, self.tempdir)
@@ -118,5 +123,88 @@ class InterpolateLayoutTest(unittest.TestCase):
self.check_ttx_dump(instfont, expected_ttx_path, tables, suffix)
+ def test_varlib_interpolate_layout_no_GSUB_ttf(self):
+ """The base master has no GSUB table.
+
+ The variable font will end up without a GSUB table.
+ """
+ suffix = '.ttf'
+ ds_path = self.get_test_input('InterpolateLayout2.designspace')
+ ufo_dir = self.get_test_input('master_ufo')
+ ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf')
+
+ self.temp_dir()
+ ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily2-')
+ for path in ttx_paths:
+ self.compile_font(path, suffix, self.tempdir)
+
+ finder = lambda s: s.replace(ufo_dir, self.tempdir).replace('.ufo', suffix)
+ instfont = interpolate_layout(ds_path, {'weight': 500}, finder)
+
+ tables = ['GSUB']
+ expected_ttx_path = self.get_test_output('InterpolateLayout2.ttx')
+ self.expect_ttx(instfont, expected_ttx_path, tables)
+ self.check_ttx_dump(instfont, expected_ttx_path, tables, suffix)
+
+
+ def test_varlib_interpolate_layout_GSUB_only_no_axes_ttf(self):
+ """Only GSUB, and only in the base master.
+ Designspace file has no element.
+
+ The variable font will inherit the GSUB table from the
+ base master.
+ """
+ suffix = '.ttf'
+ ds_path = self.get_test_input('InterpolateLayout3.designspace')
+ ufo_dir = self.get_test_input('master_ufo')
+ ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf')
+
+ self.temp_dir()
+ ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily2-')
+ for path in ttx_paths:
+ self.compile_font(path, suffix, self.tempdir)
+
+ finder = lambda s: s.replace(ufo_dir, self.tempdir).replace('.ufo', suffix)
+ instfont = interpolate_layout(ds_path, {'weight': 500}, finder)
+
+ tables = ['GSUB']
+ expected_ttx_path = self.get_test_output('InterpolateLayout.ttx')
+ self.expect_ttx(instfont, expected_ttx_path, tables)
+ self.check_ttx_dump(instfont, expected_ttx_path, tables, suffix)
+
+
+ def test_varlib_interpolate_layout_main_ttf(self):
+ """Mostly for testing varLib.interpolate_layout.main()
+ """
+ suffix = '.ttf'
+ ds_path = self.get_test_input('Build.designspace')
+ ufo_dir = self.get_test_input('master_ufo')
+ ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf')
+
+ self.temp_dir()
+ ttf_dir = os.path.join(self.tempdir, 'master_ttf_interpolatable')
+ os.makedirs(ttf_dir)
+ ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily-')
+ for path in ttx_paths:
+ self.compile_font(path, suffix, ttf_dir)
+
+ finder = lambda s: s.replace(ufo_dir, ttf_dir).replace('.ufo', suffix)
+ varfont, _, _ = build(ds_path, finder)
+ varfont_name = 'InterpolateLayoutMain'
+ varfont_path = os.path.join(self.tempdir, varfont_name + suffix)
+ varfont.save(varfont_path)
+
+ ds_copy = os.path.splitext(varfont_path)[0] + '.designspace'
+ shutil.copy2(ds_path, ds_copy)
+ args = [ds_copy, 'wght=500', 'cntr=50']
+ interpolate_layout_main(args)
+
+ instfont_path = os.path.splitext(varfont_path)[0] + '-instance' + suffix
+ instfont = TTFont(instfont_path)
+ tables = [table_tag for table_tag in instfont.keys() if table_tag != 'head']
+ expected_ttx_path = self.get_test_output(varfont_name + '.ttx')
+ self.expect_ttx(instfont, expected_ttx_path, tables)
+
+
if __name__ == "__main__":
sys.exit(unittest.main())
diff --git a/Tests/varLib/mutator_test.py b/Tests/varLib/mutator_test.py
index efebf710c..a17eada59 100644
--- a/Tests/varLib/mutator_test.py
+++ b/Tests/varLib/mutator_test.py
@@ -38,10 +38,13 @@ class MutatorTest(unittest.TestCase):
return os.path.join(path, "data", "test_results", test_file_or_folder)
@staticmethod
- def get_file_list(folder, suffix):
+ def get_file_list(folder, suffix, prefix=''):
all_files = os.listdir(folder)
- return [os.path.abspath(os.path.join(folder, p)) for p in all_files
- if p.endswith(suffix)]
+ file_list = []
+ for p in all_files:
+ if p.startswith(prefix) and p.endswith(suffix):
+ file_list.append(os.path.abspath(os.path.join(folder, p)))
+ return file_list
def temp_path(self, suffix):
self.temp_dir()
@@ -94,8 +97,8 @@ class MutatorTest(unittest.TestCase):
ufo_dir = self.get_test_input('master_ufo')
ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf')
- ttx_paths = self.get_file_list(ttx_dir, '.ttx')
self.temp_dir()
+ ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily-')
for path in ttx_paths:
self.compile_font(path, suffix, self.tempdir)
@@ -111,8 +114,8 @@ class MutatorTest(unittest.TestCase):
instfont_path = os.path.splitext(varfont_path)[0] + '-instance' + suffix
instfont = TTFont(instfont_path)
tables = [table_tag for table_tag in instfont.keys() if table_tag != 'head']
- expected_ttx = self.get_test_output(varfont_name + '.ttx')
- self.expect_ttx(instfont, expected_ttx, tables)
+ expected_ttx_path = self.get_test_output(varfont_name + '.ttx')
+ self.expect_ttx(instfont, expected_ttx_path, tables)
if __name__ == "__main__":
diff --git a/Tests/varLib/varLib_test.py b/Tests/varLib/varLib_test.py
index 592d680b6..f25f8d3e7 100644
--- a/Tests/varLib/varLib_test.py
+++ b/Tests/varLib/varLib_test.py
@@ -2,6 +2,7 @@ from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from fontTools.ttLib import TTFont
from fontTools.varLib import build
+from fontTools.varLib import main as varLib_main
import difflib
import os
import shutil
@@ -37,10 +38,13 @@ class BuildTest(unittest.TestCase):
return os.path.join(path, "data", "test_results", test_file_or_folder)
@staticmethod
- def get_file_list(folder, suffix):
+ def get_file_list(folder, suffix, prefix=''):
all_files = os.listdir(folder)
- return [os.path.abspath(os.path.join(folder, p)) for p in all_files
- if p.endswith(suffix)]
+ file_list = []
+ for p in all_files:
+ if p.startswith(prefix) and p.endswith(suffix):
+ file_list.append(os.path.abspath(os.path.join(folder, p)))
+ return file_list
def temp_path(self, suffix):
self.temp_dir()
@@ -94,13 +98,16 @@ class BuildTest(unittest.TestCase):
# -----
def test_varlib_build_ttf(self):
+ """Designspace file contains element.
+ build() is called without an axisMap parameter.
+ """
suffix = '.ttf'
ds_path = self.get_test_input('Build.designspace')
ufo_dir = self.get_test_input('master_ufo')
ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf')
- ttx_paths = self.get_file_list(ttx_dir, '.ttx')
self.temp_dir()
+ ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily-')
for path in ttx_paths:
self.compile_font(path, suffix, self.tempdir)
@@ -113,5 +120,78 @@ class BuildTest(unittest.TestCase):
self.check_ttx_dump(varfont, expected_ttx_path, tables, suffix)
+ def test_varlib_build2_ttf(self):
+ """Designspace file does not contain an element.
+ build() is called with an axisMap parameter.
+ """
+ suffix = '.ttf'
+ ds_path = self.get_test_input('Build2.designspace')
+ ufo_dir = self.get_test_input('master_ufo')
+ ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf')
+
+ self.temp_dir()
+ ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily-')
+ for path in ttx_paths:
+ self.compile_font(path, suffix, self.tempdir)
+
+ axisMap = {'contrast': ('cntr', 'Contrast')}
+ finder = lambda s: s.replace(ufo_dir, self.tempdir).replace('.ufo', suffix)
+ varfont, model, _ = build(ds_path, finder, axisMap)
+
+ tables = ['GDEF', 'HVAR', 'fvar', 'gvar']
+ expected_ttx_path = self.get_test_output('Build.ttx')
+ self.expect_ttx(varfont, expected_ttx_path, tables)
+ self.check_ttx_dump(varfont, expected_ttx_path, tables, suffix)
+
+
+ def test_varlib_build3_ttf(self):
+ """Designspace file does not contain an element.
+ build() is called without an axisMap parameter.
+ """
+ suffix = '.ttf'
+ ds_path = self.get_test_input('InterpolateLayout3.designspace')
+ ufo_dir = self.get_test_input('master_ufo')
+ ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf')
+
+ self.temp_dir()
+ ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily2-')
+ for path in ttx_paths:
+ self.compile_font(path, suffix, self.tempdir)
+
+ finder = lambda s: s.replace(ufo_dir, self.tempdir).replace('.ufo', suffix)
+ varfont, model, _ = build(ds_path, finder)
+
+ tables = ['GDEF', 'HVAR', 'fvar', 'gvar']
+ expected_ttx_path = self.get_test_output('Build3.ttx')
+ self.expect_ttx(varfont, expected_ttx_path, tables)
+ self.check_ttx_dump(varfont, expected_ttx_path, tables, suffix)
+
+
+ def test_varlib_main_ttf(self):
+ """Mostly for testing varLib.main()
+ """
+ suffix = '.ttf'
+ ds_path = self.get_test_input('Build.designspace')
+ ufo_dir = self.get_test_input('master_ufo')
+ ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf')
+
+ self.temp_dir()
+ ttf_dir = os.path.join(self.tempdir, 'master_ttf_interpolatable')
+ os.makedirs(ttf_dir)
+ ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily-')
+ for path in ttx_paths:
+ self.compile_font(path, suffix, ttf_dir)
+
+ ds_copy = os.path.join(self.tempdir, 'BuildMain.designspace')
+ shutil.copy2(ds_path, ds_copy)
+ varLib_main([ds_copy])
+
+ varfont_path = os.path.splitext(ds_copy)[0] + '-VF' + suffix
+ varfont = TTFont(varfont_path)
+ tables = [table_tag for table_tag in varfont.keys() if table_tag != 'head']
+ expected_ttx_path = self.get_test_output('BuildMain.ttx')
+ self.expect_ttx(varfont, expected_ttx_path, tables)
+
+
if __name__ == "__main__":
sys.exit(unittest.main())