Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…FontExtension into dse2.0
  • Loading branch information
typemytype committed Oct 11, 2023
2 parents e359161 + ce7eba7 commit 031436b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DesignspaceEditor2.roboFontExt/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
<key>timeStamp</key>
<real>1653936779.9141068</real>
<key>version</key>
<string>1.0</string>
<string>2.1</string>
</dict>
</plist>
26 changes: 24 additions & 2 deletions DesignspaceEditor2.roboFontExt/lib/designspaceEditor/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
infoImage = AppKit.NSImage.imageNamed_(AppKit.NSImageNameInfo)


class DesingspaceEditorOperator(ufoOperator.UFOOperator):
class DesignspaceEditorOperator(ufoOperator.UFOOperator):

def _instantiateFont(self, path):
return internalFontClasses.createFontObject(path)
Expand Down Expand Up @@ -461,7 +461,7 @@ def __init__(self, path=None):
self.load(path)

def build(self):
self.operator = DesingspaceEditorOperator()
self.operator = DesignspaceEditorOperator(extrapolate=True)

self.w = vanilla.Window((900, 500), "Designspace Editor", minSize=(720, 400))
self.w.vanillaWrapper = weakref.ref(self)
Expand Down Expand Up @@ -1257,6 +1257,22 @@ def convertInstanceToDesignLocation(menuItem):
instanceDescriptor.userLocation.clear()
item.update(self.wrapInstanceDescriptor(instanceDescriptor))

def updateUFOFilenameFromFontNames(menuItem):
for item in selectedItems:
instanceDescriptor = item["object"]
# wrapInstanceDescriptor will create a new default filename
instanceDescriptor.filename = None
item.update(self.wrapInstanceDescriptor(instanceDescriptor))
self.setDocumentNeedSave(True, who="Instances")

def openInstanceUFO(menuItem):
for item in selectedItems:
instanceDescriptor = item["object"]
path = item["object"].path
if path is not None:
if os.path.exists(path):
OpenFont(path)

menu = []
for axisDescriptor in self.operator.axes:
if axisDescriptor.name == axisName:
Expand Down Expand Up @@ -1295,6 +1311,11 @@ def convertInstanceToDesignLocation(menuItem):
menu.append(dict(title="Force Sources Change", callback=forceSourcesChangeCallback))

if selectedItems and sender.designspaceContent == "instances":
menu.append("----")
menu.append(dict(title="Open Instance UFO", callback=openInstanceUFO))
menu.append(dict(title="Reveal Instance in Finder", callback=revealInFinderCallback))
menu.append("----")
menu.append(dict(title="Update UFO Filename", callback=updateUFOFilenameFromFontNames))
menu.append("----")
menu.append(dict(title="Convert to User Location", callback=convertInstanceToUserLocation))
menu.append(dict(title="Convert to Design Location", callback=convertInstanceToDesignLocation))
Expand Down Expand Up @@ -1487,6 +1508,7 @@ def saveDesignspace(path):
for wrappedInstanceDescriptor in self.instances.list:
instanceDescriptor = self.unwrapInstanceDescriptor(wrappedInstanceDescriptor)
if instanceDescriptor.filename is None:
# maybe DSE should always update the ufo name?
instanceDescriptor.filename = os.path.join(getExtensionDefault('instanceFolderName', 'instances'), f"{instanceDescriptor.familyName}-{instanceDescriptor.styleName}.ufo")
instanceDescriptor.path = os.path.abspath(os.path.join(root, instanceDescriptor.filename))

Expand Down
8 changes: 8 additions & 0 deletions currentdesignspacedemos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
d = CurrentDesignspace()
d.loadFonts()
loc = d.newDefaultLocation()
pairs = [('public.kern1.i', 'public.kern2.b')]
k = d.makeOneKerning(loc, pairs)
info = d.makeOneInfo(loc)
print(k.items())
print(info)
17 changes: 17 additions & 0 deletions drawBot_currentDesignspace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

size(1000, 500)
d = CurrentDesignspace()
d.loadFonts()

fill(None)
stroke(0)
strokeWidth(.5)
with savedState():
translate(100, 100)
scale(0.5)
for i in range(20):
loc = d.randomLocation()
g = d.makeOneGlyph("logo", location=loc)
bp = BezierPath()
g.draw(bp)
drawPath(bp)

0 comments on commit 031436b

Please sign in to comment.