2016-11-30 14:45:41 +01:00
|
|
|
from __future__ import print_function, division, absolute_import
|
|
|
|
|
|
|
|
from ufoLib import fontInfoAttributesVersion1, fontInfoAttributesVersion2, fontInfoAttributesVersion3
|
|
|
|
from pprint import pprint
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
A subclassed DesignSpaceDocument that can
|
|
|
|
- process the document and generate finished UFOs with MutatorMath.
|
|
|
|
- read and write
|
|
|
|
- bypass and eventually replace the mutatormath ufo generator.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
from designSpaceDocument import DesignSpaceDocument, SourceDescriptor, InstanceDescriptor, AxisDescriptor
|
|
|
|
from defcon.objects.font import Font
|
|
|
|
import defcon
|
2016-11-30 16:38:13 +01:00
|
|
|
from fontMath.mathGlyph import MathGlyph
|
|
|
|
from fontMath.mathInfo import MathInfo
|
|
|
|
from fontMath.mathKerning import MathKerning
|
2016-11-30 14:45:41 +01:00
|
|
|
from mutatorMath.objects.mutator import buildMutator
|
|
|
|
from mutatorMath.objects.location import biasFromLocations, Location
|
|
|
|
import os
|
|
|
|
|
|
|
|
class DesignSpaceProcessor(DesignSpaceDocument):
|
|
|
|
"""
|
|
|
|
builder of glyphs from designspaces
|
|
|
|
validate the data
|
|
|
|
if it works, make a generating thing
|
|
|
|
"""
|
|
|
|
|
|
|
|
fontClass = defcon.Font
|
|
|
|
glyphClass = defcon.Glyph
|
|
|
|
libClass = defcon.Lib
|
|
|
|
glyphContourClass = defcon.Contour
|
|
|
|
glyphPointClass = defcon.Point
|
|
|
|
glyphComponentClass = defcon.Component
|
|
|
|
glyphAnchorClass = defcon.Anchor
|
|
|
|
kerningClass = defcon.Kerning
|
|
|
|
groupsClass = defcon.Groups
|
|
|
|
infoClass = defcon.Info
|
|
|
|
featuresClass = defcon.Features
|
|
|
|
|
|
|
|
mathInfoClass = MathInfo
|
|
|
|
mathGlyphClass = MathGlyph
|
|
|
|
mathKerningClass = MathKerning
|
|
|
|
|
|
|
|
def __init__(self, readerClass=None, writerClass=None, fontClass=None, ufoVersion=2):
|
2016-11-30 16:47:56 +01:00
|
|
|
super(DesignSpaceProcessor, self).__init__(readerClass=None, writerClass=None, fontClass=None)
|
2016-11-30 16:52:51 +01:00
|
|
|
self.ufoVersion = ufoVersion # target UFO version
|
2016-11-30 14:45:41 +01:00
|
|
|
self.roundGeometry = False
|
2016-11-30 17:48:05 +01:00
|
|
|
self._glyphMutators = {}
|
|
|
|
self._infoMutator = None
|
|
|
|
self._kerningMutator = None
|
2016-11-30 14:45:41 +01:00
|
|
|
self.default = None # name of the default master
|
|
|
|
self.defaultLoc = None
|
|
|
|
self.fonts = {}
|
2016-11-30 17:48:05 +01:00
|
|
|
self.glyphNames = [] # list of all glyphnames
|
2016-11-30 14:45:41 +01:00
|
|
|
|
2016-11-30 17:48:05 +01:00
|
|
|
def generateUFO(self):
|
|
|
|
# makes the instances
|
|
|
|
self.loadFonts()
|
2016-11-30 14:45:41 +01:00
|
|
|
for instanceDescriptor in self.instances:
|
2016-11-30 17:48:05 +01:00
|
|
|
if instanceDescriptor.path is None:
|
|
|
|
continue
|
|
|
|
font = self.makeInstance(instanceDescriptor)
|
|
|
|
if not os.path.exists(os.path.dirname(instanceDescriptor.path)):
|
|
|
|
os.makedirs(os.path.dirname(instanceDescriptor.path))
|
|
|
|
font.save(instanceDescriptor.path, self.ufoVersion)
|
|
|
|
|
|
|
|
def getInfoMutator(self):
|
|
|
|
""" Returns a info mutator """
|
|
|
|
if self._infoMutator:
|
|
|
|
return self._infoMutator
|
2016-11-30 14:45:41 +01:00
|
|
|
infoItems = []
|
2016-11-30 17:48:05 +01:00
|
|
|
for sourceDescriptor in self.sources:
|
|
|
|
loc = Location(sourceDescriptor.location)
|
|
|
|
sourceFont = self.fonts[sourceDescriptor.name]
|
|
|
|
infoItems.append((loc, self.mathInfoClass(sourceFont.info)))
|
|
|
|
bias, self._infoMutator = buildMutator(infoItems, bias=self.defaultLoc)
|
|
|
|
return self._infoMutator
|
|
|
|
|
|
|
|
def getKerningMutator(self):
|
|
|
|
""" Return a kerning mutator """
|
|
|
|
if self._kerningMutator:
|
|
|
|
return self._kerningMutator
|
2016-11-30 14:45:41 +01:00
|
|
|
kerningItems = []
|
2016-11-30 17:48:05 +01:00
|
|
|
for sourceDescriptor in self.sources:
|
|
|
|
loc = Location(sourceDescriptor.location)
|
|
|
|
sourceFont = self.fonts[sourceDescriptor.name]
|
|
|
|
kerningItems.append((loc, self.mathKerningClass(sourceFont.kerning, sourceFont.groups)))
|
|
|
|
bias, self._kerningMutator = buildMutator(kerningItems, bias=self.defaultLoc)
|
|
|
|
return self._kerningMutator
|
|
|
|
|
|
|
|
def getGlyphMutator(self, glyphName):
|
|
|
|
""" Return a glyph mutator """
|
|
|
|
if glyphName in self._glyphMutators:
|
|
|
|
return self._glyphMutators[glyphName]
|
|
|
|
items = []
|
2016-11-30 14:45:41 +01:00
|
|
|
for sourceDescriptor in self.sources:
|
|
|
|
loc = Location(sourceDescriptor.location)
|
|
|
|
f = self.fonts[sourceDescriptor.name]
|
2016-11-30 17:48:05 +01:00
|
|
|
if glyphName in sourceDescriptor.mutedGlyphNames:
|
|
|
|
continue
|
|
|
|
items.append((loc, self.mathGlyphClass(f[glyphName])))
|
|
|
|
bias, self._glyphMutators[glyphName] = buildMutator(items, bias=self.defaultLoc)
|
|
|
|
return self._glyphMutators[glyphName]
|
|
|
|
|
|
|
|
def loadFonts(self):
|
|
|
|
# Load the fonts and find the default candidate based on the info flag
|
2016-11-30 14:45:41 +01:00
|
|
|
defaultCandidate = None
|
|
|
|
for sourceDescriptor in self.sources:
|
2016-11-30 17:48:05 +01:00
|
|
|
names = set()
|
2016-11-30 14:45:41 +01:00
|
|
|
if not sourceDescriptor.name in self.fonts:
|
|
|
|
self.fonts[sourceDescriptor.name] = self._instantiateFont(sourceDescriptor.path)
|
2016-11-30 17:48:05 +01:00
|
|
|
names = names | set(self.fonts[sourceDescriptor.name].keys())
|
2016-11-30 14:45:41 +01:00
|
|
|
if sourceDescriptor.copyInfo:
|
|
|
|
# we choose you!
|
|
|
|
defaultCandidate = sourceDescriptor
|
2016-11-30 17:48:05 +01:00
|
|
|
self.glyphNames = list(names)
|
2016-11-30 14:45:41 +01:00
|
|
|
# find the default based on mutatorMath bias
|
|
|
|
masterLocations = [Location(src.location) for src in self.sources]
|
|
|
|
mutatorBias = biasFromLocations(masterLocations)
|
|
|
|
c = [src for src in self.sources if src.location==mutatorBias]
|
|
|
|
if c:
|
|
|
|
mutatorDefaultCandidate = c[0]
|
|
|
|
else:
|
|
|
|
mutatorDefaultCandidate = None
|
|
|
|
# what are we going to do?
|
|
|
|
if defaultCandidate is not None and mutatorDefaultCandidate.name != defaultCandidate.name:
|
|
|
|
# warn if we have a conflict
|
|
|
|
print("Note: conflicting default masters:\n\tUsing %s as default\n\tMutator found %s"%(defaultCandidate.name, mutatorDefaultCandidate.name))
|
|
|
|
if defaultCandidate is None and mutatorDefaultCandidate is not None:
|
|
|
|
# we didn't have a flag, use the one selected by mutator
|
|
|
|
defaultCandidate = mutatorDefaultCandidate
|
|
|
|
self.default = defaultCandidate
|
|
|
|
self.defaultLoc = Location(self.default.location)
|
|
|
|
|
|
|
|
def makeInstance(self, instanceDescriptor):
|
2016-11-30 17:48:05 +01:00
|
|
|
""" Generate a font object for this instance """
|
2016-11-30 14:45:41 +01:00
|
|
|
font = self._instantiateFont(None)
|
|
|
|
# make fonty things here
|
|
|
|
loc = Location(instanceDescriptor.location)
|
2016-11-30 17:48:05 +01:00
|
|
|
# make the kerning
|
|
|
|
if instanceDescriptor.kerning:
|
|
|
|
self.getKerningMutator().makeInstance(loc).extractKerning(font)
|
|
|
|
# make the info
|
2016-11-30 14:45:41 +01:00
|
|
|
if instanceDescriptor.info:
|
2016-11-30 17:48:05 +01:00
|
|
|
self.getInfoMutator().makeInstance(loc).extractInfo(font.info)
|
|
|
|
info = self._infoMutator.makeInstance(loc)
|
2016-11-30 14:45:41 +01:00
|
|
|
info.extractInfo(font.info)
|
|
|
|
font.info.familyName = instanceDescriptor.familyName
|
|
|
|
font.info.styleName = instanceDescriptor.styleName
|
|
|
|
font.info.postScriptFontName = instanceDescriptor.postScriptFontName
|
|
|
|
font.info.styleMapFamilyName = instanceDescriptor.styleMapFamilyName
|
|
|
|
font.info.styleMapStyleName = instanceDescriptor.styleMapStyleName
|
|
|
|
# copied info
|
|
|
|
for sourceDescriptor in self.sources:
|
|
|
|
if sourceDescriptor.copyInfo:
|
|
|
|
# this is the source
|
|
|
|
self._copyFontInfo(self.fonts[sourceDescriptor.name].info, font.info)
|
|
|
|
if sourceDescriptor.copyLib:
|
|
|
|
font.lib.update(self.fonts[sourceDescriptor.name].lib)
|
|
|
|
if sourceDescriptor.copyFeatures:
|
|
|
|
featuresText = self.fonts[sourceDescriptor.name].features.text
|
|
|
|
if isinstance(featuresText, str):
|
|
|
|
font.features.text = u""+featuresText
|
|
|
|
elif isinstance(featuresText, unicode):
|
|
|
|
font.features.text = featuresText
|
|
|
|
# glyphs
|
2016-11-30 17:48:05 +01:00
|
|
|
for glyphName in self.glyphNames:
|
|
|
|
glyphMutator = self.getGlyphMutator(glyphName)
|
|
|
|
if glyphName in instanceDescriptor.glyphs.keys():
|
|
|
|
# reminder: this is what the glyphData can look like
|
|
|
|
# {'instanceLocation': {'custom': 0.0, 'weight': 824.0},
|
|
|
|
# 'masters': [{'font': 'master.Adobe VF Prototype.Master_0.0',
|
|
|
|
# 'glyphName': 'dollar.nostroke',
|
|
|
|
# 'location': {'custom': 0.0, 'weight': 0.0}},
|
|
|
|
# {'font': 'master.Adobe VF Prototype.Master_1.1',
|
|
|
|
# 'glyphName': 'dollar.nostroke',
|
|
|
|
# 'location': {'custom': 0.0, 'weight': 368.0}},
|
|
|
|
# {'font': 'master.Adobe VF Prototype.Master_2.2',
|
|
|
|
# 'glyphName': 'dollar.nostroke',
|
|
|
|
# 'location': {'custom': 0.0, 'weight': 1000.0}},
|
|
|
|
# {'font': 'master.Adobe VF Prototype.Master_3.3',
|
|
|
|
# 'glyphName': 'dollar.nostroke',
|
|
|
|
# 'location': {'custom': 100.0, 'weight': 1000.0}},
|
|
|
|
# {'font': 'master.Adobe VF Prototype.Master_0.4',
|
|
|
|
# 'glyphName': 'dollar.nostroke',
|
|
|
|
# 'location': {'custom': 100.0, 'weight': 0.0}},
|
|
|
|
# {'font': 'master.Adobe VF Prototype.Master_4.5',
|
|
|
|
# 'glyphName': 'dollar.nostroke',
|
|
|
|
# 'location': {'custom': 100.0, 'weight': 368.0}}],
|
|
|
|
# 'unicodeValue': 36}
|
|
|
|
glyphData = instanceDescriptor.glyphs[glyphName]
|
2016-11-30 14:45:41 +01:00
|
|
|
else:
|
|
|
|
glyphData = {}
|
2016-11-30 17:48:05 +01:00
|
|
|
font.newGlyph(glyphName)
|
|
|
|
font[glyphName].clear()
|
2016-11-30 14:45:41 +01:00
|
|
|
if glyphData.get('mute', False):
|
|
|
|
# mute this glyph, skip
|
|
|
|
continue
|
|
|
|
glyphInstanceLocation = Location(glyphData.get("instanceLocation", instanceDescriptor.location))
|
2016-11-30 17:48:05 +01:00
|
|
|
glyphInstanceUnicode = glyphData.get("unicodeValue", font[glyphName].unicode)
|
2016-11-30 14:45:41 +01:00
|
|
|
note = glyphData.get("note")
|
|
|
|
if note:
|
2016-11-30 17:48:05 +01:00
|
|
|
font[glyphName] = note
|
2016-11-30 14:45:41 +01:00
|
|
|
masters = glyphData.get("masters", None)
|
|
|
|
if masters:
|
|
|
|
items = []
|
|
|
|
for glyphMaster in masters:
|
|
|
|
sourceGlyphFont = glyphMaster.get("font")
|
2016-11-30 17:48:05 +01:00
|
|
|
sourceGlyphName = glyphMaster.get("glyphName", glyphName)
|
2016-11-30 14:45:41 +01:00
|
|
|
sourceGlyph = MathGlyph(self.fonts.get(sourceGlyphFont)[sourceGlyphName])
|
|
|
|
sourceGlyphLocation = Location(glyphMaster.get("location"))
|
|
|
|
items.append((sourceGlyphLocation, sourceGlyph))
|
|
|
|
bias, glyphMutator = buildMutator(items, bias=self.defaultLoc)
|
|
|
|
glyphInstanceObject = glyphMutator.makeInstance(glyphInstanceLocation)
|
2016-11-30 17:48:05 +01:00
|
|
|
font.newGlyph(glyphName)
|
|
|
|
font[glyphName].clear()
|
2016-11-30 14:45:41 +01:00
|
|
|
if self.roundGeometry:
|
|
|
|
try:
|
|
|
|
glyphInstanceObject = glyphInstanceObject.round()
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
try:
|
2016-11-30 17:48:05 +01:00
|
|
|
glyphInstanceObject.extractGlyph(font[glyphName], onlyGeometry=True)
|
2016-11-30 14:45:41 +01:00
|
|
|
except TypeError:
|
|
|
|
# this causes ruled glyphs to end up in the wrong glyphname
|
|
|
|
# but defcon2 objects don't support it
|
2016-11-30 17:48:05 +01:00
|
|
|
pPen = font[glyphName].getPointPen()
|
|
|
|
font[glyphName].clear()
|
2016-11-30 14:45:41 +01:00
|
|
|
glyphInstanceObject.drawPoints(pPen)
|
2016-11-30 17:48:05 +01:00
|
|
|
font[glyphName].width = glyphInstanceObject.width
|
|
|
|
return font
|
2016-11-30 14:45:41 +01:00
|
|
|
|
|
|
|
def _instantiateFont(self, path):
|
2016-11-30 17:48:05 +01:00
|
|
|
""" Return a instance of a font object with all the given subclasses"""
|
2016-11-30 14:45:41 +01:00
|
|
|
return self.fontClass(path,
|
|
|
|
libClass=self.libClass,
|
|
|
|
kerningClass=self.kerningClass,
|
|
|
|
groupsClass=self.groupsClass,
|
|
|
|
infoClass=self.infoClass,
|
|
|
|
featuresClass=self.featuresClass,
|
|
|
|
glyphClass=self.glyphClass,
|
|
|
|
glyphContourClass=self.glyphContourClass,
|
|
|
|
glyphPointClass=self.glyphPointClass,
|
|
|
|
glyphComponentClass=self.glyphComponentClass,
|
|
|
|
glyphAnchorClass=self.glyphAnchorClass)
|
|
|
|
|
2016-11-30 15:50:19 +01:00
|
|
|
def _copyFontInfo(self, sourceInfo, targetInfo):
|
2016-11-30 17:48:05 +01:00
|
|
|
""" Copy the non-calculating fields from the source info."""
|
2016-11-30 14:45:41 +01:00
|
|
|
infoAttributes = [
|
|
|
|
"versionMajor",
|
|
|
|
"versionMinor",
|
|
|
|
"copyright",
|
|
|
|
"trademark",
|
|
|
|
"note",
|
|
|
|
"openTypeGaspRangeRecords",
|
|
|
|
"openTypeHeadCreated",
|
|
|
|
"openTypeHeadFlags",
|
|
|
|
"openTypeNameDesigner",
|
|
|
|
"openTypeNameDesignerURL",
|
|
|
|
"openTypeNameManufacturer",
|
|
|
|
"openTypeNameManufacturerURL",
|
|
|
|
"openTypeNameLicense",
|
|
|
|
"openTypeNameLicenseURL",
|
|
|
|
"openTypeNameVersion",
|
|
|
|
"openTypeNameUniqueID",
|
|
|
|
"openTypeNameDescription",
|
|
|
|
"#openTypeNamePreferredFamilyName",
|
|
|
|
"#openTypeNamePreferredSubfamilyName",
|
|
|
|
"#openTypeNameCompatibleFullName",
|
|
|
|
"openTypeNameSampleText",
|
|
|
|
"openTypeNameWWSFamilyName",
|
|
|
|
"openTypeNameWWSSubfamilyName",
|
|
|
|
"openTypeNameRecords",
|
|
|
|
"openTypeOS2Selection",
|
|
|
|
"openTypeOS2VendorID",
|
|
|
|
"openTypeOS2Panose",
|
|
|
|
"openTypeOS2FamilyClass",
|
|
|
|
"openTypeOS2UnicodeRanges",
|
|
|
|
"openTypeOS2CodePageRanges",
|
|
|
|
"openTypeOS2Type",
|
|
|
|
"postscriptIsFixedPitch",
|
|
|
|
"postscriptForceBold",
|
|
|
|
"postscriptDefaultCharacter",
|
|
|
|
"postscriptWindowsCharacterSet"
|
|
|
|
]
|
|
|
|
for infoAttribute in infoAttributes:
|
|
|
|
copy = False
|
|
|
|
if self.ufoVersion == 1 and infoAttribute in fontInfoAttributesVersion1:
|
|
|
|
copy = True
|
|
|
|
elif self.ufoVersion == 2 and infoAttribute in fontInfoAttributesVersion2:
|
|
|
|
copy = True
|
|
|
|
elif self.ufoVersion == 3 and infoAttribute in fontInfoAttributesVersion3:
|
|
|
|
copy = True
|
|
|
|
if copy:
|
|
|
|
value = getattr(sourceInfo, infoAttribute)
|
|
|
|
setattr(targetInfo, infoAttribute, value)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# standalone test
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
def addGlyphs(font, s):
|
|
|
|
# we need to add the glyphs
|
|
|
|
for n in ['glyphOne', 'glyphTwo', 'glyphThree', 'glyphFour']:
|
|
|
|
font.newGlyph(n)
|
|
|
|
g = font[n]
|
|
|
|
p = g.getPen()
|
|
|
|
p.moveTo((0,0))
|
|
|
|
p.lineTo((s,0))
|
|
|
|
p.lineTo((s,s))
|
|
|
|
p.lineTo((0,s))
|
|
|
|
p.closePath()
|
|
|
|
g.move((0,s*2))
|
|
|
|
g.width = s
|
|
|
|
|
|
|
|
def fillInfo(font):
|
|
|
|
font.info.unitsPerEm = 1000
|
|
|
|
font.info.ascender = 800
|
|
|
|
font.info.descender = -200
|
|
|
|
|
|
|
|
def makeTestFonts(rootPath):
|
|
|
|
""" Make some test fonts that have the kerning problem."""
|
|
|
|
path1 = os.path.join(rootPath, "geometryMaster1.ufo")
|
|
|
|
path2 = os.path.join(rootPath, "geometryMaster2.ufo")
|
|
|
|
path3 = os.path.join(rootPath, "my_test_instance_dir_one", "geometryInstance%3.3f.ufo")
|
|
|
|
path4 = os.path.join(rootPath, "my_test_instance_dir_two", "geometryInstanceAnisotropic1.ufo")
|
|
|
|
path5 = os.path.join(rootPath, "my_test_instance_dir_two", "geometryInstanceAnisotropic2.ufo")
|
|
|
|
|
|
|
|
# Two masters
|
|
|
|
f1 = Font()
|
|
|
|
addGlyphs(f1, 100)
|
|
|
|
f1.features.text = u"# features text from master 1"
|
|
|
|
|
|
|
|
f2 = Font()
|
|
|
|
addGlyphs(f2, 500)
|
|
|
|
f2.features.text = u"# features text from master 2"
|
|
|
|
|
|
|
|
|
|
|
|
fillInfo(f1)
|
|
|
|
f1.info.ascender = 400
|
|
|
|
f1.info.descender = -200
|
|
|
|
fillInfo(f2)
|
|
|
|
f2.info.ascender = 600
|
|
|
|
f2.info.descender = -100
|
|
|
|
|
|
|
|
f1.info.copyright = u"This is the copyright notice from master 1"
|
2016-11-30 15:50:19 +01:00
|
|
|
f2.info.copyright = u"This is the copyright notice from master 2"
|
2016-11-30 14:45:41 +01:00
|
|
|
|
|
|
|
# save
|
|
|
|
f1.save(path1, 2)
|
|
|
|
f2.save(path2, 2)
|
|
|
|
return path1, path2, path3, path4, path5
|
|
|
|
|
|
|
|
def test0(docPath):
|
|
|
|
# make the test fonts and a test document
|
|
|
|
testFontPath = os.path.join(os.getcwd(), "automatic_testfonts")
|
|
|
|
m1, m2, i1, i2, i3 = makeTestFonts(testFontPath)
|
|
|
|
d = DesignSpaceProcessor()
|
|
|
|
a = AxisDescriptor()
|
|
|
|
a.name = "pop"
|
|
|
|
a.minimum = 50
|
|
|
|
a.maximum = 1000
|
|
|
|
a.default = 0
|
|
|
|
a.tag = "pop*"
|
|
|
|
d.addAxis(a)
|
|
|
|
|
|
|
|
s1 = SourceDescriptor()
|
|
|
|
s1.path = m1
|
|
|
|
s1.location = dict(pop=a.minimum)
|
|
|
|
s1.name = "test.master.1"
|
2016-11-30 15:50:19 +01:00
|
|
|
s1.copyInfo = True
|
2016-11-30 14:45:41 +01:00
|
|
|
s1.copyFeatures = True
|
|
|
|
d.addSource(s1)
|
|
|
|
|
|
|
|
s2 = SourceDescriptor()
|
|
|
|
s2.path = m2
|
|
|
|
s2.location = dict(pop=1000)
|
|
|
|
s2.name = "test.master.2"
|
|
|
|
#s2.copyInfo = True
|
|
|
|
d.addSource(s2)
|
|
|
|
|
|
|
|
for counter in range(3):
|
|
|
|
factor = counter / 2
|
|
|
|
i = InstanceDescriptor()
|
|
|
|
v = a.minimum+factor*(a.maximum-a.minimum)
|
|
|
|
i.path = i1%v
|
|
|
|
i.familyName = "TestFamily"
|
|
|
|
i.styleName = "TestStyle_pop%3.3f"%(v)
|
|
|
|
i.name = "%s-%s"%(i.familyName, i.styleName)
|
|
|
|
i.location = dict(pop=v)
|
|
|
|
i.info = True
|
|
|
|
i.kerning = True
|
|
|
|
if counter == 2:
|
|
|
|
i.glyphs['glyphTwo'] = dict(name="glyphTwo", mute=True)
|
|
|
|
d.addInstance(i)
|
|
|
|
d.write(docPath)
|
|
|
|
|
|
|
|
def test1(docPath):
|
|
|
|
# execute the test document
|
|
|
|
d = DesignSpaceProcessor()
|
|
|
|
d.read(docPath)
|
2016-11-30 17:48:05 +01:00
|
|
|
d.generateUFO()
|
2016-11-30 14:45:41 +01:00
|
|
|
|
|
|
|
selfTest = True
|
|
|
|
if selfTest:
|
|
|
|
testRoot = os.path.join(os.getcwd(), "automatic_testfonts")
|
|
|
|
if os.path.exists(testRoot):
|
|
|
|
shutil.rmtree(testRoot)
|
|
|
|
docPath = os.path.join(testRoot, "automatic_test.designspace")
|
|
|
|
test0(docPath)
|
|
|
|
test1(docPath)
|