Skip to content

Commit

Permalink
Remove non existing axis names in location labels for sources and ins…
Browse files Browse the repository at this point in the history
…tances

+ white space
  • Loading branch information
typemytype committed May 3, 2024
1 parent ad7bfaa commit 8960006
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions DesignspaceEditor2.roboFontExt/lib/designspaceEditor/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ def __init__(self, parentWindow, operator, instances):
self.w.roundCheckBox = vanilla.CheckBox((split + 20, 45, -10, 22), "Round Geometry")
self.w.mathModelSuffix = vanilla.CheckBox((split + 20, 70, -10, 22), "Add Math Model Suffix")

#self.w.instancesRootText = vanilla.TextBox((10, 105, split, 22), "Instances Folder:", alignment="right")
#self.w.instancesRoot = vanilla.EditText((split + 20, 105 - 2, -10, 22), "foo")
# self.w.instancesRootText = vanilla.TextBox((10, 105, split, 22), "Instances Folder:", alignment="right")
# self.w.instancesRoot = vanilla.EditText((split + 20, 105 - 2, -10, 22), "foo")

self.w.closeButton = vanilla.Button((-180, -30, -110, 20), "Cancel", callback=self.closeCallback)
self.w.closeButton.bind(".", ["command"])
Expand Down Expand Up @@ -357,7 +357,7 @@ def axisMinimum(self):
return None
return self.axisDescriptor.minimum

#@tryExceptDecorator
# @tryExceptDecorator
def setAxisMinimum_(self, value):
if self.axisIsDescrete():
# convert to a continuous axis
Expand All @@ -377,7 +377,7 @@ def axisMaximum(self):
return None
return self.axisDescriptor.maximum

#@tryExceptDecorator
# @tryExceptDecorator
def setAxisMaximum_(self, value):
if self.axisIsDescrete():
# convert to a continuous axis
Expand All @@ -393,7 +393,7 @@ def axisDiscreteValues(self):
return " ".join([numberToString(value) for value in self.axisDescriptor.values])
return ""

#@tryExceptDecorator
# @tryExceptDecorator
def setAxisDiscreteValues_(self, value):
if not self.axisIsDescrete():
# convert to a discrete axis
Expand Down Expand Up @@ -1236,8 +1236,15 @@ def unwrapSourceDescriptor(self, wrappedSourceDescriptor):
sourceDescriptor.familyName = wrappedSourceDescriptor["sourceFamilyName"] if wrappedSourceDescriptor.get("sourceFamilyName") else None
sourceDescriptor.styleName = wrappedSourceDescriptor["sourceStyleName"] if wrappedSourceDescriptor.get("sourceStyleName") else None
sourceDescriptor.layerName = wrappedSourceDescriptor["sourceLayerName"] if wrappedSourceDescriptor.get("sourceLayerName") else None
# update locations
for axis in self.operator.axes:
sourceDescriptor.location[axis.name] = wrappedSourceDescriptor.get(f"axis_{axis.name}", axis.default)
# remove non existing location axis names
existingAxisNames = [axis.name for axis in self.operator.axes]
for locationName in list(sourceDescriptor.location):
if locationName not in existingAxisNames:
del sourceDescriptor.location[locationName]

return sourceDescriptor

def sourcesListDoubleClickCallback(self, sender):
Expand Down Expand Up @@ -1313,9 +1320,15 @@ def unwrapInstanceDescriptor(self, wrappedInstanceDescriptor):
instanceDescriptor.familyName = wrappedInstanceDescriptor["instanceFamilyName"] if wrappedInstanceDescriptor.get("instanceFamilyName") else None
instanceDescriptor.styleName = wrappedInstanceDescriptor["instanceStyleName"] if wrappedInstanceDescriptor.get("instanceStyleName") else None
instanceDescriptor.postScriptFontName = wrappedInstanceDescriptor["instancePostscriptFontName"] if wrappedInstanceDescriptor.get("instancePostscriptFontName") else None
# update locations
location = instanceDescriptor.designLocation or instanceDescriptor.userLocation
for axis in self.operator.axes:
location[axis.name] = wrappedInstanceDescriptor.get(f"axis_{axis.name}", axis.default)
# remove non existing location axis names
existingAxisNames = [axis.name for axis in self.operator.axes]
for locationName in list(location):
if locationName not in existingAxisNames:
del location[locationName]
return instanceDescriptor

def instancesListDoubleClickCallback(self, sender):
Expand Down Expand Up @@ -1538,19 +1551,19 @@ def newInstanceBetween(menuItem):
return
location = self.operator.newDefaultLocation(discreteLocation=firstDiscrete)
for axisName in firstContinuous.keys():
newValue = .5*(firstContinuous.get(axisName) + secondContinuous.get(axisName))
newValue = .5 * (firstContinuous.get(axisName) + secondContinuous.get(axisName))
location[axisName] = newValue
newFamilyName = first.familyName
newStyleName = f"{first.styleName}_{second.styleName}"
postScriptFontName = f"{newFamilyName}-{newStyleName}"
instanceUFOFileName = f"{newFamilyName}-{newStyleName}.ufo"
self.operator.addInstanceDescriptor(
familyName = first.familyName,
styleName = newStyleName,
designLocation = location,
filename = instanceUFOFileName,
postScriptFontName = postScriptFontName,
)
familyName=first.familyName,
styleName=newStyleName,
designLocation=location,
filename=instanceUFOFileName,
postScriptFontName=postScriptFontName,
)

def updateUFOFilenameFromFontNames(menuItem):
for item in selectedItems:
Expand All @@ -1572,7 +1585,6 @@ def updatePostScriptFontNameFromFontNamesCallback(menuItem):
def openUFO(menuItem):
self.openSelectedItem(sender)


menu = []
for axisDescriptor in self.operator.axes:
if axisDescriptor.name == axisName:
Expand Down

0 comments on commit 8960006

Please sign in to comment.