def __init__(self): self.fullMetadata = getExtensionDefault("%s.scriptMetadata" % KEYPREFIX, fallback={}) if not len(self.fullMetadata.keys()): # "Restart" window self.w = vanilla.Window((500, 160), "Andy’s RoboFont Hacks") self.w.hr = vanilla.HorizontalLine((10, -50, -10, 1)) self.w.restartText = vanilla.TextBox( (20, 20, -20, -45), text_Bold( "Installed and updated.\nRestart RoboFont to refresh the list of my RoboFont hacks.\n\n — Andy Clymer" )) self.w.okButton = vanilla.Button((-120, -35, 100, 20), "OK", callback=self.cancelCallback) self.w.open() else: # Full window self.w = vanilla.Window((750, 300), "Andy’s RoboFont Hacks") columnDescriptions = [{ "title": "state", "width": 20, "cell": vanilla.CheckBoxListCell() }, { "title": "longName" }] self.w.scriptList = vanilla.List( (10, 10, 300, -60), [], allowsMultipleSelection=False, showColumnTitles=False, selectionCallback=self.listSelectionChanged, columnDescriptions=columnDescriptions) self.defaultTitle = "Andy’s RoboFont Hacks" self.defaultText = "A selection of extras that make RoboFont work the way I like it. \n\nEverything is optional, click on one of the names on the left for a description of what the add-on does. Select as many as you like by checking the box to the left of the name, and restart RoboFont to activate.\n\n — Andy Clymer" self.w.descriptionBox = vanilla.Box((320, 10, -10, -60)) self.w.descriptionBox.title = vanilla.TextBox((5, 5, -10, 25), self.defaultTitle) self.w.descriptionBox.text = vanilla.TextBox((5, 38, -10, -10), self.defaultText) #self.w.webView = WebView.alloc().initWithFrame_(((0, 0), (320, 1000))) #self.w.scroll = vanilla.ScrollView((320, 10, -10, -60), self.w.webView, hasHorizontalScroller=False, hasVerticalScroller=False) #self.w.webView.setMainFrameURL_(self.htmlPath) self.w.hr = vanilla.HorizontalLine((10, -50, -10, 1)) self.w.changeNote = vanilla.TextBox( (20, -32, -230, 25), text_SmallGray("Any change will require restarting RoboFont."), sizeStyle="small") self.w.cancelButton = vanilla.Button((-230, -35, 100, 20), "Cancel", callback=self.cancelCallback) self.w.applyButton = vanilla.Button((-120, -35, 100, 20), "Apply", callback=self.applyCallback) self.populateList() self.w.open()
def __init__(self): windowWidth = 200 windowHeight = 240 self.w = vanilla.FloatingWindow((50, 50, windowWidth, windowHeight), "CopySidebearings") self.fonts = [(makeDefaultIDString(font), font) for font in AllFonts()] fontNames = [i[0] for i in self.fonts] # dropdowns self.w.sourceUFOText = vanilla.TextBox((15, 15, 90, 22), "Source UFO:", sizeStyle="small") self.w.sourceUFODropDown = vanilla.PopUpButton((15, 30, 170, 20), fontNames) self.w.sourceUFODropDown.set(0) self.w.destinationUFOText = vanilla.TextBox((15, 60, 90, 22), "Destination UFO:", sizeStyle="small") self.w.destinationUFODropDown = vanilla.PopUpButton((15, 75, 170, 20), fontNames) self.w.destinationUFODropDown.set(1) # divider self.w.divider1 = vanilla.HorizontalLine((15, 108, -15, 1)) # glyphs scope area self.w.iconAllGlyphs = vanilla.ImageView((15, 123, 12, 13)) self.w.iconAllGlyphs.setImage(imagePath="../resources/allGlyphs.png") self.w.iconSelGlyphs = vanilla.ImageView((15, 149, 12, 13)) self.w.iconSelGlyphs.setImage( imagePath="../resources/selectedGlyphs.png") self.w.glyphsRadioGroup = vanilla.RadioGroup( (32, 118, -15, 50), ["All Glyphs", "Selected Glyphs"], sizeStyle="small") self.w.glyphsRadioGroup.set(0) # default to all glyphs # divider self.w.divider2 = vanilla.HorizontalLine((15, 176, -15, 1)) # commit button self.w.commitButton = vanilla.Button( (15, 188, -15, 20), "Copy Sidebearings", sizeStyle="small", callback=self._commitButtonCallback) # note self.w.note = vanilla.TextBox((15, 215, -15, 15), "Open output window for results.", sizeStyle="mini", alignment="center") self.w.open() # go go gadget window
def __init__(self): windowWidth = 200 windowHeight = 270 # amount area self.w = vanilla.FloatingWindow((windowWidth, windowHeight), "AdjustMargins") self.w.amountText = vanilla.TextBox((15, 17, 65, 22), "Amount:", sizeStyle="small") self.w.amountTextBox = vanilla.EditText((70, 12, -15, 22)) # divider self.w.divider1 = vanilla.HorizontalLine((15, 48, -15, 1)) # glyphs scope area self.w.iconAllGlyphs = vanilla.ImageView((15, 65, 12, 13)) self.w.iconAllGlyphs.setImage(imagePath="../resources/allGlyphs.png") self.w.iconSelGlyphs = vanilla.ImageView((15, 91, 12, 13)) self.w.iconSelGlyphs.setImage( imagePath="../resources/selectedGlyphs.png") self.w.glyphsRadioGroup = vanilla.RadioGroup( (32, 60, -15, 50), ["All Glyphs", "Selected Glyphs"], sizeStyle="small") self.w.glyphsRadioGroup.set(1) # default to just selected glyphs # divider self.w.divider2 = vanilla.HorizontalLine((15, 121, -15, 1)) # margins area self.w.iconBothMargins = vanilla.ImageView((15, 137, 12, 12)) self.w.iconBothMargins.setImage( imagePath="../resources/bothMargins.png") self.w.iconLeftMargin = vanilla.ImageView((15, 161, 12, 12)) self.w.iconLeftMargin.setImage(imagePath="../resources/leftMargin.png") self.w.iconRightMargin = vanilla.ImageView((15, 185, 12, 12)) self.w.iconRightMargin.setImage( imagePath="../resources/rightMargin.png") self.w.marginSelectionGroup = vanilla.RadioGroup( (32, 133, -15, 70), ["Both Margins", "Left Margin Only", "Right Margin Only"], sizeStyle="small") self.w.marginSelectionGroup.set(0) # default both margins # divider self.w.divider3 = vanilla.HorizontalLine((15, 216, -15, 1)) # commit button self.w.commitButton = vanilla.Button( (15, 232, -15, 20), "Commit Adjustments", sizeStyle="small", callback=self.commitButtonCallback) self.w.open() # go go gadget window
def __init__( self ): self.w = vanilla.FloatingWindow( (330, 170), "Anchor Mover 2.0", minSize=(300,170), maxSize=(1000,170), autosaveName="com.mekkablue.AnchorMover2.mainwindow" ) self.w.text_1 = vanilla.TextBox((15-1, 12+2, 75, 14), "Move anchor", sizeStyle='small' ) self.w.anchor_name = vanilla.PopUpButton((15+75, 12, -110-15-25, 17), self.GetAnchorNames(), sizeStyle='small' ) self.w.button = vanilla.SquareButton((-110-15-20, 12, -110-15, 18), u"↺", sizeStyle='small', callback=self.SetAnchorNames ) self.w.text_2 = vanilla.TextBox((-105-15, 12+2, -15, 14), "in selected glyphs:", sizeStyle='small' ) self.w.hLine_1 = vanilla.HorizontalLine((15, 40, -15, 1)) self.w.hText_1 = vanilla.TextBox((15-2, 40+12, 20, 14), u"↔", sizeStyle='regular' ) self.w.hText_2 = vanilla.TextBox((15+20, 40+12+2, 20, 14), "to", sizeStyle='small' ) self.w.hTarget = vanilla.PopUpButton((15+40, 40+12, -50-15-15-15, 17), [x[0] for x in listHorizontal], sizeStyle='small', callback=self.SavePreferences ) self.w.hText_3 = vanilla.TextBox((-60-15-15, 40+12+2, -50-15, 14), "+", sizeStyle='small' ) self.w.hChange = vanilla.EditText((-60-15, 40+12, -15, 19), "0.0", sizeStyle='small', callback=self.SavePreferences ) self.w.vText_1 = vanilla.TextBox((15, 70+12, 20, 14), u"↕", sizeStyle='regular' ) self.w.vText_2 = vanilla.TextBox((15+20, 70+12+2, 20, 14), "to", sizeStyle='small' ) self.w.vTarget = vanilla.PopUpButton((15+40, 70+12, -50-15-15-15, 17), [y[0] for y in listVertical], sizeStyle='small', callback=self.SavePreferences ) self.w.vText_3 = vanilla.TextBox((-60-15-15, 70+12+2, -50-15, 14), "+", sizeStyle='small' ) self.w.vChange = vanilla.EditText((-60-15, 70+12, -15, 19), "0.0", sizeStyle='small', callback=self.SavePreferences ) self.w.italic = vanilla.CheckBox((15, 110, -15, 18), "Respect italic angle", value=True, sizeStyle='small', callback=self.SavePreferences ) self.w.moveButton = vanilla.Button((-80-15, -20-15, -15, -15), "Move", sizeStyle='regular', callback=self.MoveCallback ) self.w.setDefaultButton( self.w.moveButton ) if not self.LoadPreferences( ): print "Error: Could not load preferences. Will resort to defaults." self.w.open()
def __init__( self ): # Window 'self.w': textY = 19 spaceX = 10 spaceY = 10 buttonX = 90 buttonY = 20 windowWidth = spaceX*4+buttonX*3 windowHeight = spaceY*6+textY*2+buttonY self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "Set Kerning Groups", # window title ) self.w.textLower = vanilla.TextBox((spaceX, spaceY, 200, textY), "Lowercase style?", sizeStyle='regular') self.w.normalButton = vanilla.Button((spaceX, spaceY*2+textY, buttonX, buttonY), "Normal", sizeStyle='regular', callback=self.SetKernPairsMain ) self.w.cursiveButton = vanilla.Button((spaceX*2+buttonX, spaceY*2+textY, buttonX, buttonY), "Cursive", sizeStyle='regular', callback=self.SetKernPairsMain ) self.w.allcapButton = vanilla.Button((spaceX*3+buttonX*2, spaceY*2+textY, buttonX, buttonY), "All Cap", sizeStyle='regular', callback=self.SetKernPairsMain ) self.w.line = vanilla.HorizontalLine((spaceX, spaceX*4+textY*2, -spaceX, 1)) self.w.radioButton = vanilla.RadioGroup((spaceX, spaceY*5+textY*2, 300, textY), ["All Glyphs", "Selected Glyphs"], sizeStyle='regular', isVertical=False) # Open window and focus on it: self.w.open() self.w.radioButton.set(0) self.w.makeKey()
def __init__(self, frameToCenterInside, screen, callback): self._callback = callback width = 180 height = 97 (frameXMin, frameYMin), (frameWidth, frameHeight) = frameToCenterInside screenTop = screen.frame()[0][1] frameTop = screenTop - (frameYMin + frameHeight) x = frameXMin + ((frameWidth - width) / 2) y = frameTop + ((frameHeight - height) / 2) formatter = NSNumberFormatter.alloc().init() formatter.setFormat_("#;0;-#") formatter.setAllowsFloats_(False) formatter.setGeneratesDecimalNumbers_(False) formatter.setMinimum_(NSNumber.numberWithInt_(1)) self.w = InteractivePopUpWindow((x, y, width, height)) self.w.title = vanilla.TextBox((15, 18, 88, 17), "Jump to line:") self.w.lineInput = vanilla.EditText((103, 15, -15, 22), formatter=formatter) self.w.lineInput.getNSTextField().setFocusRingType_(NSFocusRingTypeNone) self.w.line = vanilla.HorizontalLine((15, -50, -15, 1)) self.w.cancelButton = vanilla.Button((15, -35, 70, 20), "Cancel", callback=self.cancelCallback) self.w.okButton = vanilla.Button((95, -35, 70, 20), "OK", callback=self.okCallback) self.w.setDefaultButton(self.w.okButton) self.w.cancelButton.bind(".", ["command"]) self.w.getNSWindow().makeFirstResponder_(self.w.lineInput.getNSTextField()) self.w.open()
def _heading(self, title): self.leading += 20 setattr(self.w, 'text%s' % self.head_count, vanilla.TextBox((14, self.leading, 300, 14), title, sizeStyle='small')) self.leading += 12 self.head_count += 1 setattr(self.w, 'rule%s' % self.head_count, vanilla.HorizontalLine((14, self.leading, 300, 14))) self.leading += 12
def __init__( self ): windowWidth = 400 windowHeight = 280 self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "ALL YOUR @BASE BELONG TO US.", # window title autosaveName = "com.Tosche.BatchMetricKey.mainwindow" # stores last window position and size ) # UI elements: self.w.presetText = vanilla.TextBox( ( 12, 13, 55, 17), "Presets:", sizeStyle='regular' ) self.w.presetPopup = vanilla.PopUpButton( (14+58, 13, -15, 17), [str(x) for x in presets], callback=self.setField, sizeStyle='regular' ) self.w.keyTextField = vanilla.EditText( (14, 45, -15, 22), re.sub(" .*", "", presets[0]), sizeStyle = 'regular') self.w.setToText = vanilla.TextBox( ( 12, 78, 50, 17), "Set to:", sizeStyle='regular' ) self.w.applyL = vanilla.CheckBox( ( 12+50, 78, 50, 22), "Left", value=True, sizeStyle='regular') self.w.applyR = vanilla.CheckBox( ( 12+50+50, 78, 56, 22), "Right", value=True, sizeStyle='regular') self.w.avoidNest = vanilla.CheckBox( ( 275, 78, 115, 22), "Adoid Nesting", value=True, sizeStyle='regular') self.w.radioQText = vanilla.TextBox( ( 12, 115, 100, 17), "If there is Q:", sizeStyle='regular' ) self.w.radioQ = vanilla.RadioGroup( (100, 115, 350, 19), ["Use width of O (no key)", "Use RSB of Q"], sizeStyle='regular', isVertical=False) self.w.radioQ.set(0) self.w.line = vanilla.HorizontalLine((12, 190, -10, 1)) self.w.explain = vanilla.TextBox( ( 12, 200, 350, 80), "@base is a glyph without suffix of the selected glyph.\n@base of hsuperior is h\n@Base of a.smcp is A\[email protected] of one.numr is one.smcp", sizeStyle='regular' ) # Run Button: self.w.setButton = vanilla.Button((290, 145, 90, 34), "Set", sizeStyle='regular', callback=self.BatchMetricKeyMain ) self.w.setDefaultButton( self.w.setButton ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self, glyph, construction, decompose): self.glyph = glyph width = 350 height = 120 editorWindow = CurrentGlyphWindow() (editorX, editorY, editorW, editorH), screen = getGlyphEditorRectAndScreen(editorWindow) x = editorX + ((editorW - width) / 2) y = editorY + ((editorH - height) / 2) self.w = StatusInteractivePopUpWindow((x, y, width, height), screen=screen) self.w.constructionEditor = vanilla.EditText((15, 15, -15, 22), construction) self.w.decomposeCheckBox = vanilla.CheckBox((15, 45, -15, 22), "Decompose", value=decompose) self.w.open() self.w.line = vanilla.HorizontalLine((15, -45, -15, 1)) self.w.cancelButton = vanilla.Button( (-165, -35, 70, 20), "Cancel", callback=self.cancelButtonCallback) self.w.okButton = vanilla.Button((-85, -35, 70, 20), "OK", callback=self.okButtonCallback) self.w.setDefaultButton(self.w.okButton) self.w.cancelButton.bind(".", ["command"]) self.w.getNSWindow().makeFirstResponder_( self.w.constructionEditor.getNSTextField()) self.w.open()
def __init__(self): self.w = vanilla.FloatingWindow((200, 120), "Sidebearings EQ") self.w.iconAll = vanilla.ImageView((15, 16, 13, 10)) self.w.iconAll.setImage(imagePath="allglyphs.png") self.w.iconSelected = vanilla.ImageView((15, 43, 13, 10)) self.w.iconSelected.setImage(imagePath="selectedglyphs.png") self.w.scopeRadioGroup = vanilla.RadioGroup( (35, 10, -15, 50), ["All Glyphs", "Selected Glyphs"], sizeStyle="small") self.w.scopeRadioGroup.set(1) self.w.divider1 = vanilla.HorizontalLine((15, 70, -15, 1)) self.w.applyButton = vanilla.Button((15, 85, -15, 20), "Equalize Sidebearings", sizeStyle="small", callback=self.applyButtonCallback) self.w.open()
def __init__(self): self.keysToControls = {} self.w = vanilla.FloatingWindow((185, 415), "Glyph Nanny") self.top = 10 controls = [ dict(key="unicodeValue", title="Unicode Value"), dict(key="contourCount", title="Contour Count") ] self.buildSettingsGroup("glyphChecks", "Glyph Checks", controls) controls = [ dict(key="strayPoints", title="Stray Points"), dict(key="smallContours", title="Small Contours"), dict(key="openContours", title="Open Contours"), dict(key="duplicateContours", title="Duplicate Contours"), dict(key="extremePoints", title="Extreme Points"), dict(key="unnecessaryPoints", title="Unnecessary Points"), dict(key="unnecessaryHandles", title="Unnecessary Handles"), dict(key="overlappingPoints", title="Overlapping Points"), dict(key="pointsNearVerticalMetrics", title="Points Near Vertical Metrics"), dict(key="complexCurves", title="Complex Curves"), dict(key="crossedHandles", title="Crossed Handles"), dict(key="straightLines", title="Straight Lines"), dict(key="unsmoothSmooths", title="Unsmooth Smooths"), ] self.buildSettingsGroup("outlineChecks", "Outline Checks", controls) self.w.fontLine = vanilla.HorizontalLine((10, self.top, -10, 1)) self.top += 10 self.w.testFontButton = vanilla.Button( (10, self.top, -10, 17), "Test Entire Font", sizeStyle="small", callback=self.testFontButtonCallback) self.setUpBaseWindowBehavior() self.startObserver() self.settingsCallback(None) self.w.open()
def __init__(self): self.currentGlyph = None self.window = None self.fonts = [] self.fontNames = [] self.glyph0 = RGlyph() #None self.glyph1 = RGlyph() #None self.compatibilityReport = None self.interpolatedGlyph = RGlyph() self.w = vanilla.FloatingWindow((250, 155), "Interpolation Slider") self.w.open() self.w.title = vanilla.TextBox((10, 10, -10, 25), "Masters:", sizeStyle="small") self.w.font0 = vanilla.PopUpButton((10, 25, -10, 25), [], callback=self.glyphChanged, sizeStyle="small") self.w.font1 = vanilla.PopUpButton((10, 50, -10, 25), [], callback=self.glyphChanged, sizeStyle="small") self.w.compatibilityText = vanilla.TextBox((-105, 83, 100, 35), u"Compatibility: ⚪️", sizeStyle="small") self.w.line = vanilla.HorizontalLine((5, 110, -5, 1)) self.w.interpValue = vanilla.Slider((10, 120, -10, 25), callback=self.optionsChanged, minValue=0, maxValue=1) self.w.interpValue.set(0.5) self.w.bind("close", self.closed) self.collectFonts() self.glyphChanged(None) addObserver(self, "glyphChanged", "currentGlyphChanged") addObserver(self, "fontsChanged", "newFontDidOpen") addObserver(self, "fontsChanged", "fontDidOpen") addObserver(self, "fontsChanged", "fontDidClose") addObserver(self, "drawBkgnd", "drawBackground") addObserver(self, "drawPreview", "drawPreview")
def __init__(self): width, height = 600,50 self.w = vanilla.FloatingWindow((width, height),"") self.w.center() # Setting Window Appearance window = self.w.getNSWindow() window.setTitlebarAppearsTransparent_(1) # Hide title bar window.setStandardWindowTitleButtonsAlphaValue_(0.00001) # Hiding buttons hack window.setBackgroundColor_(NSColor.whiteColor()) # Window background window.setAlphaValue_(0.9) # Slight transparency, don't know how to apply vibrancy like in spotlight self.w.editText = vanilla.EditText((20, 0, -20, -14), continuous=False, callback=self.test) # Setting EditText Appearance font = NSFont.systemFontOfSize_weight_(28,-0.5) box = self.w.editText.getNSTextField() box.setBordered_(False) box.setDrawsBackground_(False) box.setFont_(font) box.setFocusRingType_(NSFocusRingTypeNone) # Open window and focus self.w.open() self.w.select() self.w.infoText = vanilla.TextBox((10, -25, -1, -1), "") infoBox = self.w.infoText.getNSTextField() infoBox.setBordered_(False) infoBox.setDrawsBackground_(False) # infoBox.setFont_(font) infoBox.setFocusRingType_(NSFocusRingTypeNone) self.w.line = vanilla.HorizontalLine((10, -56, -10, 0)) self.w.line.show(0)
def __init__(self): self.bundle = DrawBotPackage() self.w = vanilla.Window((350, 320), "Package builder") y = 10 m = 120 for attr in self.packageInfo: text = vanilla.TextBox((10, y, m - 15, 22), "%s:" % attr, alignment="right") edit = vanilla.EditText( (m, y, -10, 22), placeholder=getattr(self.bundle.info, attr)) setattr(self.w, "%s_text" % attr, text) setattr(self.w, "%s_edit" % attr, edit) y += 30 self.w.note = vanilla.TextBox((m, y, -10, 22), "Everything is optional.", sizeStyle="mini") y += 30 self.w.h1 = vanilla.HorizontalLine((0, y, 0, 1)) y += 10 self.w.scriptRoot_text = vanilla.TextBox((10, y, m - 15, 22), "Script Root:", alignment="right") self.w.scriptRoot = vanilla.PathControl( (m, y - 2, -10, 22), None, pathStyle="popUp", callback=self.scriptRootCallback) y += 25 self.w.scriptRoot_note = vanilla.TextBox( (m, y, -10, 22), "A folder containing all required python files.", sizeStyle="mini") self.w.buildButton = vanilla.Button((-120, -30, -10, 22), "Build", callback=self.buildCallback) self.w.open()
def __init__(self): self._unsubscribeGlyphCallback = None self._holdGlyphUpdates = False self.w = vanilla.Window((500, 600), self.title, minSize=(500, 500)) y = -(10 + 30 + len(self.attributes) * 30) self.w.preview = GlyphPreview((0, 0, -0, y)) middleLeft = 120 middleRight = middleLeft + 20 right = -10 self.w.hl = vanilla.HorizontalLine((0, y, -0, 1)) y += 10 for attr, kwargs in self.attributes: if kwargs.get("title") is None: txtObj = vanilla.TextBox((10, y, middleLeft, 22), "%s:" % attr, alignment="right") setattr(self.w, "%sText" % camelCase(attr), txtObj) uiElement = kwargs.get("ui", "Slider") if uiElement == "Slider" or uiElement is None: obj = SliderEditFloatStepper else: del kwargs["ui"] obj = getattr(vanilla, uiElement) obj = obj((middleRight, y - 2, -7, 22), callback=self.parametersChanged, **kwargs) setattr(self.w, camelCase(attr), obj) y += 30 self.w.apply = vanilla.Button((-150+right, y, -10, 22), "Apply Glyph", callback=self.applyCallback) self.w.newFont = vanilla.Button((-150+right-10-150, y, -150+right-10, 22), "New Font", callback=self.generateFontCallback) self.w.showInSpaceCenter = vanilla.CheckBox((10, y, 160, 22), "Show In Space Center", callback=self.showInSpaceCenterCallback) addObserver(self, "currentGlyphChanged", "currentGlyphChanged") self.w.bind("close", self.windowClose) self.parametersChanged() self.w.open()
def buildSettingsGroup(self, groupID, title, items): tb = vanilla.TextBox((10, self.top, -10, 14), title, sizeStyle="small") l = vanilla.HorizontalLine((10, self.top + 18, -10, 1)) setattr(self.w, groupID + "Title", tb) setattr(self.w, groupID + "Line", l) self.top += 24 for item in items: key = item["key"] attr = key + "CheckBox" title = item["title"] default = item.get("default", True) cb = vanilla.CheckBox((10, self.top, -10, 18), title, value=default, sizeStyle="small", callback=self.settingsCallback) setattr(self.w, attr, cb) self.keysToControls[key] = cb self.top += 20 self.top += 10
def __init__(self, resources_path): self.pref_key = 'com.ryanbugden.sidebear.increment' initialDefaults = { self.pref_key: 2, } registerExtensionDefaults(initialDefaults) try: self.g = CurrentGlyph() except: self.g = None window_width = 255 window_margin = 20 gutter = 25 vert_gutter = 12 rule_gutter = vert_gutter - 2 text_box_height = 20 row_1_y = -14 row_2_y = row_1_y + vert_gutter + text_box_height - 5 row_3_y = row_2_y + vert_gutter + text_box_height row_4_y = row_3_y + text_box_height + rule_gutter row_5_y = row_4_y + rule_gutter third_width = (window_width - (window_margin * 2) - (gutter * 2)) / 3 self.window_height = window_margin * 2 + row_5_y + text_box_height + 8 # The group of elements self.w = vanilla.Group((0, 0, -0, -0)) # Current glyph self.w.curr_glyph_note = vanilla.TextBox( (window_margin + third_width / 2, window_margin + row_1_y, third_width * 2 + gutter * 2, text_box_height), "None", sizeStyle="regular", alignment="center") # Left width span rule self.w.left_w_span = vanilla.HorizontalLine( (window_margin + 2, window_margin + row_1_y + (text_box_height / 2), third_width, 1)) # Left width vert rule self.w.left_w_vert = vanilla.VerticalLine( (window_margin + 1, window_margin + row_1_y, 1, text_box_height)) # Right width span rule self.w.right_w_span = vanilla.HorizontalLine( (window_margin + third_width * 2 + gutter * 2, window_margin + row_1_y + (text_box_height / 2), third_width - 1, 1)) # Right width vert rule self.w.right_w_vert = vanilla.VerticalLine( (window_margin + third_width * 3 + gutter * 2 - 1, window_margin + row_1_y, 1, text_box_height)) # Left side-bearing self.w.LSB = vanilla.EditText((window_margin, window_margin + row_2_y, third_width, text_box_height), text="", sizeStyle="small", callback=self.editLSBCallback, continuous=False) self.w.LSB.getNSTextField().setFocusRingType_(1) self.w.LSB.getNSTextField().setAlignment_(2) # Left swap bridge rule self.w.left_sw_rule = vanilla.HorizontalLine( (window_margin + third_width, window_margin + row_2_y + text_box_height / 2, gutter, 1)) # Swap SB button self.w.swap_SB = vanilla.ImageButton( (window_margin + third_width + gutter, window_margin + row_2_y, third_width, text_box_height), imagePath=resources_path + '/_icon_Swap.pdf', callback=self.swapSBButtonCallback, sizeStyle='regular') # Right swap bridge rule self.w.right_sw_rule = vanilla.HorizontalLine( (window_margin + third_width * 2 + gutter, window_margin + row_2_y + text_box_height / 2, gutter, 1)) # Right side-bearing self.w.RSB = vanilla.EditText( (window_margin + third_width * 2 + gutter * 2, window_margin + row_2_y, third_width, text_box_height), text="", sizeStyle="small", callback=self.editRSBCallback, continuous=False) self.w.RSB.getNSTextField().setFocusRingType_(1) self.w.RSB.getNSTextField().setAlignment_(2) # Center Glyph button self.w.center_glyph = vanilla.ImageButton( (window_margin + third_width + gutter, window_margin + row_3_y, third_width, text_box_height), imagePath=resources_path + '/_icon_Center.pdf', callback=self.centerGlyphButtonCallback, sizeStyle='regular') # Left vert bridge rule self.w.left_vert_rule = vanilla.VerticalLine( (window_margin + third_width / 2, window_margin + row_2_y + text_box_height, 1, vert_gutter)) # Right vert bridge rule self.w.right_vert_rule = vanilla.VerticalLine( (window_margin + third_width * 2.5 + gutter * 2, window_margin + row_2_y + text_box_height, 1, vert_gutter)) # Equals RSB button self.w.equals_RSB = vanilla.ImageButton( (window_margin, window_margin + row_3_y, third_width, text_box_height), imagePath=resources_path + '/_icon_EqualRSB.pdf', callback=self.equalsRSBButtonCallback, sizeStyle='regular') # Equals LSB button self.w.equals_LSB = vanilla.ImageButton( (window_margin + third_width * 2 + gutter * 2, window_margin + row_3_y, third_width, text_box_height), imagePath=resources_path + '/_icon_EqualLSB.pdf', callback=self.equalsLSBButtonCallback, sizeStyle='regular') # Rule self.w.rule = vanilla.HorizontalLine( (window_margin, window_margin + row_4_y, third_width * 3 + gutter * 2, 1)) # Increment input self.increment = getExtensionDefault(self.pref_key, 2) self.w.inc_text_box = vanilla.EditText( (window_margin + gutter + third_width, window_margin + row_5_y, third_width, text_box_height), text="%s" % self.increment, sizeStyle="small", callback=self.incrementCallback) self.w.inc_text_box.getNSTextField().setFocusRingType_(1) self.w.inc_text_box.getNSTextField().setAlignment_(2) # Left expand/contract bridge rule self.w.left_ec_rule = vanilla.HorizontalLine( (window_margin + third_width, window_margin + row_5_y + text_box_height / 2, gutter, 1)) # Right expand/contract bridge rule self.w.right_ec_rule = vanilla.HorizontalLine( (window_margin + third_width * 2 + gutter, window_margin + row_5_y + text_box_height / 2, gutter, 1)) # Close SBs self.w.close_SB = vanilla.ImageButton( (window_margin, window_margin + row_5_y, third_width, text_box_height), imagePath=resources_path + '/_icon_Close.pdf', callback=self.closeSBButtonCallback, sizeStyle='regular') # Open SBs self.w.open_SB = vanilla.ImageButton( (window_margin + third_width * 2 + gutter * 2, window_margin + row_5_y, third_width, text_box_height), imagePath=resources_path + '/_icon_Open.pdf', callback=self.openSBButtonCallback, sizeStyle='regular') # Increment self.w.incr_caption = vanilla.TextBox( (window_margin + third_width, window_margin + row_5_y + 23, third_width + gutter * 2, text_box_height), "Increment", sizeStyle="mini", alignment="center") addObserver(self, "glyphChanged", "currentGlyphChanged") addObserver(self, "glyphChanged", "viewDidChangeGlyph") addObserver(self, "glyphChanged", "glyphWindowDidOpen") addObserver(self, "glyphDraw", "draw") self.updateUI_BothSB()
def __init__(self): # Window 'self.w': edY = 22 txX = 116 txY = 17 spX = 14 spY = 12 btnX = 60 btnY = 20 windowWidth = 260 windowHeight = 300 windowWidthResize = 100 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Make Bubble Layers", # window title autosaveName= "com.Tosche.MakeBubbleLayers.mainwindow" # stores last window position and size ) # Offset values: self.w.textH = vanilla.TextBox((spX, spY, txX, txY), "Horizontal Offset:") self.w.textV = vanilla.TextBox((spX, spY * 2 + txY, txX, txY), "Vertical Offset:") self.w.editH = vanilla.EditText((-spX - 80, spY, -spX, edY), "60") self.w.editV = vanilla.EditText((-spX - 80, spY * 2 + txY, -spX, edY), "60") self.w.line1 = vanilla.HorizontalLine( (0, spY * 3 + txY * 2 + 5, -0, 1)) # Sidebearing modification: self.w.adhereToSB = vanilla.CheckBox( (spX, spY * 4 + txY * 2, -spX, edY), "Adhere to Sidebearigs", callback=self.checkBoxCallback, value=True) self.w.excess = vanilla.TextBox( (spX + 16, spY * 5 + txY * 3 - 7, -spX, txY), "Exceeding outlines are:") self.w.excessRadio = vanilla.RadioGroup( (spX + 16, spY * 6 + txY * 4 - 14, 160, edY), ["Nudged", "Trimmed"], isVertical=False, ) self.w.line2 = vanilla.HorizontalLine( (0, spY * 6 + txY * 5 - 4, -0, 1)) # Overwrite Behaviour: self.w.textOverwrite = vanilla.TextBox( (spX, spY * 7 + txY * 5 - 8, -spX, txY), "Overwrite existing?") self.w.overwriteRadio = vanilla.RadioGroup( (spX, spY * 8 + txY * 6 - 11, -spX, edY), ["Never", "If Empty", "Always"], isVertical=False, ) self.w.line3 = vanilla.HorizontalLine( (0, spY * 9 + txY * 7 - 8, -0, 1)) # Master preference self.w.masterRadio = vanilla.RadioGroup( (spX, spY * 9 + txY * 7, 0, edY), ["Current Master", "All Masters"], isVertical=False, ) # Run Button: self.w.runButton = vanilla.Button((-80 - 15, -20 - 15, -15, -15), "Go!", sizeStyle='regular', callback=self.MakeBubbleLayersMain) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): self.w.excessRadio.set(0) self.w.overwriteRadio.set(1) self.w.masterRadio.set(1) print "Note: 'Make Bubble Layers' could not load preferences. Will resort to defaults" # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): self.fontList = [] self.fontNames = [] self.fontStems = [] self.estimatedStems = None # Estimated stem measurements for the resulting font # Glyph groups self.groups = [] # Case info, normalized after editing self.normalizedInfo = {} self.dataNorms = { "scaleH": dict(default=100, dataType=float, scale=0.01), "scaleV": dict(default=100, dataType=float, scale=0.01), "interpH": dict(default=100, dataType=float, scale=0.01), "interpV": dict(default=100, dataType=float, scale=0.01), "tracking": dict(default=0, dataType=float, scale=1) } self.w = vanilla.Window((317, 700), "Scale And Interpolate %s" % VERSION, minSize=(317, 300), maxSize=(317, 969), autosaveName="ScaleAndInterp") # 882 height self.g = vanilla.Group((0, 0, 300, 900)) step = 10 self.g.font0title = vanilla.TextBox((10, step, -10, 25), colorText("Lightest Master (0%)", style="bold")) self.g.font0choice = vanilla.PopUpButton( (10, step + 20, -10, 25), self.fontNames, callback=self.fontChoiceChanged) step += 50 self.g.font0stemTextUC = vanilla.TextBox((20, step, -10, 20), "") self.g.font0stemTextLC = vanilla.TextBox((20, step + 20, -10, 20), "") step += 50 self.g.font1title = vanilla.TextBox((10, step, -10, 25), colorText("Heaviest Master (100%)", style="bold")) self.g.font1choice = vanilla.PopUpButton( (10, step + 20, -10, 25), self.fontNames, callback=self.fontChoiceChanged) step += 50 self.g.font1stemTextUC = vanilla.TextBox((20, step, -10, 20), "") self.g.font1stemTextLC = vanilla.TextBox((20, step + 20, -10, 20), "") step += 50 self.g.hr1 = vanilla.HorizontalLine((10, step, -10, 1)) step += 15 self.g.capsTitle = vanilla.TextBox((10, step, -10, 25), colorText("Caps", style="bold")) step += 25 self.g.ucGroups = vanilla.PopUpButton((10, step, -10, 25), []) step += 35 columnDescriptions = [ dict(title="Name"), dict(title="Value", editable=True, width=50) ] capInfo = [ dict(Name="Scale Horizontal %", attr="scaleH", Value=100), dict(Name="Scale Vertical %", attr="scaleV", Value=100), dict(Name="Interpolate Horizontal %", attr="interpH", Value=100), dict(Name="Interpolate Vertical %", attr="interpV", Value=100), dict(Name="Units of tracking", attr="tracking", Value=0) ] self.g.ucInfo = vanilla.List((10, step, -10, 100), capInfo, columnDescriptions=columnDescriptions, showColumnTitles=False, editCallback=self.dataChanged) step += 110 self.g.resultStemTextUC = vanilla.TextBox((20, step, -10, 20), "") step += 30 self.g.lcTitle = vanilla.TextBox((10, step, -10, 25), colorText("Lowercase", style="bold")) step += 25 self.g.lcGroups = vanilla.PopUpButton((10, step, -10, 25), []) step += 35 lcInfo = [ dict(Name="Scale Horizontal %", attr="scaleH", Value=100), dict(Name="Scale Vertical %", attr="scaleV", Value=100), dict(Name="Interpolate Horizontal %", attr="interpH", Value=100), dict(Name="Interpolate Vertical %", attr="interpV", Value=100), dict(Name="Units of tracking", attr="tracking", Value=0) ] self.g.lcInfo = vanilla.List((10, step, -10, 100), lcInfo, columnDescriptions=columnDescriptions, showColumnTitles=False, editCallback=self.dataChanged) step += 110 self.g.resultStemTextLC = vanilla.TextBox((20, step, -10, 20), "") step += 30 self.g.otherTitle = vanilla.TextBox((10, step, -10, 25), colorText("Other glyphs", style="bold")) step += 25 self.g.otherRadio = vanilla.RadioGroup((10, step, -10, 70), [ "Copy from the lightest master", "Process at 50% of UC and LC settings", "Skip any other glyphs" ], callback=self.dataChanged) self.g.otherRadio.set(2) step += 80 self.g.loadButton = vanilla.SquareButton((100, step, -10, 25), "Load settings from UFO", callback=self.loadSettings) step += 35 self.g.hr2 = vanilla.HorizontalLine((10, step, -10, 1)) step += 15 self.g.skewBox = vanilla.CheckBox( (10, step, -10, 25), "Skew Italic glyphs upright before scaling") self.g.skewBox.set(True) step += 25 self.g.infoBox = vanilla.CheckBox( (10, step, -10, 25), "Interpolate Font Info whenever possible") self.g.infoBox.set(True) step += 25 self.g.scaleComponentBox = vanilla.CheckBox( (10, step, -10, 25), "Don’t scale component positions") self.g.scaleComponentBox.set(True) step += 25 self.g.doKernBox = vanilla.CheckBox((10, step, -10, 25), "Process Kerning") self.g.doKernBox.set(True) step += 3 self.g.testKernButton = vanilla.SquareButton( (135, step, -10, 25), "Compatibility Test", callback=self.kernCompatibilityTestCallback) #step += 40 self.w.buildButton = vanilla.SquareButton( (10, -35, -10, 25), "Make Font", callback=self.makeFontCallback) # Add the group to a ScrollView view = self.g.getNSView() self.w.sv = vanilla.ScrollView( (0, 0, -0, -45), view, hasHorizontalScroller=False, hasVerticalScroller=True, autohidesScrollers=False, drawsBackground=False ) #backgroundColor=NSColor.windowBackgroundColor()) # Update the font info before opening self.fontsChanged() self.dataChanged() addObserver(self, "fontsChanged", "fontDidOpen") addObserver(self, "fontsChanged", "newFontDidOpen") addObserver(self, "fontsChanged", "fontDidClose") self.w.bind("close", self.windowClosed) self.w.open()
def __init__(self): edX = 40 txX = 70 sliderY = 18 spX = 10 windowWidth = 350 windowHeight = 260 windowWidthResize = 3000 # user can resize width by this value windowHeightResize = 3000 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Instance Slider", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.Tosche.InstanceSlider.mainwindow" # stores last window position and size ) # UI elements: YOffset = 27 self.w.add = vanilla.Button((6, -YOffset, 24, 20), "+", callback=self.addDelButtons) self.w.delete = vanilla.Button((34, -YOffset, 24, 20), u"–", callback=self.addDelButtons) self.w.revert = vanilla.Button((62, -YOffset, 60, 20), "Revert", callback=self.revert) LineHeight = 26 YOffset += LineHeight if slider1Min != slider1Max: self.w.textY = vanilla.TextBox((spX, -YOffset, txX, 14), "WeightY", sizeStyle='small') self.w.checkY = vanilla.CheckBox( (txX - spX, -YOffset - 3, -10, 18), "", sizeStyle='small', callback=self.checkboxY, value=False) self.w.sliderY = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=slider1Min, maxValue=slider1Max, tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.editY = vanilla.EditText( (-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight if slider3Min != slider3Max: self.w.text3 = vanilla.TextBox((spX, -YOffset, txX, 14), "Custom", sizeStyle='small') self.w.slider3 = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=slider3Min, maxValue=slider3Max, tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit3 = vanilla.EditText( (-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight if slider2Min != slider2Max: self.w.text2 = vanilla.TextBox((spX, -YOffset, txX, 14), "Width", sizeStyle='small') self.w.slider2 = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=slider2Min, maxValue=slider2Max, tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit2 = vanilla.EditText( (-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight if slider1Min != slider1Max: self.w.text1 = vanilla.TextBox((spX, -YOffset, txX, 14), "Weight", sizeStyle='small') self.w.slider1 = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=slider1Min, maxValue=slider1Max, tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit1 = vanilla.EditText( (-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight self.w.list = vanilla.List((0, 0, -0, -(YOffset - 18)), insList, selectionCallback=self.listClick, allowsMultipleSelection=False, allowsEmptySelection=False, columnDescriptions=[{ "title": "Instance", "width": self.w.getPosSize()[2] - 215 }, { "title": "Weight", "width": 50 }, { "title": "Width", "width": 50 }, { "title": "Custom", "width": 50 }, { "title": "WeightY", "width": 50 }]) self.w.list._nsObject.setBorderType_(NSNoBorder) tableView = self.w.list._tableView tableView.setAllowsColumnReordering_(False) tableView.unbind_( "sortDescriptors") # Disables sorting by clicking the title bar tableView.tableColumns()[0].setResizingMask_(1) tableView.tableColumns()[1].setResizingMask_(0) tableView.tableColumns()[2].setResizingMask_(0) tableView.tableColumns()[3].setResizingMask_(0) # setResizingMask_() 0=Fixed, 1=Auto-Resizable (Not user-resizable). There may be more options? tableView.setColumnAutoresizingStyle_(5) # AutoresizingStyle: # 0 Disable table column autoresizing. # 1 Autoresize all columns by distributing space equally, simultaneously. # 2 Autoresize each table column sequentially, from the last auto-resizable column to the first auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size. # 3 Autoresize each table column sequentially, from the first auto-resizable column to the last auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size. # 4 Autoresize only the last table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead. # 5 Autoresize only the first table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead. self.w.line = vanilla.HorizontalLine((0, -(YOffset - 18), -0, 1)) # Open window and focus on it: self.w.open() self.w.makeKey() # initialisation: # set the first instance in preview if there is an instance # set the slider and text # set preview area if closed # redraw uiList = self.w.list if len(font.instances) > 0: if not font.tabs: font.newTab("HALOGEN halogen 0123") if font.currentTab.previewHeight <= 1.0: font.currentTab.previewHeight = 150 self.setupSliders(font.instances[0], uiList[0])
def __init__(self): # Window 'self.w': windowWidth = 430 windowHeight = 230 windowWidthResize = 100 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Build Symbols", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.BuildSymbols.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 22 self.w.descriptionText = vanilla.TextBox( (inset, linePos + 2, -inset, 14), u"Create the following symbols automatically. See tooltips for requirements.", sizeStyle='small', selectable=True) linePos += lineHeight self.w.buildEstimated = vanilla.CheckBox((inset, linePos, -inset, 20), u"estimated", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.buildEstimated.getNSButton().setToolTip_( u"Will build estimated ℮ and scale it to the size of your lining zero, if available." ) self.w.buildBars = vanilla.CheckBox((inset + 120, linePos, -inset, 20), u"bars, brokenbar", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.buildBars.getNSButton().setToolTip_( u"Will build bar | and brokenbar ¦ and use the master’s stem values for their size." ) self.w.buildEmptyset = vanilla.CheckBox( (inset + 240, linePos, -inset, 20), u"emptyset", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.buildEmptyset.getNSButton().setToolTip_( u"Will build emptyset. Not yet implemented, sorry.") linePos += lineHeight self.w.buildCurrency = vanilla.CheckBox((inset, linePos, -inset, 20), u"currency", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.buildCurrency.getNSButton().setToolTip_( u"Will build currency. Not yet implemented, sorry.") self.w.buildLozenge = vanilla.CheckBox( (inset + 120, linePos, -inset, 20), u"lozenge", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.buildLozenge.getNSButton().setToolTip_( u"Will build lozenge. Not yet implemented, sorry.") self.w.buildProduct = vanilla.CheckBox( (inset + 240, linePos, -inset, 20), u"product", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.buildProduct.getNSButton().setToolTip_( u"Will build product. Not yet implemented, sorry.") linePos += lineHeight self.w.buildSummation = vanilla.CheckBox((inset, linePos, -inset, 20), u"summation", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.buildSummation.getNSButton().setToolTip_( u"Will build summation. Not yet implemented, sorry.") self.w.buildRadical = vanilla.CheckBox( (inset + 120, linePos, -inset, 20), u"radical", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.buildRadical.getNSButton().setToolTip_( u"Will build radical. Not yet implemented, sorry.") self.w.buildNotdef = vanilla.CheckBox( (inset + 240, linePos, -inset, 20), u".notdef", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.buildNotdef.getNSButton().setToolTip_( u"Will build the mandatory .notdef glyph based on the boldest available question mark." ) linePos += lineHeight # ----------- SEPARATOR LINE ----------- self.w.line = vanilla.HorizontalLine( (inset, int(linePos + 0.5 * lineHeight - 1), -inset, 1)) linePos += lineHeight # Other options: self.w.override = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Overwrite existing symbol glyphs (creates backup layers)", value=False, callback=self.SavePreferences, sizeStyle='small') self.w.override.getNSButton().setToolTip_( u"If checked, will create fresh symbols even if they already exist. Current outlines will be copied to a backup layer (if they are different). If unchecked, will skip glyphs that already exist." ) linePos += lineHeight self.w.newTab = vanilla.CheckBox((inset, linePos - 1, 180, 20), u"Open tab with new glyphs", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.newTab.getNSButton().setToolTip_( u"If checked, will open a new tab with the newly created symbols.") self.w.reuseTab = vanilla.CheckBox( (inset + 180, linePos - 1, -inset, 20), u"Reuse current tab", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.reuseTab.getNSButton().setToolTip_( u"If checked, will reuse the current tab, and open a new tab only if there is no Edit tab open already. Highly recommended." ) linePos += lineHeight # Run Button: self.w.uncheckAllButton = vanilla.Button( (-315 - inset, -20 - inset, -200 - inset, -inset), "Uncheck All", sizeStyle='regular', callback=self.checkAll) self.w.checkAllButton = vanilla.Button( (-190 - inset, -20 - inset, -90 - inset, -inset), "Check All", sizeStyle='regular', callback=self.checkAll) self.w.runButton = vanilla.Button( (-80 - inset, -20 - inset, -inset, -inset), "Build", sizeStyle='regular', callback=self.BuildSymbolsMain) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Build Symbols' could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): edX = 40 txX = 70 sliderY = 18 spX = 10 axisX = 60 windowWidth = 350 windowHeight = 260 windowWidthResize = 3000 # user can resize width by this value windowHeightResize = 3000 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Instance Slider", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.Tosche.InstanceSlider.mainwindow" # stores last window position and size ) YOffset = 27 self.w.add = vanilla.Button((6, -YOffset, 24, 20), "+", callback=self.addDelButtons) self.w.delete = vanilla.Button((34, -YOffset, 24, 20), "–", callback=self.addDelButtons) self.w.revert = vanilla.Button((62, -YOffset, 60, 20), "Revert", callback=self.revert) global av LineHeight = 26 YOffset += LineHeight axisCount = len([v for v in av if v[0] != ""]) self.w.textY = vanilla.TextBox((spX, -YOffset, txX, 14), "WeightY", sizeStyle='small') self.w.checkY = vanilla.CheckBox((txX - spX, -YOffset - 3, -10, 18), "", sizeStyle='small', callback=self.checkboxY, value=False) self.w.sliderY = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=av[0][1], maxValue=av[0][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.editY = vanilla.EditText((-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight move = -LineHeight * 2 move -= LineHeight if axisCount == 6 else 0 self.w.text5 = vanilla.TextBox((spX, move, txX, 14), av[5][0], sizeStyle='small') self.w.slider5 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[5][1], maxValue=av[5][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit5 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 5 else 0 self.w.text4 = vanilla.TextBox((spX, move, txX, 14), av[4][0], sizeStyle='small') self.w.slider4 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[4][1], maxValue=av[4][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit4 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 4 else 0 self.w.text3 = vanilla.TextBox((spX, move, txX, 14), av[3][0], sizeStyle='small') self.w.slider3 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[3][1], maxValue=av[3][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit3 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 3 else 0 self.w.text2 = vanilla.TextBox((spX, move, txX, 14), av[2][0], sizeStyle='small') self.w.slider2 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[2][1], maxValue=av[2][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit2 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 2 else 0 self.w.text1 = vanilla.TextBox((spX, move, txX, 14), av[1][0], sizeStyle='small') self.w.slider1 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[1][1], maxValue=av[1][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit1 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 1 else 0 self.w.text0 = vanilla.TextBox((spX, move, txX, 14), av[0][0], sizeStyle='small') self.w.slider0 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[0][1], maxValue=av[0][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit0 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight * axisCount av = [v for v in av if v[0] != ""] axisElements = [ [self.w.text0, self.w.slider0, self.w.edit0], [self.w.text1, self.w.slider1, self.w.edit1], [self.w.text2, self.w.slider2, self.w.edit2], [self.w.text3, self.w.slider3, self.w.edit3], [self.w.text4, self.w.slider4, self.w.edit4], [self.w.text5, self.w.slider5, self.w.edit5], ] for els in axisElements[len(av):]: els[0].show(False) els[1].show(False) els[2].show(False) self.usedAxisElements = axisElements[:len(av)] # TODO: disable WeightY if Weight doesn't exist if "Weight" not in [a[0] for a in av]: self.w.checkY.enable(False) columnTitles = [{ "title": "Instance", "width": self.w.getPosSize()[2] - axisX * (len(av) + 1) }] for i in range(len(av)): columnTitles += [{"title": av[i][0], "width": axisX}] self.w.list = vanilla.List((0, 0, -0, -(YOffset - 18)), insList, selectionCallback=self.listClick, allowsMultipleSelection=False, allowsEmptySelection=False, columnDescriptions=columnTitles) self.w.list._nsObject.setBorderType_(NSNoBorder) tableView = self.w.list._tableView tableView.setAllowsColumnReordering_(False) tableView.unbind_( "sortDescriptors") # Disables sorting by clicking the title bar for i in range(len(av)): if i == 0: tableView.tableColumns()[i].setResizingMask_(1) else: tableView.tableColumns()[i].setResizingMask_(0) # setResizingMask_() 0=Fixed, 1=Auto-Resizable (Not user-resizable). There may be more options? tableView.setColumnAutoresizingStyle_(5) # AutoresizingStyle: # 0 Disable table column autoresizing. # 1 Autoresize all columns by distributing space equally, simultaneously. # 2 Autoresize each table column sequentially, from the last auto-resizable column to the first auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size. # 3 Autoresize each table column sequentially, from the first auto-resizable column to the last auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size. # 4 Autoresize only the last table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead. # 5 Autoresize only the first table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead. self.w.line = vanilla.HorizontalLine((0, -(YOffset - 18), -0, 1)) self.w.open() self.w.makeKey() # initialisation: # set the first instance in preview if there is an instance # set the slider and text # set preview area if closed # redraw uiList = self.w.list if len(f.instances) > 0: if f.currentTab == None: f.newTab("HALOGEN halogen 0123") if f.currentTab.previewHeight <= 20.0: f.currentTab.previewHeight = 150 self.setupSliders(0, uiList[0])
def __init__(self): # Window 'self.w': edY = 22 sp = 10 btnX = 80 btnY = 22 windowWidth = 300 windowHeight = 340 windowWidthResize = 100 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Export InDesign Tagged Text", # window title autosaveName= "com.Tosche.ExportInDesignTaggedText.mainwindow" # stores last window position and size ) f = Glyphs.font try: os.path.dirname(f.filepath) location = "the same folder as the Glyphs source file" except: location = "Documents folder" instruction = u'''Instruction: 1. Export button will save the text file(s) in %s (overwites existing ones). 2. You also need to generate the font and make it available in InDesign. 3. In InDesign, have a document open. Go to "File > Place", choose the exported text file, and place it somewhere in the document. Et voilà!''' % location instancePopupItems = [] for ins in f.instances: familyName = ins.customParameters[ "familyName"] if ins.customParameters[ "familyName"] else f.familyName instancePopupItems.append("%s %s" % (familyName, ins.name)) instancePopupItems += ["All instances"] # UI elements: self.w.instancesText = vanilla.TextBox((sp, sp + 5, 75, edY), "Export for", sizeStyle='small') self.w.instancesList = vanilla.PopUpButton((sp * 2 + 55, sp, -sp, edY), instancePopupItems, sizeStyle='small') self.w.tabCheck = vanilla.CheckBox((sp, sp * 2 + edY * 1, -sp, edY), "Tab-separated", sizeStyle='small', callback=self.checkBoxes) self.w.unicodeCheck = vanilla.CheckBox( (sp, sp * 2 + edY * 2, -sp, edY), "Unicode characters first, un-encoded later", sizeStyle='small', callback=self.checkBoxes) self.w.breakCheck = vanilla.CheckBox( (sp, sp * 2 + edY * 3, -sp, edY), "Break up the unicode part by category", sizeStyle='small') self.w.runButton = vanilla.Button( (sp, sp * 3 + edY * 4, -sp, btnY), "Export", sizeStyle='regular', callback=self.ExportInDesignTaggedTextMain) self.w.setDefaultButton(self.w.runButton) self.w.border = vanilla.HorizontalLine((0, sp * 4 + edY * 5, -0, 1)) self.w.instructionText = vanilla.TextBox( (sp, sp * 5 + edY * 5, -sp, 200), instruction, sizeStyle='small') # Load Settings: if not self.LoadPreferences(): print "Note: 'Export InDesign Tagged Text.py' could not load preferences. Will resort to defaults" self.checkBoxes(self.w.unicodeCheck) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): self.screenInfo = getScreenInfo() self.screenNames = [] for screen in self.screenInfo: for location in ["↖︎", "↗︎"]: self.screenNames += ["%s %s" % (location, screen["name"])] self.dsPath = None self.ds = None self.sourceFonts = {} step = 10 self.w = vanilla.Window((660, 600), "Rotated DesignSpace Preview", minSize=(320, 500), autosaveName="Rotated DesignSpace Preview") self.w.openButton = vanilla.SquareButton((10, step, 150, 25), "Open Designspace", sizeStyle="small", callback=self.openDesignSpace) self.w.reloadButton = vanilla.SquareButton( (10, step + 35, 150, 25), "Update/Reload Fonts", sizeStyle="small", callback=self.reloadDesignSpace) #self.w.saveButton = vanilla.SquareButton((10, step+70, 40, 25), "Save", sizeStyle="small", callback=self.saveSources) self.w.screenChoice = vanilla.PopUpButton( (10, step + 65, 150, 25), self.screenNames, sizeStyle="small", callback=self.positionSourceWindows) self.w.vr1 = vanilla.VerticalLine((170, 10, 1, 100)) self.w.glyphNameTitle = vanilla.TextBox((190, step + 5, 100, 25), "Glyph name:") self.w.glyphName = vanilla.EditText((190, step + 35, 100, 25), "", callback=self.glyphChanged) self.w.fillBox = vanilla.CheckBox((190, step + 65, 100, 25), "Fill Preview", callback=self.settingsChanged) self.w.vr2 = vanilla.VerticalLine((310, 10, 1, 100)) mid = 330 self.w.selectedPointTitle = vanilla.TextBox((mid, step + 5, 100, 25), "Selected BCP:") self.w.setRatioButton = vanilla.SquareButton( (mid, step + 35, 175, 25), "Match “default” master ratio...", sizeStyle="small", callback=self.setPointRatio) self.w.setRatioButton.id = "ratio" self.w.setRatioButton2 = vanilla.SquareButton( (mid + 174, step + 35, 135, 25), "...move off-curves only", sizeStyle="small", callback=self.setPointRatio) self.w.setRatioButton2.id = "ratioLeaveAnchor" mid = 439 self.w.magTitle = vanilla.TextBox((mid - 100, step + 70, 100, 25), "Scale off-curves:", sizeStyle="small") self.w.magButton0 = vanilla.SquareButton( (mid, step + 64, 51, 25), "-20", sizeStyle="small", callback=self.pointMagCallback) self.w.magButton0.value = 0.8 self.w.magButton1 = vanilla.SquareButton( (mid + 50, step + 64, 51, 25), "-5", sizeStyle="small", callback=self.pointMagCallback) self.w.magButton1.value = 0.95 self.w.magButton2 = vanilla.SquareButton( (mid + 100, step + 64, 51, 25), "+5", sizeStyle="small", callback=self.pointMagCallback) self.w.magButton2.value = 1.05 self.w.magButton3 = vanilla.SquareButton( (mid + 150, step + 64, 50, 25), "+20", sizeStyle="small", callback=self.pointMagCallback) self.w.magButton3.value = 1.2 #self.w.closeButton = vanilla.SquareButton((550, step+35, 40, 25), "Close", sizeStyle="small", callback=self.closeSourceWindows) self.w.hr1 = vanilla.HorizontalLine((10, 110, -10, 1)) step += 110 # Sliders for tag in ["HROT", "VROT"]: posSize = (10, step + 5, 50, 25) control = vanilla.TextBox(posSize, tag, sizeStyle="small") setattr(self.w, "label_%s" % tag, control) posSize = (50, step, 60, 25) control = vanilla.EditText(posSize, 0, callback=self.valueChangedCallback) control.id = tag setattr(self.w, "value_%s" % tag, control) posSize = (120, step, -10, 25) control = vanilla.Slider(posSize, callback=self.sliderChangedCallback, tickMarkCount=1) control.id = tag # axis min, max, default control.setMinValue(-45) control.setMaxValue(45) control.set(0) setattr(self.w, "slider_%s" % tag, control) step += 30 self.w.glyphPreview = GlyphView((10, step, -10, -10)) #self.w.bind("close", self.windowClosed) self.settingsChanged() self.w.open()
def __init__(self): # Window 'self.w': windowWidth = 350 windowHeight = 300 windowWidthResize = 1000 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Font Info Batch Setter", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.FontInfoBatchSetter.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 22 column = 100 self.w.descriptionText = vanilla.TextBox( (inset, linePos + 2, -inset, 14), u"Batch-set Font Info > Font of open fonts with these values:", sizeStyle='small', selectable=True) linePos += lineHeight # DESIGNER self.w.setDesigner = vanilla.CheckBox((inset, linePos - 1, column, 20), u"Designer:", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.designer = vanilla.EditText( (inset + column, linePos, -inset, 19), "", callback=self.SavePreferences, sizeStyle='small') linePos += lineHeight self.w.setDesignerURL = vanilla.CheckBox( (inset, linePos - 1, column, 20), u"Designer URL:", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.designerURL = vanilla.EditText( (inset + column, linePos, -inset, 19), "https://", callback=self.SavePreferences, sizeStyle='small') linePos += lineHeight # MANUFACTURER self.w.setManufacturer = vanilla.CheckBox( (inset, linePos - 1, column, 20), u"Manufacturer:", value=False, callback=self.SavePreferences, sizeStyle='small') self.w.manufacturer = vanilla.EditText( (inset + column, linePos, -inset, 19), "", callback=self.SavePreferences, sizeStyle='small') linePos += lineHeight self.w.setManufacturerURL = vanilla.CheckBox( (inset, linePos - 1, column, 20), u"Manufact.URL:", value=False, callback=self.SavePreferences, sizeStyle='small') self.w.manufacturerURL = vanilla.EditText( (inset + column, linePos, -inset, 19), "https://", callback=self.SavePreferences, sizeStyle='small') linePos += lineHeight # COPYRIGHT self.w.setCopyright = vanilla.CheckBox( (inset, linePos - 1, column, 20), u"Copyright:", value=False, callback=self.SavePreferences, sizeStyle='small') self.w.copyright = vanilla.EditText( (inset + column, linePos, -inset, 19), "", callback=self.SavePreferences, sizeStyle='small') linePos += lineHeight # VERSION NUMBER self.w.setVersion = vanilla.CheckBox((inset, linePos - 1, column, 20), u"Version:", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.versionMajor = vanilla.EditText( (inset + column, linePos, 50, 19), "1", callback=self.SavePreferences, sizeStyle='small') self.w.versionDot = vanilla.TextBox((inset + 151, linePos + 2, 8, 18), u".", sizeStyle='regular', selectable=True) self.w.versionMinor = vanilla.EditText( (inset + 160, linePos, -inset - 113, 19), "005", callback=self.SavePreferences, sizeStyle='small') self.w.versionMinorDecrease = vanilla.SquareButton( (-inset - 110, linePos, -inset - 90, 19), u"−", sizeStyle='small', callback=self.changeMinVersion) self.w.versionMinorDecrease.getNSButton().setToolTip_( "Decrease the version number by 0.001.") self.w.versionMinorIncrease = vanilla.SquareButton( (-inset - 91, linePos, -inset - 71, 19), u"+", sizeStyle='small', callback=self.changeMinVersion) self.w.versionMinorIncrease.getNSButton().setToolTip_( "Increase the version number by 0.001.") self.w.minVersionButton = vanilla.SquareButton( (-inset - 60, linePos, -inset, 18), u"⟳ 1.005", sizeStyle='small', callback=self.setVersion1005) self.w.minVersionButton.getNSButton().setToolTip_( u"Resets the version to 1.005. Some (old?) Microsoft apps may consider fonts with smaller versions as unfinished and not display them in their font menu." ) linePos += lineHeight # DATE AND TIME self.w.setDate = vanilla.CheckBox((inset, linePos - 1, column, 20), u"Date and time:", value=True, callback=self.SavePreferences, sizeStyle='small') self.w.datePicker = vanilla.DatePicker( (inset + column, linePos - 3, -inset - 70, 22), date=NSDate.alloc().init(), minDate=None, maxDate=None, showStepper=True, mode='text', timeDisplay='hourMinuteSecond', dateDisplay='yearMonthDay', callback=None, sizeStyle='small') self.w.noonButton = vanilla.SquareButton( (-inset - 60, linePos, -inset, 18), u"🕛 Today", sizeStyle='small', callback=self.setNoon) self.w.noonButton.getNSButton().setToolTip_( u"Resets the date to today 12:00 noon.") linePos += lineHeight # SEPARATOR self.w.separator = vanilla.HorizontalLine( (inset, linePos + int(lineHeight * 0.5) - 1, -inset, 1)) linePos += lineHeight # APPLY TO FONTS self.w.finger = vanilla.TextBox((inset - 5, linePos, 22, 22), u"👉 ", sizeStyle='regular', selectable=True) self.w.applyText = vanilla.TextBox((inset + 17, linePos + 2, 70, 14), u"Apply to", sizeStyle='small', selectable=True) self.w.applyPopup = vanilla.PopUpButton( (inset + 70, linePos, 150, 17), (u"ALL open fonts", u"open fonts containing"), sizeStyle='small', callback=self.SavePreferences) self.w.applyContaining = vanilla.EditText( (inset + 70 + 150 + 10, linePos, -inset, 19), "", callback=self.SavePreferences, sizeStyle='small', placeholder="enter part of family name here") self.w.applyContaining.getNSTextField().setToolTip_( u"Only applies the settings to fonts that contain this in Font Info > Font > Family Name." ) linePos += lineHeight # Buttons: self.w.extractButton = vanilla.Button( (-270 - inset, -20 - inset, -130 - inset, -inset), "Extract from Font", sizeStyle='regular', callback=self.ExtractFontInfoFromFrontmostFont) self.w.extractButton.getNSButton().setToolTip_( u"Extracts the settings from the frontmost font and fills the UI with it." ) self.w.runButton = vanilla.Button( (-120 - inset, -20 - inset, -inset, -inset), "Apply to Fonts", sizeStyle='regular', callback=self.FontInfoBatchSetterMain) self.w.runButton.getNSButton().setToolTip_( u"Applies the checked settings above to all fonts indicated in the ‘Apply to’ option." ) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Font Info Batch Setter' could not load preferences. Will resort to defaults" ) self.setNoon() self.updateUI() # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): if Font is None: Message("No font selected", "Select a font project!") return self.font = Font self.font.instances.append(GSInstance()) self.font.instances[-1].name = "Interpolator Preview" self.w = vanilla.FloatingWindow((0, 0), "Interpolation Preview") self.axesRanges = [ ] # create a list to contain tuples with the min and max of an axis self.currentCoords = [] self.sliderList = [] # create a list of the slider objects self.popUpButtonList = [] self.inputFieldList = [] self.instanceName = "Regular" self.selectedClasses = ["Medium (normal)", "Regular"] self.selectedParent = 0 self.namePlaceholder = "Regular" self.styleClasses = { "Weight": { 1: "Hairline", 2: "Thin", 3: "Extralight", 4: "Light", 5: "Regular", 6: "Medium", 7: "Semibold", 8: "Bold", 9: "Extrabold", 10: "Black", 11: "Extrablack" }, "Width": { 1: "Ultra Condensed", 2: "Extra Condensed", 3: "Condensed", 4: "SemiCondensed", 5: "Medium (normal)", 6: "Semi Expanded", 7: "Expanded", 8: "Extra Expanded", 9: "Ultra Expanded" } } for coord in self.font.selectedFontMaster.axes: self.currentCoords.append(int(coord)) for i, axis in enumerate( self.font.axes ): # for each axis in the font, create a new slider self.axesRanges.append( set() ) # for each axis in the font, create an empty tuple to store the axis range for master in self.font.masters: # first, build a list of the axis ranges self.axesRanges[i].add(master.axes[i]) self.axesRanges = [sorted(list(a)) for a in self.axesRanges] for axisRange in self.axesRanges: del axisRange[1:-1] # delete intermediate master coordinates if len(self.axesRanges[i]) == 1: Message( "Please add more than one axis coordinate in your masters.", "Invalid axis coordinates for " + axis.name + " axis") return if str(Glyphs.versionNumber)[0] == "3": axis_tag = axis.axisTag axis_name = axis.name else: axis_tag = axis["Tag"] axis_name = axis["Name"] setattr( self.w, axis_tag + "title", vanilla.TextBox((10, 20 + i * 30, -10, 14), axis_name, sizeStyle="small")) s = vanilla.Slider((60, 20 + i * 30, -70, 15), minValue=sorted(self.axesRanges[i])[0], maxValue=sorted(self.axesRanges[i])[1], value=self.currentCoords[i], callback=self.axis_slider) setattr(self.w, axis_tag + "slider", s) self.sliderList.append(s) t = vanilla.EditText((-60, 20 + i * 30 - 1, -10, 22), callback=self.axis_input, text=self.currentCoords[i]) self.inputFieldList.append(t) setattr(self.w, axis_tag + "input", t) self.ypos = s.getPosSize()[1] + 36 if self.font.instances: self.w.selectInstanceTitle = vanilla.TextBox( (10, self.ypos, -10, 14), "Copy from instance:", sizeStyle="small") setattr( self.w, "instanceSelect", vanilla.PopUpButton((130, self.ypos, -10, 17), [i.name for i in self.font.instances], callback=self.instance_selector)) self.ypos += 32 setattr(self.w, "separator", vanilla.HorizontalLine((10, self.ypos, -10, 1))) self.ypos += 16 setattr( self.w, "addMenu", vanilla.Button((155, self.ypos, -10, 20), "Instance...", callback=self.add_instance_menu)) setattr( self.w, "addIntermediate", vanilla.Button((10, self.ypos, -155, 20), "Intermediate...", callback=self.intermediate_menu)) self.w.resize(300, self.w.addMenu.getPosSize()[1] + 30) self.w.open() self.w.makeKey() self.w.bind("close", self.remove_preview)
def __init__(self): self.glyph = CurrentGlyph() self.w = vanilla.Window((300, 0), minSize=(100, 100)) metrics = dict( border=15, padding1=10, padding2=5, titleWidth=45, inputSpace=70, # border + title + padding killButtonWidth=20, fieldHeight=22, ) rules = [ # Left "H:|-border-[leftTitle(==titleWidth)]-padding1-[leftField]-border-|", "H:|-inputSpace-[leftButton]-padding2-[leftKillButton(==killButtonWidth)]-border-|", "V:|-border-[leftTitle(==fieldHeight)]", "V:|-border-[leftField(==fieldHeight)]", "V:[leftField]-padding2-[leftButton]", "V:[leftField]-padding2-[leftKillButton(==leftButton)]", # Right "H:|-border-[rightTitle(==titleWidth)]-padding1-[rightField]-border-|", "H:|-inputSpace-[rightButton]-padding2-[rightKillButton(==killButtonWidth)]-border-|", "V:[leftButton]-padding1-[rightTitle(==fieldHeight)]", "V:[leftButton]-padding1-[rightField(==fieldHeight)]", "V:[rightField]-padding2-[rightButton]", "V:[rightField]-padding2-[rightKillButton(==rightButton)]", # Width "H:|-border-[widthTitle(==titleWidth)]-padding1-[widthField]-border-|", "H:|-inputSpace-[widthButton]-padding2-[widthKillButton(==killButtonWidth)]-border-|", "V:[rightButton]-padding1-[widthTitle(==fieldHeight)]", "V:[rightButton]-padding1-[widthField(==fieldHeight)]", "V:[widthField]-padding2-[widthButton]", "V:[widthField]-padding2-[widthKillButton(==rightButton)]", # Bottom "H:|-inputSpace-[line]-border-|", "H:|-inputSpace-[doneButton]-border-|", "V:[widthButton]-padding1-[line]-padding1-[doneButton]-border-|", ] self.w.leftTitle = vanilla.TextBox("auto", "Left:", alignment="right") self.w.leftField = vanilla.EditText("auto", "", continuous=False, callback=self.fieldCallback) self.w.leftButton = vanilla.Button("auto", "", callback=self.buttonCallback) self.w.leftKillButton = vanilla.ImageButton( "auto", imageNamed=NSImageNameStopProgressFreestandingTemplate, bordered=False, callback=self.buttonCallback) self.w.rightTitle = vanilla.TextBox("auto", "Right:", alignment="right") self.w.rightField = vanilla.EditText("auto", "", continuous=False, callback=self.fieldCallback) self.w.rightButton = vanilla.Button("auto", "", callback=self.buttonCallback) self.w.rightKillButton = vanilla.ImageButton( "auto", imageNamed=NSImageNameStopProgressFreestandingTemplate, bordered=False, callback=self.buttonCallback) self.w.widthTitle = vanilla.TextBox("auto", "Width:", alignment="right") self.w.widthField = vanilla.EditText("auto", "", continuous=False, callback=self.fieldCallback) self.w.widthButton = vanilla.Button("auto", "", callback=self.buttonCallback) self.w.widthKillButton = vanilla.ImageButton( "auto", imageNamed=NSImageNameStopProgressFreestandingTemplate, bordered=False, callback=self.buttonCallback) self.controlGroups = [ dict(attr="leftMargin", field=self.w.leftField, button=self.w.leftButton), dict(attr="rightMargin", field=self.w.rightField, button=self.w.rightButton), dict(attr="width", field=self.w.widthField, button=self.w.widthButton), ] for group in self.controlGroups: field = group["field"] button = group["button"] button.getNSButton().setAlignment_(NSLeftTextAlignment) # if self.glyph.bounds is None: # self.setFirstResponder(self.w.widthField) # else: # self.setFirstResponder(self.w.leftField) # leftField = self.w.leftField.getNSTextField() # rightField = self.w.rightField.getNSTextField() # leftField.setNextKeyView_(rightField) # rightField.setNextKeyView_(leftField) self.w.line = vanilla.HorizontalLine("auto") self.w.doneButton = vanilla.Button("auto", "Close", callback=self.doneCallback) self.w.doneButton.bind(escapeCharacter, []) self.w.addAutoPosSizeRules(rules, metrics) self.w.open()
def __init__(self, posSize, callback): self._callback = callback # put the controls group into a flipped group. # this will give better scroll behavior. width = posSize[2] - NSScroller.scrollerWidth() - 2 view = DefconAppKitTopAnchoredNSView.alloc().init() view.setFrame_(((0, 0), (width, 0))) # call the super super(OpenTypeControlsView, self).__init__(posSize, view, hasHorizontalScroller=False, drawsBackground=False) # build the view for the controls self._controlGroup = vanilla.Group((0, 0, width, 0)) view.addSubview_(self._controlGroup.getNSView()) # build the static controls top = 10 # mode self._controlGroup.modeTitle = vanilla.TextBox( (10, top, -10, 14), NSAttributedString.alloc().initWithString_attributes_( "DISPLAY MODE", titleControlAttributes), sizeStyle="small") top += 20 self._controlGroup.modeRadioGroup = vanilla.RadioGroup( (10, top, -10, 38), ["Glyph Preview", "Glyph Records"], callback=self._controlEditCallback) self._controlGroup.modeRadioGroup.set(0) top += 48 self._controlGroup.line1 = vanilla.HorizontalLine((10, top, -10, 1)) top += 11 # case self._controlGroup.caseTitle = vanilla.TextBox( (10, top, -10, 14), NSAttributedString.alloc().initWithString_attributes_( "CASE CONVERSION", titleControlAttributes), sizeStyle="small") top += 20 self._controlGroup.caseRadioGroup = vanilla.RadioGroup( (10, top, -10, 58), ["Unchanged", "Uppercase", "Lowercase"], callback=self._controlEditCallback) self._controlGroup.caseRadioGroup.set(0) top += 68 # language, script and direction self._controlGroup.scriptTitle = vanilla.TextBox( (10, top, -10, 14), NSAttributedString.alloc().initWithString_attributes_( "SCRIPT & LANGUAGE", titleControlAttributes), sizeStyle="small") top += 20 self._controlGroup.scriptPopUpButton = vanilla.PopUpButton( (10, top, -10, 20), [], callback=self._controlEditCallback) top += 25 self._controlGroup.languagePopUpButton = vanilla.PopUpButton( (10, top, -10, 20), [], callback=self._controlEditCallback) top += 35 self._controlGroup.directionTitle = vanilla.TextBox( (10, top, -10, 14), NSAttributedString.alloc().initWithString_attributes_( "WRITING DIRECTION", titleControlAttributes), sizeStyle="small") top += 20 self._controlGroup.directionRadioGroup = vanilla.RadioGroup( (10, top, -10, 38), ["Left to Right", "Right to Left"], callback=self._controlEditCallback) self._controlGroup.directionRadioGroup.set(0) top += 48 # GSUB and GPOS self._controlGroup.line2 = vanilla.HorizontalLine((10, top, -10, 1)) top += 11 # set document view height (x, y), (w, h) = self._nsObject.documentView().frame() self._nsObject.documentView().setFrame_(((x, y), (w, top))) x, y, w, h = self._controlGroup.getPosSize() self._controlGroup.setPosSize((x, y, w, top)) # storage self._dynamicTop = top self._gsubAttributes = {} self._gposAttributes = {}
def __init__(self): self.listOfMasters = [] self.updateListOfMasters() # Window settings windowWidth = 470 windowHeight = 390 # Values used when the window is rezied by the user #windowWidthResize = 500 #windowHeightResize = 10 self.pageFormats = [ "A0", "A0Landscape", "A1", "A1Landscape", "A2", "A2Landscape", "A3", "A3Landscape", "A4", "A4Landscape", "A4Small", "A4SmallLandscape", "A5", "A5Landscape", "B4", "B4Landscape", "B5", "B5Landscape", "Executive", "ExecutiveLandscape", "Folio", "FolioLandscape", "Ledger", "LedgerLandscape", "Legal", "LegalLandscape", "Letter", "LetterLandscape", "LetterSmall", "LetterSmallLandscape", "Quarto", "QuartoLandscape", "Statement", "StatementLandscape", "Tabloid", "TabloidLandscape" ] # Building window self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Build Character Set", # window title #minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) #maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) ) # UI elements linePos, margin, lineHeight = 20, 15, 25 columnLine = margin + 145 # Description text self.w.descriptionText = vanilla.TextBox( (margin, linePos, -margin, 14), u"Select some glyphs and choose the instances you want to see in the character set.", sizeStyle='small', selectable=True) linePos += lineHeight * 1.5 # Text + list of masters self.w.text_anchor = vanilla.TextBox((margin, linePos + 2, 200, 17), "Set the character set in:", sizeStyle='small') self.w.master2Use = vanilla.List( (margin + 180, linePos, -margin, 268), self.listOfMasterNames(), selectionCallback=self.getMaster, allowsMultipleSelection=True, ) #print(self.w.master2Use.getSelection() self.w.master2Use.enable(onOff=True) linePos += lineHeight # All instances self.w.allMasters = vanilla.CheckBox( (margin * 2, linePos - 1, 200, 20), "All instances", value=False, sizeStyle='small', callback=self.buttonCheck) linePos += lineHeight * 1.8 self.w.line = vanilla.HorizontalLine( (margin, linePos - 10, columnLine, 1)) linePos += lineHeight * .05 # Number of columns self.w.colNumberLabel = vanilla.TextBox((margin, linePos + 3, 200, 17), "Number of columns:", sizeStyle='small') self.w.colNumberEdit = vanilla.EditText( (margin + 115, linePos, margin + 30, 20), "20", sizeStyle='small') linePos += lineHeight self.w.line2 = vanilla.HorizontalLine( (margin, linePos + 7, columnLine, 1)) linePos += lineHeight * 0.8 # Page format Pop-up self.w.pageFormatText = vanilla.TextBox((margin, linePos, 200, 17), "Page format:", sizeStyle='small') linePos += lineHeight self.w.pageFormat = vanilla.PopUpButton( (margin, linePos - 2, columnLine, 20), self.pageFormats, callback=self.popupFormat) # Default value to A4 self.w.pageFormat.set(8) linePos += lineHeight self.w.line3 = vanilla.HorizontalLine( (margin, linePos + 7, columnLine, 1)) linePos += lineHeight - 1 # Enable/Disable grid self.w.rectangle = vanilla.CheckBox((margin, linePos - 5, 200, 20), "Grid", value=False, sizeStyle='small') self.w.rectangle.getNSButton().setToolTip_( "Enable or disable rectangle around each glyph.") linePos += lineHeight self.w.line4 = vanilla.HorizontalLine( (margin, linePos + 3, columnLine, 1)) linePos += lineHeight # Enable/Disable text self.w.glyphText = vanilla.CheckBox((margin, linePos - 5, 200, 20), "Name & Unicode", value=False, sizeStyle='small') self.w.glyphText.getNSButton().setToolTip_( "If activated, prints each glyph's Name and Unicode value.") #print("Text",self.w.glyphText.get()) linePos += lineHeight # Generate button self.w.buildChar = vanilla.Button((margin + 180, windowHeight * .83, -margin, margin + lineHeight * 2), "Generate", sizeStyle='small', callback=self.buildCharacterSet) # Opening the window self.w.open() self.w.makeKey()
def __init__( self ): # Window 'self.w': windowWidth = 320 windowHeight = 470 windowWidthResize = 100 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "Path Problem Finder", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.PathProblemFinder.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 22 indent = 170 self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, 14), u"New tab with layers containing path problems:", sizeStyle='small', selectable=True ) linePos += lineHeight self.w.zeroHandles = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Zero handles", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.zeroHandles.getNSButton().setToolTip_(u"Zero handles (a.k.a. half-dead curves) can cause problems with screen rendering, hinting and interpolation. Indicated with purple disks in the Show Angled Handles plug-in.") linePos += lineHeight self.w.outwardHandles = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Outward-bent handles", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.outwardHandles.getNSButton().setToolTip_(u"Will find handles that point outside the stretch of their enclosing on-curves. Usually unwanted.") linePos += lineHeight self.w.largeHandles = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Overshooting handles (larger than 100%)", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.largeHandles.getNSButton().setToolTip_(u"Handles that are longer than 100%, i.e. going beyond the intersection with the opposing handle. Indicated with laser beams in the Show Angled Handles plug-in.") linePos += lineHeight self.w.shortHandles = vanilla.CheckBox( (inset, linePos, indent, 20), u"Handles shorter than:", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.shortHandlesThreshold = vanilla.EditText( (inset+indent, linePos, -inset-55, 19), "12", callback=self.SavePreferences, sizeStyle='small' ) self.w.shortHandlesText = vanilla.TextBox( (-inset-50, linePos+2, -inset, 14), u"units", sizeStyle='small', selectable=True ) tooltipText = u"Will find handles shorter than the specified amount in units. Short handles may cause kinks when rounded to the grid." self.w.shortHandlesThreshold.getNSTextField().setToolTip_(tooltipText) self.w.shortHandles.getNSButton().setToolTip_(tooltipText) linePos += lineHeight self.w.angledHandles = vanilla.CheckBox( (inset, linePos, indent, 20), u"Angled handles up to:", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.angledHandlesAngle = vanilla.EditText( (inset+indent, linePos, -inset-55, 19), "8", callback=self.SavePreferences, sizeStyle='small' ) self.w.angledHandlesText = vanilla.TextBox( (-inset-50, linePos+2, -inset, 14), u"degrees", sizeStyle='small', selectable=True ) linePos += lineHeight self.w.shallowCurveBBox = vanilla.CheckBox( (inset, linePos, indent, 20), u"Curve bbox smaller than:", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.shallowCurveBBoxThreshold = vanilla.EditText( (inset+indent, linePos, -inset-55, 19), "10", sizeStyle='small' ) self.w.shallowCurveBBoxText = vanilla.TextBox( (-inset-50, linePos+2, -inset, 14), u"units", sizeStyle='small', selectable=True ) tooltipText = u"Will find very flat curve segments. Flat curves leave little manœuvring space for handles (BCPs), or cause very short handles, which in turn causes grid rounding problems. Can usually be fixed by removing an extremum point or adding an overlap." self.w.shallowCurveBBoxThreshold.getNSTextField().setToolTip_(tooltipText) self.w.shallowCurveBBox.getNSButton().setToolTip_(tooltipText) linePos += lineHeight self.w.shallowCurve = vanilla.CheckBox( (inset, linePos, indent, 20), u"Curves shallower than:", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.shallowCurveThreshold = vanilla.EditText( (inset+indent, linePos, -inset-55, 19), "5", sizeStyle='small' ) self.w.shallowCurveText = vanilla.TextBox( (-inset-50, linePos+2, -inset, 14), u"units", sizeStyle='small', selectable=True ) tooltipText = u"Finds curve segments where the handles deviate less than the specified threshold from the enclosing on-curves." self.w.shallowCurveThreshold.getNSTextField().setToolTip_(tooltipText) self.w.shallowCurve.getNSButton().setToolTip_(tooltipText) linePos += lineHeight self.w.shortLine = vanilla.CheckBox( (inset, linePos, indent, 20), u"Line segments shorter than:", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.shortLineThreshold = vanilla.EditText( (inset+indent, linePos, -inset-55, 19), "8", sizeStyle='small' ) self.w.shortLineText = vanilla.TextBox( (-inset-50, linePos+2, -inset, 14), u"units", sizeStyle='small', selectable=True ) tooltipText = u"Finds line segments (two consecutive on-curve nodes) shorter than the specified threshold length. Very short line segments may be deleted because they are barely visible. Also, if not orthogonal, may pose grid rounding problems." self.w.shortLineThreshold.getNSTextField().setToolTip_(tooltipText) self.w.shortLine.getNSButton().setToolTip_(tooltipText) linePos += lineHeight self.w.almostOrthogonalLines = vanilla.CheckBox( (inset, linePos, indent, 20), u"Non-orthogonal lines:", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.almostOrthogonalLinesThreshold = vanilla.EditText( (inset+indent, linePos, -inset-75, 19), "3", callback=self.SavePreferences, sizeStyle='small' ) self.w.almostOrthogonalLinesText = vanilla.TextBox( (-inset-70, linePos+2, -inset, 14), u"units deep", sizeStyle='small', selectable=True ) tooltipText = u"Will find line segments that are close to, but not completely horizontal or vertical. Will look for segments where the x or y distance between the two nodes is less than the specified threshold. Often unintentional." self.w.almostOrthogonalLinesThreshold.getNSTextField().setToolTip_(tooltipText) self.w.almostOrthogonalLines.getNSButton().setToolTip_(tooltipText) linePos += lineHeight self.w.badOutlineOrder = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Bad outline order", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.badOutlineOrder.getNSButton().setToolTip_(u"If the first path is clockwise, paths are most likely in the wrong order.") linePos += lineHeight self.w.twoPointOutlines = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Paths with two on-curve nodes only", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.twoPointOutlines.getNSButton().setToolTip_(u"Paths with only two on-curve nodes are most likely leftover debris from a previous operation.") linePos += lineHeight self.w.offcurveAsStartPoint = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Off-curve point (handle) as startpoint", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.offcurveAsStartPoint.getNSButton().setToolTip_(u"Finds paths where the first point happens to be a BCP. Not really an issue, but you’ll like it if you are going full OCD on your font.") linePos += lineHeight self.w.openPaths = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Open paths (except _corner, _cap, etc.)", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.openPaths.getNSButton().setToolTip_(u"Finds unclosed paths. Special glyphs that are supposed to have open paths, like corner and cap components, are ignored.") linePos += lineHeight self.w.line = vanilla.HorizontalLine( (inset, linePos+3, -inset, 1)) linePos += int(lineHeight/2) # Script Options: self.w.includeAllGlyphs = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Check complete font (i.e., ignore glyph selection)", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.includeAllGlyphs.getNSButton().setToolTip_(u"If enabled, will ignore your current (glyph) selection, and simply go through the complete font. Recommended. May still ignore non-exporting glyph, see following option.") linePos += lineHeight self.w.includeNonExporting = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Include non-exporting glyphs", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.includeNonExporting.getNSButton().setToolTip_(u"If disabled, will ignore glyphs that are set to not export.") linePos += lineHeight self.w.reuseTab = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Reuse existing tab", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.reuseTab.getNSButton().setToolTip_(u"If enabled, will only open a new tab if none is open. Recommended.") linePos += lineHeight # Progress Bar and Status text: self.w.progress = vanilla.ProgressBar((inset, linePos, -inset, 16)) self.w.progress.set(0) # set progress indicator to zero self.w.status = vanilla.TextBox( (inset, -18-inset, -inset-100, 14), u"🤖 Ready.", sizeStyle='small', selectable=True ) linePos += lineHeight # Run Button: self.w.runButton = vanilla.Button( (-100-inset, -20-inset, -inset, -inset), "Open Tab", sizeStyle='regular', callback=self.PathProblemFinderMain ) self.w.setDefaultButton( self.w.runButton ) # Load Settings: if not self.LoadPreferences(): print("Note: 'Path Problem Finder' could not load preferences. Will resort to defaults") # Open window and focus on it: self.w.open() self.w.makeKey()