Document object

SuperDocumentObject

Object representing the current (front most) Superpolator3. This is part of the SuperScript API.

Use currentSpDocument and friends to have the application make this object for you, do not instantiate it yourself.

Defining the design space

  • addAxis(axisName, shortName, minValue, maxValue, initValue, color)
    This adds a new axis to this document. AxisName and shortName are strings and should be unique, minValue is the smallest value for this axis. maxValue is the largest value for this axis. initValue is the value locations will default to.
    doc.addAxis("weight", "wt", -1000, 1000, 0)
  • addMaster(path, location)
    This adds the UFO at path as a new master to this document at this location. Location is a dictionary with dimension name / value pairs.
    items = [ ('path/to/light.ufo', dict(weight=0)), ('path/to/bold.ufo', dict(weight=1000)) ]
    doc.addMasters(items)
  • addMasters(listOfPathsAndLocations)
    This adds a list of [(path, location),…] items to the document. Before defining new instances or adding masters you need to define axes for all dimensions you want to use.
    loc = dict(weight=100, width=300)
    doc.addMaster("path/to/my.ufo", loc)
  • addInstance(instanceSettings)
    This adds an instance described by the instanceSettings dict. These are the values you can add to the settings dict:

    • familyName: string for the family name. Required
    • styleName: string for the style name. Required
    • location: dict with the design space location. Required
    • muteGlyphNames: list of glyphs to be ignored. Optional
    • muteFontInfo: boolean, don’t generate the font info. Optional
    • muteGlyphs: boolean, don’t generate any glyphs. Optional
    • muteKerning: boolean, don’t generate kerning. Optional
    • note: string, the note about this instance. Optional

    # add a normal instance
    settings = dict(
    familyName = "MyFamily",
    styleName = "Regular",
    location = dict(width=400, weight=500),
    note = "This is an instance added with a script"
    )
    d.addInstance(settings)
    # add an anisotropic instance
    settings = dict(
    familyName = "MyFamily",
    styleName = "Split",
    location = dict(width=400, weight=(600,500)),
    note = "This is an instance added with a script"
    )
    d.addInstance(settings)

Change the presentation

  • setPreviewText(aStringWithPreviewText)
    This sets the text of the glyph line in the document to aStringWithPreviewText. You can set a unicode string and escaped glyphnames /aagrave/udieresis
    doc.setPreviewText("üå /aring/sterling")
  • setPreviewLocation(location)
    This sets the design space location of the glyphline in the document.
    loc = dict(weight=100, width=300)
    doc.setPreviewLocation(loc)

Generating things

After defining axes and adding masters it is possible to sample the design space. You can generate single glyph objects at any location. For instance if you want to draw into drawBot, or if you want to find out things about the shape.

  • sampleGlyph(glyphName, locationDict=None) This returns a defcon glyph object for glyphName at this location. If no locationDict is given it will use a default location. Note: if you’re generating a glyph with components, only the component offset will interpolate. If you want a glyph object to draw with (with all components as paths, check SuperScript and DrawBot)
  • sampleFontInfo(locationDict=None) This returns a defcon fontInfo object at this location. if no locationDict is given it will use a default location.

Document I/O

  • save(path=None)
    This saves the current document. Use the optional path to save it somewhere else.
    doc.save() # just save the changes
    doc.save("some/other/path.sp3") # save it somewhere else.
  • close()
    This closes the current document, losing any unsaved changes.

Attributes

  • masters This returns a list of objects representing the masters. The list is read only. Use doc.addMaster to add more masters. The master object is editable: master/instance object.
    for item in masters:
    print item

  • instances This returns a list of objects representing the instances. Read only. Use doc.addInstance to add more instances. The instance object is editable: master/instance object.
    for item in doc.masters:
    print item