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
Exemple #2
0
    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)

#doc.checkAxes()

#doc.checkDefault()

doc.write(designSpacePath)