def saveCallback(self, sender): data = { "threaded": self.w.threaded.get(), "exportInFolders": self.w.exportInFolders.get(), "keepFileNames": self.w.keepFileNames.get() } setExtensionDefault(self.identifier, data) setDefault("Batch.Debug", self.w.debug.get()) self.closeCallback(sender)
def resize(self, sender): SWM = getDefault("singleWindowMode") fw = CurrentFontWindow() fo = fw.fontOverview gc = fo.getGlyphCollection() v = gc.getGlyphCellView() # make cells small first starter = 10 v.setCellSize_([starter, starter]) # get the width of the whole window x, y, w, h = fw.window().getPosSize() # get the width of overall font overview fo_w = fo.getNSView().frameSize().width # get the width of the cell view vw, vh = v.frameSize().width, v.frameSize().height # get the width of the sets menu to the left of the font overview sets_w = fo_w - vw # get number of glyphs num_g = len(gc.getGlyphNames()) cells_across = 1 cw = int(vw / cells_across) while ((num_g) / cells_across) * cw > vh: cells_across += 1 cw = ch = int(vw / cells_across) vw = cw * cells_across fo_total_w = vw + sets_w # set frame size in single window mode if SWM == 1: fw.editor.splitView.setDimension('fontOverview', fo_total_w) fw.editor.splitView.setDimension('glyphView', w - fo_total_w) fw.centerGlyphInView() # set frame size in multi-window mode else: windows = NSApp().orderedWindows() (x, y), (w, h) = windows[0].frame() x_diff = w - fo_total_w windows[0].setFrame_display_animate_( ((x + x_diff, y), (fo_total_w, h)), True, False) # change the cell size once and for all, update the slider to reflect the change v.setCellSize_([cw, ch]) fo.views.sizeSlider.set(cw) # set this as the new default cell size (this happens when you use the native slide too) setDefault("fontCollectionViewGlyphSize", int(cw))
from fontTools.pens import boundsPen from fontTools.pens import reverseContourPen from fontTools.misc import arrayTools from fontTools.misc import bezierTools # lets start import warnings import sys from types import ModuleType import mojo from mojo.UI import setDefault # force warnings to be displayed setDefault("warningsLevel", "once") warnings.resetwarnings() warnings.simplefilter("once") # a simple wrapper around a func/class thingy # just to post a deprecated warning def warnWrapper(func, rootModule, oldModule, newModule): def wrapper(*args, **kwargs): message = "%s is deprecated use '%s' instead of '%s'" % ( rootModule, newModule, oldModule) warnings.warn(message, DeprecationWarning) return func(*args, **kwargs) return wrapper
# add guide in middle, baseline to cap height from mojo.UI import setDefault f = CurrentFont() g = CurrentGlyph() setDefault("defaultGuidelineShowMeasurment", 1) glyphCenter = g.width / 2 print(glyphCenter) help(g.appendGuideline) g.appendGuideline((glyphCenter, 0), 90, name="glyphCenter") #setDefault("defaultGuidelineShowMeasurment", 0)
def _applyTheme(self, theme): # Do the actual applying of the theme for key, val in theme.items(): setDefault(key, val) PostNotification("doodle.preferencesChanged")
italicAngle = f.info.italicAngle else: italicAngle = 0 # clear existing guides in glyph def clearGuides(): for guide in g.guidelines: g.removeGuideline(guide) # if the glyph already has a bunch of guides clear them and set default guides to be unlocked; otherwise, add them if len(g.guidelines) > 10: print("🤖 There are more than 10 guidelines. Now clearing guides.") clearGuides() setDefault("glyphViewLockGuides", False) # set to False to unlock guidelines else: print("🤖 Applying a grid of guidelines with a size of " + str(gridSize)) print("🤖 You have a leftover of " + str(UPM % divisions) + " units.") clearGuides() setDefault("glyphViewLockGuides", True) italicOffset = f.lib["com.typemytype.robofont.italicSlantOffset"] # add vertical guides for x in range(0, g.width + gridSize, gridSize): if italicOffset: xPos = italicOffset else: xPos = 0
hasMojo = False try: CurrentFont except NameError: class CurrentFont(dict): def save(self, path=None): pass f = CurrentFont() if hasMojo: glyphViewRoundValues = getDefault("glyphViewRoundValues") setDefault("glyphViewRoundValues", 0) for g in f: g.leftMargin = 0 g.rightMargin = 0 n = g.naked() d = g.getLayer("union") d.clear() d.appendGlyph(g) d.removeOverlap(round=0) if len(g) > 1: for method in "xor", "difference", "intersection": d = g.getLayer(method) d.clear()
import toolBox from mojo.UI import setDefault setDefault("Batch.Debug", False) toolBox.ToolBox()
hasMojo = False try: CurrentFont except NameError: class CurrentFont(dict): def save(self, path=None): pass f = CurrentFont() if hasMojo: glyphViewRoundValues = getDefault("glyphViewRoundValues") setDefault("glyphViewRoundValues", 0) for g in f: g.leftMargin = 0 g.rightMargin = 0 n = g.naked() d = g.getLayer("union") d.clear() d.appendGlyph(g) d.removeOverlap(round=0) if len(g) > 1: for method in "xor", "difference", "intersection": d = g.getLayer(method) d.clear() func = getattr(booleanOperations, method)
italicAngle = 0 # clear existing guides in glyph def clearGuides(): for guide in g.guidelines: g.removeGuideline(guide) # if the glyph already has a bunch of guides clear them and set default guides to be unlocked; otherwise, add them if len(g.guidelines) > 10: print("🤖 There are more than 10 guidelines. Now clearing guides.") clearGuides() # set to False to unlock guidelines setDefault("glyphViewLockGuides", False) else: print("🤖 Applying a grid of guidelines with a size of " + str(gridSize)) print("🤖 You have a leftover of " + str(UPM % divisions) + " units.") clearGuides() setDefault("glyphViewLockGuides", True) italicOffset = f.lib["com.typemytype.robofont.italicSlantOffset"] # add vertical guides for x in range(0, g.width + gridSize, gridSize): if italicOffset: xPos = italicOffset else: xPos = 0