def buildDesignSpace(sources, instances, axes): doc = DesignSpaceDocument() # build source descriptors from source list for source in sources: s = SourceDescriptor() s.path = source["path"] s.name = source["name"] s.copyInfo = source["copyInfo"] s.location = source["location"] s.familyName = source["familyName"] s.styleName = source["styleName"] doc.addSource(s) # build instance descriptors from instance list for instance in instances: i = InstanceDescriptor() i.location = instance["location"] i.familyName = instance["familyName"] i.styleName = instance["styleName"] i.path = instance["path"] i.postScriptFontName = instance["postScriptFontName"] i.styleMapFamilyName = instance["styleMapFamilyName"] i.styleMapStyleName = instance["styleMapStyleName"] doc.addInstance(i) # build axis descriptors from axis list for axis in axes: a = AxisDescriptor() a.minimum = axis["minimum"] a.maximum = axis["maximum"] a.default = axis["default"] a.name = axis["name"] a.tag = axis["tag"] for languageCode, labelName in axis["labelNames"].items(): a.labelNames[languageCode] = labelName a.map = axis["map"] doc.addAxis(a) return doc
minDoc.read(minPath) # resetting instances minDoc.instances = [] # Calculate location weightMin = wght.get('regular') - (wght.get('regular') - wght.get('min')) * weightCropIndex weightMax = wght.get('regular') + (wght.get('max') - wght.get('regular')) * weightCropIndex instance = InstanceDescriptor() instance.familyName = familyName instance.styleName = "Thin" instance.name = "Piazzolla-Thin-OpszMin.ufo" instance.path = lightUfo newUfo = ufo.replace('.ufo', '-OpszMin.ufo') instance.location = {'Weight': weightMin, 'Optical size': opsz['min']} minDoc.addInstance(instance) instance = InstanceDescriptor() instance.familyName = familyName instance.styleName = "Black" instance.name = "Piazzolla-Black-OpszMin.ufo" instance.path = blackUfo instance.location = {'Weight': weightMax, 'Optical size': opsz['min']} minDoc.addInstance(instance) minDoc.write(minPath) print("Generate new ufos for OpszMin")
s3.path = "MutatorSansBoldWide.ufo" s3.name = "master.MutatorSansTest.BoldWide.3" s3.familyName = familyName s3.styleName = "BoldWide" s3.location = dict(weight=1000, width=1000) doc.addSource(s3) #----------- # instances #----------- i0 = InstanceDescriptor() i0.name = 'instance_LightCondensed' i0.familyName = familyName i0.styleName = "Medium" i0.path = os.path.join(root, "instances", "MutatorSansTest-Medium.ufo") i0.location = dict(weight=500, width=327) i0.kerning = True i0.info = True doc.addInstance(i0) #------- # rules #------- # TODO: add rules to match the contents of `MutatorSans.designspace` # http://github.com/LettError/mutatorSans/blob/master/MutatorSans.designspace #-------- # saving #--------
s1.path = "NotoSerifTagalog-Bold.ufo" s1.name = "master.NotoSerifTagalog.Bold.0" s1.familyName = familyName s1.styleName = "Bold" s1.location = dict(weight=700) doc.addSource(s1) #----------- # instances #----------- i0 = InstanceDescriptor() i0.name = 'instance_Regular' i0.familyName = familyName i0.styleName = "Regular" i0.path = os.path.join(root, "instances", "NotoSerifTagalog-Regular.ufo") i0.location = dict(weight=400) i0.kerning = True i0.info = True doc.addInstance(i0) i1 = InstanceDescriptor() i1.name = 'instance_Medium' i1.familyName = familyName i1.styleName = "Medium" i1.path = os.path.join(root, "instances", "NotoSerifTagalog-Medium.ufo") i1.location = dict(weight=500) i1.kerning = True i1.info = True doc.addInstance(i1)