diff --git a/Plugins/HOI Viewer.glyphsReporter/Contents/Info.plist b/Plugins/HOI Viewer.glyphsReporter/Contents/Info.plist index ddef455..0ab294c 100755 --- a/Plugins/HOI Viewer.glyphsReporter/Contents/Info.plist +++ b/Plugins/HOI Viewer.glyphsReporter/Contents/Info.plist @@ -3,9 +3,7 @@ CFBundleDevelopmentRegion - English - CFBundleDisplayName - HOI Viewer + en CFBundleExecutable plugin CFBundleIdentifier @@ -14,25 +12,13 @@ 6.0 CFBundleName HOI Viewer - CFBundlePackageType - BNDL - CFBundleVersion - 1.0 CFBundleShortVersionString - 1.0 - UpdateFeedURL - ____OnlineUrlToThisPlist____ - productPageURL - ____ProductPageURL____ - productReleaseNotes - ____LatestReleaseNotes____ + 1.0.1 + CFBundleVersion + 3 NSHumanReadableCopyright Copyright, Michael LaGattuta, 2018 NSPrincipalClass viewHOI - PyMainFileNames - - ../MacOS/main.py - diff --git a/Plugins/HOI Viewer.glyphsReporter/Contents/MacOS/main.py b/Plugins/HOI Viewer.glyphsReporter/Contents/MacOS/main.py deleted file mode 100755 index 028888c..0000000 --- a/Plugins/HOI Viewer.glyphsReporter/Contents/MacOS/main.py +++ /dev/null @@ -1,16 +0,0 @@ -def _run(script): - global __file__ - import os, sys - sys.frozen = 'macosx_plugin' - base = os.environ['RESOURCEPATH'] - __file__ = path = os.path.join(base, script) - if sys.version_info[0] == 2: - with open(path, 'rU') as fp: - source = fp.read() + "\n" - else: - with open(path, 'r', encoding='utf-8') as fp: - source = fp.read() + '\n' - - exec(compile(source, path, 'exec'), globals(), globals()) - -_run('plugin.py') diff --git a/Plugins/HOI Viewer.glyphsReporter/Contents/MacOS/plugin b/Plugins/HOI Viewer.glyphsReporter/Contents/MacOS/plugin index b21f0e4..3d1b859 100755 Binary files a/Plugins/HOI Viewer.glyphsReporter/Contents/MacOS/plugin and b/Plugins/HOI Viewer.glyphsReporter/Contents/MacOS/plugin differ diff --git a/Plugins/HOI Viewer.glyphsReporter/Contents/PkgInfo b/Plugins/HOI Viewer.glyphsReporter/Contents/PkgInfo deleted file mode 100755 index 19a9cf6..0000000 --- a/Plugins/HOI Viewer.glyphsReporter/Contents/PkgInfo +++ /dev/null @@ -1 +0,0 @@ -BNDL???? \ No newline at end of file diff --git a/Plugins/HOI Viewer.glyphsReporter/Contents/Resources/plugin.py b/Plugins/HOI Viewer.glyphsReporter/Contents/Resources/plugin.py index 50a2ea5..d87d583 100755 --- a/Plugins/HOI Viewer.glyphsReporter/Contents/Resources/plugin.py +++ b/Plugins/HOI Viewer.glyphsReporter/Contents/Resources/plugin.py @@ -11,6 +11,7 @@ # ########################################################################################################### +from __future__ import print_function import objc import GlyphsApp from GlyphsApp import * @@ -19,6 +20,12 @@ import time import re +glyphsVersion = Glyphs.buildNumber +def getAxisName(axis): + if glyphsVersion > 3000: + return axis.name + return axis["Name"] + class viewHOI(ReporterPlugin): # The dialog view (e.g., panel or window) # TODO: currently this is a right click context menu but may make more sense as a persistent window @@ -78,45 +85,23 @@ class viewHOI(ReporterPlugin): # Set up variables for the name of each axis "axis" + "#" starting from 1 # Also makes variables for Min and Max values + @objc.python_method def makeAxisVariables(self, font, iterAxes): for i in iterAxes: - globals()['axis%s' % (i + 1)] = font.axes[i]["Name"] + globals()['axis%s' % (i + 1)] = getAxisName(font.axes[i]) globals()['axis%sMin' % (i + 1)] = 100000.0 globals()['axis%sMax' % (i + 1)] = -100000.0 + @objc.python_method def checkMasters(self, font, axis, index): for master in font.masters: - if index == 0: - if master.weightValue < globals()['axis%sMin' % (index + 1)]: - globals()['axis%sMin' % (index + 1)] = master.weightValue - if master.weightValue > globals()['axis%sMax' % (index + 1)]: - globals()['axis%sMax' % (index + 1)] = master.weightValue - elif index == 1: - if master.widthValue < globals()['axis%sMin' % (index + 1)]: - globals()['axis%sMin' % (index + 1)] = master.widthValue - if master.widthValue > globals()['axis%sMax' % (index + 1)]: - globals()['axis%sMax' % (index + 1)] = master.widthValue - elif index == 2: - if master.customValue < globals()['axis%sMin' % (index + 1)]: - globals()['axis%sMin' % (index + 1)] = master.customValue - if master.customValue > globals()['axis%sMax' % (index + 1)]: - globals()['axis%sMax' % (index + 1)] = master.customValue - elif index == 3: - if master.customValue1 < globals()['axis%sMin' % (index + 1)]: - globals()['axis%sMin' % (index + 1)] = master.customValue1 - if master.customValue1 > globals()['axis%sMax' % (index + 1)]: - globals()['axis%sMax' % (index + 1)] = master.customValue1 - elif index == 4: - if master.customValue2 < globals()['axis%sMin' % (index + 1)]: - globals()['axis%sMin' % (index + 1)] = master.customValue2 - if master.customValue2 > globals()['axis%sMax' % (index + 1)]: - globals()['axis%sMax' % (index + 1)] = master.customValue2 - elif index == 5: - if master.customValue3 < globals()['axis%sMin' % (index + 1)]: - globals()['axis%sMin' % (index + 1)] = master.customValue3 - if master.customValue3 > globals()['axis%sMax' % (index + 1)]: - globals()['axis%sMax' % (index + 1)] = master.customValue3 - + axisValue = master.axes[index] + if axisValue < globals()['axis%sMin' % (index + 1)]: + globals()['axis%sMin' % (index + 1)] = axisValue + if axisValue > globals()['axis%sMax' % (index + 1)]: + globals()['axis%sMax' % (index + 1)] = axisValue + + @objc.python_method def checkVirtualMasters(self, font, axis, index): for parameter in font.customParameters: if parameter.name == "Virtual Master": @@ -128,60 +113,50 @@ def checkVirtualMasters(self, font, axis, index): globals()['axis%sMax' % (index + 1)] = float(item["Location"]) # Can maybe truncate this + @objc.python_method def setAxisExtremes(self, font, iterAxes): for i in iterAxes: # Set axis values self.checkMasters(font, globals()['axis%s' % (i + 1)], i) self.checkVirtualMasters(font, globals()['axis%s' % (i + 1)], i) - + + minValue = globals()['axis%sMin' % (i + 1)] + maxValue = globals()['axis%sMax' % (i + 1)] # Set slider values if i == 0: - self.slider1.setMinValue_(globals()['axis%sMin' % (i + 1)]) - self.slider1.setMaxValue_(globals()['axis%sMax' % (i + 1)]) - print font.axes[i]["Name"] - print globals()['axis%sMin' % (i + 1)] - print globals()['axis%sMax' % (i + 1)] + self.slider1.setMinValue_(minValue) + self.slider1.setMaxValue_(maxValue) elif i == 1: - self.slider2.setMinValue_(globals()['axis%sMin' % (i + 1)]) - self.slider2.setMaxValue_(globals()['axis%sMax' % (i + 1)]) - print font.axes[i]["Name"] - print globals()['axis%sMin' % (i + 1)] - print globals()['axis%sMax' % (i + 1)] + self.slider2.setMinValue_(minValue) + self.slider2.setMaxValue_(maxValue) elif i == 2: - self.slider3.setMinValue_(globals()['axis%sMin' % (i + 1)]) - self.slider3.setMaxValue_(globals()['axis%sMax' % (i + 1)]) - print font.axes[i]["Name"] - print globals()['axis%sMin' % (i + 1)] - print globals()['axis%sMax' % (i + 1)] + self.slider3.setMinValue_(minValue) + self.slider3.setMaxValue_(maxValue) elif i == 3: - self.slider4.setMinValue_(globals()['axis%sMin' % (i + 1)]) - self.slider4.setMaxValue_(globals()['axis%sMax' % (i + 1)]) - print font.axes[i]["Name"] - print globals()['axis%sMin' % (i + 1)] - print globals()['axis%sMax' % (i + 1)] + self.slider4.setMinValue_(minValue) + self.slider4.setMaxValue_(maxValue) elif i == 4: - self.slider5.setMinValue_(globals()['axis%sMin' % (i + 1)]) - self.slider5.setMaxValue_(globals()['axis%sMax' % (i + 1)]) - print font.axes[i]["Name"] - print globals()['axis%sMin' % (i + 1)] - print globals()['axis%sMax' % (i + 1)] + self.slider5.setMinValue_(minValue) + self.slider5.setMaxValue_(maxValue) elif i == 5: - self.slider6.setMinValue_(globals()['axis%sMin' % (i + 1)]) - self.slider6.setMaxValue_(globals()['axis%sMax' % (i + 1)]) - print font.axes[i]["Name"] - print globals()['axis%sMin' % (i + 1)] - print globals()['axis%sMax' % (i + 1)] + self.slider6.setMinValue_(minValue) + self.slider6.setMaxValue_(maxValue) + print(getAxisName(font.axes[i])) + print(minValue) + print(maxValue) + @objc.python_method def settings(self): # Load .nib file next to plugin.py self.loadNib("sliderView", __file__) - self.menuName = Glyphs.localize({'en': u'HOI Viewer', 'de': u'Mein Plugin'}) + self.menuName = Glyphs.localize({'en': u'HOI Viewer'}) # Load slider view as a right-click context menu self.generalContextMenus = [{'name': 'HOI Viewer', 'view': self.sliderView}] # Updates the temp instance and the drawings based on the sliders # DONE: Figure out how to pull the state of the check boxes and then set values equal based on it # TODO: use a dictionary to link axes rather than iterating through them + @objc.python_method def sliderUpdate(self): sliderList = [self.slider1, self.slider2, self.slider3, self.slider4, self.slider5, self.slider6] keySlider = None @@ -298,6 +273,7 @@ def sync6_(self, sender): globals()['check6'] = True # generate nodes on canvas + @objc.python_method def roundDotForPoint( self, thisPoint, markerWidth ): """ from Show Angled Handles by MekkaBlue @@ -307,6 +283,7 @@ def roundDotForPoint( self, thisPoint, markerWidth ): return NSBezierPath.bezierPathWithOvalInRect_(myRect) # If nodes are stacked calculate using the next node + @objc.python_method def getDelta(self, node, node2, previous): if previous == True: previous = True @@ -325,6 +302,7 @@ def getDelta(self, node, node2, previous): return [dx, dy] # Node color changes based on angle (change the 'angleTolerance' variable) + @objc.python_method def nodeColor(self, nodePrev, node, nodeNext): deltaPrev = self.getDelta(node, nodePrev, True) deltaNext = self.getDelta(node, nodeNext, False) @@ -361,6 +339,7 @@ def nodeColor(self, nodePrev, node, nodeNext): # These functions are currently not being used...too slow # TODO: make currentGlyph a class variable rather than a local one # TODO: find a way to keep HOI layers in sync + @objc.python_method def getFullName(self, layerName): currentGlyph = Glyphs.font.selectedLayers[0].parent @@ -370,7 +349,8 @@ def getFullName(self, layerName): # Sync everything to the primary control masters V2 # needs to work with more paths***** - def syncToControl(self, aName, cName, dName, bName, hoiName): + @objc.python_method + def syncToControl(self, aName, cName, dName, bName, hoiName): currentGlyph = Glyphs.font.selectedLayers[0].parent c2Name = self.getFullName(re.sub("\d", "2", cName)) @@ -397,6 +377,7 @@ def syncToControl(self, aName, cName, dName, bName, hoiName): # Sync everything to the respective HOI layer V2 # needs to work with more paths***** + @objc.python_method def syncToHOI(self, aName, cName, dName, bName, hoiName): currentGlyph = Glyphs.font.selectedLayers[0].parent @@ -426,6 +407,7 @@ def syncToHOI(self, aName, cName, dName, bName, hoiName): # TODO: Preview axis should have separate checkboxes than syncing axes # TODO: Preview should be based on the min and max value of each axis + @objc.python_method def showAll(self, layer, currentGlyphName, pathIndex, interpolatedIndex, nodeScale, futureFontLayer): x2 = futureFontLayer.paths[pathIndex].nodes[interpolatedIndex].x y2 = futureFontLayer.paths[pathIndex].nodes[interpolatedIndex].y @@ -454,8 +436,9 @@ def showAll(self, layer, currentGlyphName, pathIndex, interpolatedIndex, nodeSca pNode.fill() # MAYBE change this to background instead + @objc.python_method def background(self, layer): - print "Start BG Draw" + print("Start BG Draw") start = time.time() currentGlyphName = layer.parent.name masterLayer = layer.parent.layers[layer.associatedMasterId] @@ -473,19 +456,14 @@ def background(self, layer): # MAYBE move this to a method and store in a variable with all the relevant axes values startInstance = time.time() - tempInstance = self.font.instances[0].copy() + tempInstance = GSInstance() + tempInstance.setFont_(self.font) tempInstance.name = "tempInstance" - tempInstance.weightValue = axis1Value - tempInstance.widthValue = axis2Value - tempInstance.customValue = axis3Value - tempInstance.setInterpolationCustom1_(axis4Value) - tempInstance.setInterpolationCustom3_(axis6Value) - tempInstance.setInterpolationCustom2_(axis5Value + 1) - tempInstance.setInterpolationCustom2_(axis5Value) + tempInstance.axes = [axis1Value, axis2Value, axis3Value, axis4Value, axis6Value, axis5Value + 1, axis5Value] tempFontLayer = tempInstance.interpolatedFontProxy.glyphs[currentGlyphName].layers[0] endInstance = time.time() - startInstance - print "Copy + Update Instance Time:", endInstance + print("Copy + Update Instance Time:", endInstance) if self.showFuture == True: previewProxies = [] @@ -510,14 +488,14 @@ def background(self, layer): increment = (globals()['axis%sMax' % (i + 1)] - globals()['axis%sMin' % (i + 1)]) / resolution # If this can be faster, then the range can be more to show smaller increments, or show more points at once - print "Making Preview Proxies" + print("Making Preview Proxies") startProxies = time.time() for i in range(resolution): try: plotPoint = previewMin + (i * increment) preview.update({"preview": plotPoint}) except: - print "No axis set to preview" + print("No axis set to preview") futureTempInstance.weightValue = preview[preview["axis1"]] futureTempInstance.widthValue = preview[preview["axis2"]] @@ -530,7 +508,7 @@ def background(self, layer): futureFontLayer = futureTempInstance.interpolatedFontProxy.glyphs[currentGlyphName].layers[0] previewProxies.append(futureFontLayer) - print "Finished Making Proxies", time.time() - startProxies + print("Finished Making Proxies", time.time() - startProxies) # TODO: find a way to implement this in the foreground draw nodes loop. Should make it slightly faster # def glyphPreview(self, masterLayer, pathIndex, node, tempFontLayer, tSub): @@ -604,7 +582,7 @@ def background(self, layer): t.fill() endVarPrev = time.time() - print "Draw Var Preview Time:", time.time() - startVarPrev + print("Draw Var Preview Time:", time.time() - startVarPrev) # currentState = layer.paths[0] # Adding a state variable and an if statement makes this not as responsive as I'd like @@ -669,7 +647,7 @@ def background(self, layer): drawFuture = time.time() for proxy in previewProxies: self.showAll(layer, currentGlyphName, pathIndex, interpolatedIndex, nodeScale, proxy) - print "Drew Future %s" % (time.time() - drawFuture) + print("Drew Future %s" % (time.time() - drawFuture)) # FUTURE block ———————————————————————————————————————————————————————————— @@ -722,7 +700,7 @@ def background(self, layer): drawFuture = time.time() for proxy in previewProxies: self.showAll(layer, currentGlyphName, pathIndex, interpolatedIndex, nodeScale, proxy) - print "Drew Future %s" % (time.time() - drawFuture) + print("Drew Future %s" % (time.time() - drawFuture)) # FUTURE block ———————————————————————————————————————————————————————————— @@ -752,8 +730,9 @@ def background(self, layer): p.stroke() end = time.time() - print end - start + print(end - start) + @objc.python_method def __file__(self): """Please leave this method unchanged""" return __file__ diff --git a/Plugins/VizBez.glyphsReporter/Contents/Info.plist b/Plugins/VizBez.glyphsReporter/Contents/Info.plist index 6cadb1d..aa5b30b 100755 --- a/Plugins/VizBez.glyphsReporter/Contents/Info.plist +++ b/Plugins/VizBez.glyphsReporter/Contents/Info.plist @@ -3,9 +3,7 @@ CFBundleDevelopmentRegion - English - CFBundleDisplayName - VizBez + en CFBundleExecutable plugin CFBundleIdentifier @@ -14,25 +12,13 @@ 6.0 CFBundleName VizBez - CFBundlePackageType - BNDL - CFBundleVersion - ____BundleVersion____ CFBundleShortVersionString - ____BundleVersionString____ - UpdateFeedURL - ____OnlineUrlToThisPlist____ - productPageURL - ____ProductPageURL____ - productReleaseNotes - ____LatestReleaseNotes____ + 3 + CFBundleVersion + 0.1 NSHumanReadableCopyright Copyright, MichaelLaGattuta, ____YEAR____ NSPrincipalClass VizBez - PyMainFileNames - - ../MacOS/main.py - diff --git a/Plugins/VizBez.glyphsReporter/Contents/MacOS/main.py b/Plugins/VizBez.glyphsReporter/Contents/MacOS/main.py deleted file mode 100755 index 028888c..0000000 --- a/Plugins/VizBez.glyphsReporter/Contents/MacOS/main.py +++ /dev/null @@ -1,16 +0,0 @@ -def _run(script): - global __file__ - import os, sys - sys.frozen = 'macosx_plugin' - base = os.environ['RESOURCEPATH'] - __file__ = path = os.path.join(base, script) - if sys.version_info[0] == 2: - with open(path, 'rU') as fp: - source = fp.read() + "\n" - else: - with open(path, 'r', encoding='utf-8') as fp: - source = fp.read() + '\n' - - exec(compile(source, path, 'exec'), globals(), globals()) - -_run('plugin.py') diff --git a/Plugins/VizBez.glyphsReporter/Contents/MacOS/plugin b/Plugins/VizBez.glyphsReporter/Contents/MacOS/plugin index b21f0e4..3d1b859 100755 Binary files a/Plugins/VizBez.glyphsReporter/Contents/MacOS/plugin and b/Plugins/VizBez.glyphsReporter/Contents/MacOS/plugin differ diff --git a/Plugins/VizBez.glyphsReporter/Contents/PkgInfo b/Plugins/VizBez.glyphsReporter/Contents/PkgInfo deleted file mode 100755 index 19a9cf6..0000000 --- a/Plugins/VizBez.glyphsReporter/Contents/PkgInfo +++ /dev/null @@ -1 +0,0 @@ -BNDL???? \ No newline at end of file diff --git a/Plugins/VizBez.glyphsReporter/Contents/Resources/plugin.py b/Plugins/VizBez.glyphsReporter/Contents/Resources/plugin.py index 2a57099..1ed1a55 100755 --- a/Plugins/VizBez.glyphsReporter/Contents/Resources/plugin.py +++ b/Plugins/VizBez.glyphsReporter/Contents/Resources/plugin.py @@ -1,4 +1,5 @@ # encoding: utf-8 +from __future__ import division, print_function, unicode_literals ########################################################################################################### # @@ -18,9 +19,10 @@ class VizBez(ReporterPlugin): + @objc.python_method def settings(self): self.menuName = Glyphs.localize({'en': u'VizBez'}) - + @objc.python_method def roundDotForPoint(self, thisPoint, markerWidth): """ from Show Angled Handles by MekkaBlue @@ -29,7 +31,7 @@ def roundDotForPoint(self, thisPoint, markerWidth): myRect = NSRect( ( thisPoint[0] - markerWidth * 0.5, thisPoint[1] - markerWidth * 0.5 ), ( markerWidth, markerWidth ) ) return NSBezierPath.bezierPathWithOvalInRect_(myRect) - + @objc.python_method def nodeColor(self, nodePrev, node, nodeNext, angleTolerance=1.0): def getDelta(node, node2, previous): if previous == True: @@ -70,7 +72,8 @@ def getDelta(node, node2, previous): greenValue = 1.0 - ((diff % angleTolerance) / angleTolerance) return (redValue, greenValue) - + + @objc.python_method def drawBezier(self, resolution, points, scale): def pointOnBezier(t, points): n = len(points) - 1 @@ -193,6 +196,7 @@ def factorial(num): p.stroke() return steps + @objc.python_method def background(self, layer): scale = Glyphs.font.currentTab.scale nodeScale = 8.0 / scale @@ -222,7 +226,7 @@ def background(self, layer): if j < (len(pathSteps) - 1): n = NSBezierPath.bezierPath() color = self.nodeColor(pathSteps[j - 1][i], point, pathSteps[j + 1][i], angleTolerance=angleTolerance) - print j, color + print(j, color) n.appendBezierPath_(self.roundDotForPoint(point, nodeScale)) storeNodes.append( (n, NSColor.colorWithCalibratedRed_green_blue_alpha_(color[0] ,color[1] , 0.0, 1.0)) ) NSColor.colorWithCalibratedRed_green_blue_alpha_(0.0, 0.0, 1.0, 0.5).set() @@ -233,6 +237,7 @@ def background(self, layer): color.set() node.fill() + @objc.python_method def __file__(self): """Please leave this method unchanged""" return __file__