예제 #1
0
def buildDesignSpace(sources, instances, axes):
    # use DesignSpaceDocument because it supports axis labelNames
    doc = DesignSpaceDocument()

    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)

    for instance in instances:
        i = InstanceDescriptor()
        i.location = instance["location"]
        i.familyName = instance["familyName"]
        i.styleName = instance["styleName"]
        doc.addInstance(i)

    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
예제 #2
0
 def testDocument(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"
     s1.copyInfo = True
     s1.copyFeatures = True
     s1.copyLib = 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)
             i.copyLib = True
         if counter == 2:
             i.glyphs['narrow'] = dict(instanceLocation=dict(pop=400),
                                       unicodes=[0x123, 0x124, 0x125])
         d.addInstance(i)
     d.write(docPath)
a2 = AxisDescriptor()
a2.maximum = 1000
a2.minimum = 0
a2.default = 0
a2.name = "weight"
a2.tag = "wght"
doc.addAxis(a2)

#---------
# masters
#---------

s0 = SourceDescriptor()
s0.path = "MutatorSansLightCondensed.ufo"
s0.name = "master.MutatorMathTest.LightCondensed.0"
s0.familyName = familyName
s0.styleName = "LightCondensed"
s0.location = dict(weight=0, width=0)
s0.copyLib = True
s0.copyInfo = True
s0.copyGroups = True
s0.copyFeatures = True
doc.addSource(s0)

s1 = SourceDescriptor()
s1.path = "MutatorSansBoldCondensed.ufo"
s1.name = "master.MutatorMathTest.BoldCondensed.1"
s1.familyName = familyName
s1.styleName = "BoldCondensed"
s1.location = dict(weight=1000, width=0)
예제 #4
0
instances = []

for source in sources:
    instances.append(
        dict(location=source["location"],
             styleName=source["styleName"],
             familyName=source["familyName"]))

###

doc = DesignSpaceDocument()

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)

for instance in instances:
    i = InstanceDescriptor()
    i.location = instance["location"]
    i.familyName = instance["familyName"]
    i.styleName = instance["styleName"]
    doc.addInstance(i)

for axis in axes:
    a = AxisDescriptor()