def __init__( self ):
		# Window 'self.w':
		windowWidth  = 350
		windowHeight = 130
		windowWidthResize  = 200 # 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
			"Remove Component from Selected Glyphs", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.RemoveComponentfromSelectedGlyphs.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		self.w.text1 = vanilla.TextBox( (15, 12+3, 130, 14), "Remove component", sizeStyle='small' )
		self.w.componentName  = vanilla.ComboBox((15+130, 12, -15, 19), self.glyphList(), sizeStyle='small' )
		self.w.fromWhere = vanilla.RadioGroup((15, 40, -15, 40), [ "from all selected glyphs", "from all glyphs in the font" ], callback=self.SavePreferences, sizeStyle = 'small' )
		self.w.fromWhere.set( 0 )
		
		# Run Button:
		self.w.runButton = vanilla.Button((-100-15, -20-15, -15, -15), "Remove", sizeStyle='regular', callback=self.RemoveComponentfromSelectedGlyphsMain )
		self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print("Note: 'Remove Component from Selected Glyphs' could not load preferences. Will resort to defaults")
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
Пример #2
0
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 300
		windowHeight = 170
		windowWidthResize  = 500 # 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
			"Position Clicker", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.PositionClicker.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		linePos, inset, lineHeight, indent = 12, 15, 22, 100

		self.w.descriptionText = vanilla.TextBox( (inset, linePos, -inset, 14), "Report positional combos that do not click:", sizeStyle='small', selectable=True )
		self.w.descriptionText.getNSTextField().setToolTip_("Clicking means that when two matching positional shapes follow each other (e.g. initial and final), they ‘click’, i.e., they share at least 2 point coordinates. Or whatever number is set in the minimal node count setting below.")
		linePos += lineHeight
		
		tooltip = "Reference glyph. Pick a medial glyph with paths for clicking. We recommend behDotless-ar.medi."
		self.w.referenceText = vanilla.TextBox( (inset, linePos+2, indent, 14), "Click with glyph", sizeStyle='small', selectable=True )
		self.w.referenceText.getNSTextField().setToolTip_(tooltip)
		
		self.w.referenceGlyphName = vanilla.ComboBox( (inset+indent, linePos-4, -inset-23, 25), self.getAllMediGlyphNames(), callback=self.SavePreferences, sizeStyle='regular' )
		self.w.referenceGlyphName.getNSComboBox().setFont_(NSFont.userFixedPitchFontOfSize_(11))
		self.w.referenceGlyphName.getNSComboBox().setToolTip_(tooltip)
		
		self.w.updateButton = vanilla.SquareButton( (-inset-20, linePos-1, -inset, 18), "↺", sizeStyle='small', callback=self.updateReferenceGlyphs )
		self.w.updateButton.getNSButton().setToolTip_("Update the list in the combo box with all .medi glyphs in the frontmost font.")
		linePos += lineHeight
		
		tooltip = "The amount of point coordinates that must be shared between two consecutive positional forms. E.g., if set to 2, an initial and a final shape must have two or more nodes exactly on top of each other when they follow each other."
		self.w.clickCountText = vanilla.TextBox( (inset, linePos+2, indent, 14), "Minimal node count", sizeStyle='small', selectable=True )
		self.w.clickCount = vanilla.EditText( (inset+indent, linePos-1, -inset, 19), "2", callback=self.SavePreferences, sizeStyle='small' )
		linePos += lineHeight
		
		self.w.includeNonExporting = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Include non-exporting glyphs", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.includeNonExporting.getNSButton().setToolTip_("Will also measure glyphs that are set to not export.")
		linePos += lineHeight
		
		self.w.reuseTab = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Reuse current tab", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.reuseTab.getNSButton().setToolTip_("Will use the current tab for output. Will open a new tab only if there is no Edit tab open already.")
		linePos += lineHeight
		
		# Run Button:
		self.w.runButton = vanilla.Button( (-100-inset, -20-inset, -inset, -inset), "Open Tab", sizeStyle='regular', callback=self.PositionClickerMain )
		self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print("Note: 'Position Clicker' could not load preferences. Will resort to defaults")
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 120
        windowWidthResize = 500  # 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
            "Set Hidden App Preferences",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.SetHiddenAppPreferences.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),
            "Choose and apply the app defaults:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.pref = vanilla.ComboBox((inset, linePos - 1, -inset - 100, 23),
                                       self.prefs,
                                       callback=self.SavePreferences,
                                       sizeStyle='regular')
        self.w.pref.getNSComboBox().setFont_(
            NSFont.userFixedPitchFontOfSize_(11))
        self.w.prefValue = vanilla.EditText((-inset - 90, linePos, -inset, 21),
                                            "",
                                            sizeStyle='regular')
        linePos += lineHeight

        # Run Button:
        self.w.delButton = vanilla.Button(
            (-170 - inset, -20 - inset, -90 - inset, -inset),
            "Delete",
            sizeStyle='regular',
            callback=self.SetHiddenAppPreferencesMain)
        self.w.runButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            "Apply",
            sizeStyle='regular',
            callback=self.SetHiddenAppPreferencesMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print "Note: 'Set Hidden App Preferences' could not load preferences. Will resort to defaults"

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
	def __init__( self):
		# Window 'self.w':
		windowWidth  = 400
		windowHeight = 80
		windowWidthResize  = 200 # 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
			"Replace Components in Selection", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.ReplaceComponents.mainwindow" # stores last window position and size
		)

		# UI elements:
		linePos, inset, lineHeight = 10, 15, 22
		
		self.w.textReplace = vanilla.TextBox((inset, linePos+2, inset+50, 14), "Replace", sizeStyle='small')
		self.w.componentName = vanilla.PopUpButton((inset+50, linePos, 100, 17), self.GetComponentNames(), sizeStyle='small')
		self.w.componentName.getNSPopUpButton().setToolTip_(u"The name of the component you want to replace. If it is not shown here, make a glyph selection and press the ↺ Update button. This will populate the menu with the names of all components in selected glyphs.")
		self.w.resetComponentName = vanilla.SquareButton((inset+50+100+5, linePos, 20, 18), u"↺", sizeStyle='small', callback=self.SetComponentNames )

		self.w.textBy = vanilla.TextBox((inset+50+100+35, linePos+2, 20, 14), "by", sizeStyle='small')
		# self.w.componentNewName = vanilla.EditText((65+100+35+25, linePos, -inset-95, 19), "", sizeStyle='small', callback=self.SavePreferences)
		self.w.componentNewName = vanilla.ComboBox( (65+100+35+25, linePos-1, -inset-95, 19), self.getAllGlyphNamesOfFrontmostFont(), sizeStyle='small', callback=self.SavePreferences )
		self.w.componentNewName.getNSComboBox().setToolTip_(u"The name of the component you want to insert instead of the component chosen in the menu.")
		self.w.resetComponentNewName = vanilla.SquareButton((-inset-90, linePos, -inset-70, 18), u"↺", sizeStyle='small', callback=self.ResetComponentNewName )
		self.w.replaceButton = vanilla.Button((-inset-60, linePos+1, -inset, 17), "Replace", sizeStyle='small', callback=self.FindAndReplaceMain )
		self.w.setDefaultButton( self.w.replaceButton )

		linePos += lineHeight
		
		self.w.includeAllLayers = vanilla.CheckBox((inset, linePos, 120, 18), "Include all layers", value=True, callback=self.SavePreferences, sizeStyle='small' )
		self.w.includeAllLayers.getNSButton().setToolTip_(u"If checked, will not only treat visible selected layers, but ALL (master, special and backup) layers of all selected glyphs.")
		self.w.includeBackgrounds = vanilla.CheckBox( (inset+120, linePos, -inset, 20), u"Include backgrounds", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.includeBackgrounds.getNSButton().setToolTip_(u"If checked, will also go through backgrounds of all treated layers.")
		linePos += lineHeight
		
		if not self.LoadPreferences( ):
			print("⚠️ Note: Could not load preferences. Will resort to defaults.")

		self.w.open()
    def __init__(self):
        self.w = vanilla.FloatingWindow(
            (360, 350),
            "Insert weight instances",
            minSize=(360, 350),
            maxSize=(360, 500),
            autosaveName="com.mekkablue.InstanceMaker.mainwindow")

        self.w.text_1 = vanilla.TextBox((15 - 1, 12 + 2, 75, 14),
                                        "Insert",
                                        sizeStyle='small')
        self.w.numberOfInstances = vanilla.PopUpButton(
            (15 + 40, 12, 50, 17), [str(x) for x in range(3, 12)],
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.text_2 = vanilla.TextBox((15 + 40 + 55, 12 + 2, 120, 14),
                                        "instances with prefix",
                                        sizeStyle='small')
        self.w.prefix = vanilla.EditText((15 + 40 + 55 + 120, 12 - 1, -15, 19),
                                         "A-",
                                         callback=self.UpdateSample,
                                         sizeStyle='small')

        self.w.text_3 = vanilla.TextBox((15 - 1, 40 + 2, 60, 14),
                                        "from:",
                                        sizeStyle='small')
        self.w.master1 = vanilla.ComboBox((15 + 40, 40 - 1, 50, 19),
                                          self.MasterList(1),
                                          callback=self.UpdateSample,
                                          sizeStyle='small')
        self.w.text_4 = vanilla.TextBox((15 + 40 + 55, 40 + 2, 55, 14),
                                        "through:",
                                        sizeStyle='small')
        self.w.master2 = vanilla.ComboBox((15 + 40 + 55 + 55, 40 - 1, 50, 19),
                                          self.MasterList(-1),
                                          callback=self.UpdateSample,
                                          sizeStyle='small')
        self.w.text_5 = vanilla.TextBox(
            (15 + 40 + 55 + 55 + 55, 40 + 2, 55, 14),
            "at width:",
            sizeStyle='small')
        self.w.width = vanilla.EditText(
            (15 + 40 + 45 + 55 + 55 + 65, 40 - 1, -15, 19),
            "100",
            callback=self.SavePreferences,
            sizeStyle='small')

        self.w.text_6 = vanilla.TextBox((15 - 1, 68 + 2, 60, 14),
                                        "using",
                                        sizeStyle='small')
        self.w.algorithm = vanilla.PopUpButton((15 + 40, 68, 80, 17),
                                               ["Pablo", "Luc(as)", "linear"],
                                               callback=self.UpdateSample,
                                               sizeStyle='small')
        self.w.text_7 = vanilla.TextBox((15 + 40 + 85, 68 + 2, 110, 14),
                                        "distribution:",
                                        sizeStyle='small')
        self.w.help_instances = vanilla.HelpButton((-15 - 21, 68 + 2, -15, 20),
                                                   callback=self.openURL)

        self.w.existingInstances = vanilla.RadioGroup(
            (15 + 30, 100, -10, 60), [
                "Leave existing instances as they are",
                "Deactivate existing instances", "Delete existing instances"
            ],
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.existingInstances.set(0)

        self.w.maciej = vanilla.CheckBox((15, 170, 160, 19),
                                         "Maciej y distribution from:",
                                         value=False,
                                         callback=self.UpdateSample,
                                         sizeStyle='small')
        self.w.maciej_light = vanilla.ComboBox((15 + 165, 170 - 2, 50, 19),
                                               self.MasterList(1),
                                               callback=self.UpdateSample,
                                               sizeStyle='small')
        self.w.text_maciej_1 = vanilla.TextBox(
            (15 + 165 + 55, 170 + 2, 55, 19), "through:", sizeStyle='small')
        self.w.maciej_bold = vanilla.ComboBox(
            (15 + 165 + 55 + 55, 170 - 2, -15, 19),
            self.MasterList(-1),
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.text_maciej_2 = vanilla.TextBox(
            (15 + 15, 170 + 2 + 20, -40, 40),
            "Provide horizontal stem widths in extreme masters to interpolate contrast rather than stems.",
            sizeStyle='small',
            selectable=True)
        self.w.help_maciej = vanilla.HelpButton(
            (-15 - 21, 170 + 6 + 20, -15, 20), callback=self.openURL)

        self.w.sample = vanilla.Box((15, 170 + 30 + 40, -15, -30 - 15))
        self.w.sample.text = vanilla.TextBox((5, 5, -5, -5),
                                             "",
                                             sizeStyle='small')

        self.w.createButton = vanilla.Button((-80 - 15, -20 - 15, -15, -15),
                                             "Create",
                                             sizeStyle='regular',
                                             callback=self.CreateInstances)
        self.w.setDefaultButton(self.w.createButton)

        if not self.LoadPreferences():
            print "Error: Could not load preferences. Will resort to defaults."

        self.w.open()
        self.UpdateSample(self)
        self.w.makeKey()
Пример #6
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 380
        windowHeight = 160
        windowWidthResize = 500  # user can resize width by this value
        windowHeightResize = 600  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Axis Mapper",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.AxisMapper.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight = 4, 10, 22

        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, 14),
            "Axis Mapping from user-visible (not native) values:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.axisPicker = vanilla.ComboBox((inset, linePos - 1, 60, 20),
                                             self.AxisListForFrontmostFont(),
                                             callback=self.SavePreferences,
                                             sizeStyle='small')
        self.w.axisPicker.getNSComboBox().setToolTip_(
            "Pick or type the 4-letter tag of the axis for which you want to edit the mapping."
        )
        self.w.axisReset = vanilla.SquareButton((inset + 65, linePos, 20, 18),
                                                "↺",
                                                sizeStyle='small',
                                                callback=self.resetAxisList)
        self.w.axisReset.getNSButton().setToolTip_(
            "Will populate the axis picker with the tags for all axes in the frontmost font."
        )

        self.w.minText = vanilla.TextBox((inset + 100, linePos + 2, 55, 14),
                                         "Axis Min:",
                                         sizeStyle='small',
                                         selectable=True)
        self.w.minValue = vanilla.EditText(
            (inset + 100 + 55, linePos - 1, 40, 19),
            self.MinimumForCurrentAxis(),
            callback=self.SavePreferences,
            sizeStyle='small')
        tooltipText = "User-visible slider minimum, typically set with an Axis Location parameter. Not (necessarily) the native master value."
        self.w.minText.getNSTextField().setToolTip_(tooltipText)
        self.w.minValue.getNSTextField().setToolTip_(tooltipText)
        self.w.minValueReset = vanilla.SquareButton(
            (inset + 100 + 60 + 40, linePos, 20, 18),
            "↺",
            sizeStyle='small',
            callback=self.resetMinimum)
        self.w.minValueReset.getNSButton().setToolTip_(
            "Will attempt to guess the user-visible slider minimum of the frontmost font."
        )

        self.w.maxText = vanilla.TextBox((inset + 230, linePos + 2, 55, 14),
                                         "Axis Max:",
                                         sizeStyle='small',
                                         selectable=True)
        self.w.maxValue = vanilla.EditText(
            (inset + 230 + 55, linePos - 1, 40, 19),
            self.MaximumForCurrentAxis(),
            callback=self.SavePreferences,
            sizeStyle='small')
        tooltipText = "User-visible slider maximum, typically set with an Axis Location parameter. Not (necessarily) the native master value."
        self.w.maxText.getNSTextField().setToolTip_(tooltipText)
        self.w.maxValue.getNSTextField().setToolTip_(tooltipText)
        self.w.maxValueReset = vanilla.SquareButton(
            (inset + 230 + 60 + 40, linePos, 20, 18),
            "↺",
            sizeStyle='small',
            callback=self.resetMaximum)
        self.w.maxValueReset.getNSButton().setToolTip_(
            "Will attempt to guess the user-visible slider maximum of the frontmost font."
        )
        linePos += lineHeight

        self.w.mappingRecipe = vanilla.TextEditor(
            (0, linePos, -0, -20 - inset * 2),
            text=fallbackText.strip(),
            callback=self.SavePreferences,
            checksSpelling=False)
        legibleFont = NSFont.legibileFontOfSize_(NSFont.systemFontSize())
        textView = self.w.mappingRecipe.getNSTextView()
        textView.setFont_(legibleFont)

        # Buttons:
        self.w.recipeButton = vanilla.Button((inset, -20 - inset, 120, -inset),
                                             "Reset Recipe",
                                             sizeStyle='regular',
                                             callback=self.ResetRecipe)
        self.w.recipeButton.getNSButton().setToolTip_(
            "Construct a fallback axis mapping recipe for axis and the min/max values above, based on the existing active instances. Can be a good start for creating new mappings. Respects the weightClass settings for the 'wght' axis."
        )

        self.w.extractButton = vanilla.Button(
            (inset + 130, -20 - inset, 120, -inset),
            "Extract Recipe",
            sizeStyle='regular',
            callback=self.ExtractAxisMapping)
        self.w.extractButton.getNSButton().setToolTip_(
            "Extract the axis mapping recipe for the chosen axis from an existing Axis Mappings parameter, and into the min/max values specified above. Will do nothing if it fails. Great for editing existing mappings."
        )

        self.w.runButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            "Map",
            sizeStyle='regular',
            callback=self.AxisMapperMain)
        self.w.runButton.getNSButton().setToolTip_(
            "Write the current mapping recipe into an Axis Mappings parameter for the frontmost font."
        )
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Axis Mapper' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Пример #7
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 320
        windowHeight = 130
        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 rand Feature",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.BuildRandFeature.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"Build a Randomize feature with the following suffix:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.suffixText = vanilla.TextBox((inset, linePos + 3, 45, 14),
                                            u"Suffix:",
                                            sizeStyle='small',
                                            selectable=True)
        self.w.suffix = vanilla.ComboBox(
            (inset + 45, linePos, -inset - 25, 17),
            self.fillSuffixes(),
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.suffix.getNSComboBox().setToolTip_(
            u"Find all (exporting) glyphs that have this suffix and in OT feature ‘rand’, build a one-from-many substitution with them. Hint: keep the dot, but avoid the figures, e.g. for all stylistic sets, type ‘.ss’."
        )
        self.w.suffixReset = vanilla.SquareButton(
            (-inset - 20, linePos, -inset, 18),
            u"↺",
            sizeStyle='small',
            callback=self.updateUI)
        linePos += lineHeight

        self.w.overwrite = vanilla.CheckBox((inset, linePos - 1, -inset, 20),
                                            u"Overwrite existing rand feature",
                                            value=True,
                                            callback=self.SavePreferences,
                                            sizeStyle='small')
        linePos += lineHeight

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-120 - inset, -20 - inset, -inset, -inset),
            "Add Feature",
            sizeStyle='regular',
            callback=self.BuildRandFeatureMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Build rand Feature' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
    def __init__(self):
        self.mostImportantObjects = (
            "GSLayer",
            "GSAlignmentZone",
            "GSAnchor",
            "GSAnnotation",
            "GSApplication",
            "GSBackgroundImage",
            "GSClass",
            "GSComponent",
            "GSCustomParameter",
            "GSEditViewController",
            "GSGlyphEditView",
            "GSFeature",
            "GSFeaturePrefix",
            "GSFont",
            "GSFontMaster",
            "GSGlyph",
            "GSGlyphInfo",
            "GSGlyphsInfo",
            "GSGuideLine",
            "GSHint",
            "GSInstance",
            "GSNode",
            "GSPath",
            "GSPathSegment",
            "NSBezierPath",
            "NSColor",
            "NSAffineTransform",
            "NSAffineTransformStruct",
            "NSDate",
            "NSImage",
            "NSTextField",
            "NSComboBox",
            "NSPopUpButton",
            "NSButton",
            "FTPointArray",
            "Glyph_g_l_y_f",
            "GSProjectDocument",
        )

        # Window 'self.w':
        windowWidth = 250
        windowHeight = 200
        windowWidthResize = 400  # user can resize width by this value
        windowHeightResize = 650  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Method Reporter",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.MethodReporter.mainwindow"  # stores last window position and size
        )

        # UI ELEMENTS:

        # Method Picker:
        self.w.objectPicker = vanilla.ComboBox(
            (10, 10, 120, 19),
            self.mostImportantObjects,
            sizeStyle='small',
            completes=True,
            continuous=False,
            callback=self.MethodReporterMain)
        self.w.objectPicker.set("GSLayer")
        self.w.objectPicker.getNSComboBox().setToolTip_(
            "Type a class name here. Names will autocomplete.")

        # Filter:
        self.w.text2 = vanilla.TextBox((140, 13, 35, 14),
                                       "Filter:",
                                       sizeStyle='small')
        self.w.filter = vanilla.EditText((180, 10, -10, 19),
                                         "",
                                         sizeStyle='small',
                                         callback=self.MethodReporterMain)
        self.w.filter.getNSTextField().setToolTip_(
            "Type one or more search terms here. Case is ignored. Use * as wildcard at beginning, middle or end of term. Multiple search terms are AND concatendated."
        )

        # Listing of methods:
        self.w.methodList = vanilla.List(
            (0, 40, -0, -0),
            self.methodList("GSLayer"),
            autohidesScrollers=False,
            drawVerticalLines=True,
            doubleClickCallback=self.copySelection,
            rowHeight=19,
        )
        self.w.methodList.getNSTableView().tableColumns()[0].setWidth_(501)
        self.w.methodList.getNSTableView().setToolTip_(
            "Double click an entry to copy it to the clipboard and display its help() in Macro Window."
        )

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Method Reporter' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
        self.MethodReporterMain(None)
Пример #9
0
    def __init__(self):
        # register prefs if run for the first time:
        if not Glyphs.defaults["com.mekkablue.Bumper.kernStrings"]:
            self.RegisterPreferences()

        # Window 'self.w':
        windowWidth = 500
        windowHeight = 365
        windowWidthResize = 500  # user can resize width by this value
        windowHeightResize = 500  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Auto Bumper",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.Bumper.mainwindow"  # stores last window position and size
        )

        # UI elements:
        inset, lineHeight, currentHeight = 14, 24, -10
        currentHeight += lineHeight

        self.w.text_1 = vanilla.TextBox(
            (inset, currentHeight, -inset, 14),
            "Add supplementary kerning for specified glyphs in the current master:",
            sizeStyle='small')
        currentHeight += lineHeight

        self.w.swapButton = vanilla.SquareButton(
            (-inset - 20, currentHeight, -inset, 42),
            u"↰\n↲",
            sizeStyle='regular',
            callback=self.swap)

        self.w.text_left = vanilla.TextBox((inset, currentHeight + 3, 80, 14),
                                           "Left glyphs:",
                                           sizeStyle='small')
        self.w.leftGlyphs = vanilla.ComboBox(
            (inset + 80, currentHeight, -inset - 102, 18),
            self.kernStringList(self),
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.leftGlyphs.getNSComboBox().setToolTip_(
            u"Measures the specified glyphs from their right side to the following glyph. You can type the character ‘é’ or the slash-escaped glyph name ‘/eacute’. Or specify a category after an at sign ‘@Letter’, add a subcategory after a colon ‘@Letter:Lowercase’.\nAdd default strings in the text box at the bottom of the window. Expand the window at the bottom to access it."
        )
        self.w.leftIsGroups = vanilla.CheckBox(
            (-inset - 94, currentHeight + 1, -inset - 22, 17),
            u"As groups",
            value=True,
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.leftIsGroups.getNSButton().setToolTip_(
            u"If on, will measure only the specified glyph, but set the calculated kerning for the whole right group of the glyph (i.e., add group kerning). If off, will set the kerning for the glyph only (i.e., add an exception)."
        )
        currentHeight += lineHeight

        self.w.text_right = vanilla.TextBox((inset, currentHeight + 3, 80, 14),
                                            "Right glyphs:",
                                            sizeStyle='small')
        self.w.rightGlyphs = vanilla.ComboBox(
            (inset + 80, currentHeight, -inset - 102, 18),
            self.kernStringList(self),
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.rightGlyphs.getNSComboBox().setToolTip_(
            u"Measures from the previous glyphs to the specified glyphs to their left side. You can type the character ‘é’ or the slash-escaped glyph name ‘/eacute’. Or specify a category after an at sign ‘@Letter’, add a subcategory after a colon ‘@Letter:Lowercase’.\nAdd default strings in the text box at the bottom of the window. Expand the window at the bottom to access it."
        )
        self.w.rightIsGroups = vanilla.CheckBox(
            (-inset - 94, currentHeight + 1, -inset - 22, 17),
            u"As groups",
            value=True,
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.rightIsGroups.getNSButton().setToolTip_(
            u"If on, will measure only the specified glyph, but set the calculated kerning for the whole left group of the glyph (i.e., add group kerning). If off, will set the kerning for the glyph only (i.e., add an exception)."
        )
        currentHeight += lineHeight

        self.w.suffixText = vanilla.TextBox((inset, currentHeight + 3, 80, 14),
                                            u"Add suffix:",
                                            sizeStyle='small',
                                            selectable=True)
        self.w.suffix = vanilla.EditText((inset + 80, currentHeight, 150, 19),
                                         "",
                                         callback=self.SavePreferences,
                                         sizeStyle='small')
        self.w.suffix.getNSTextField().setToolTip_(
            "Looks for the suffixed version of the listed glyphs, with this suffix added to the name. Useful with .sc for smallcaps. Enter WITH the leading dot for dot suffixes. Can also be used with 'superior' for figures."
        )
        currentHeight += lineHeight

        self.w.text_21 = vanilla.TextBox((inset, currentHeight + 3, 80, 14),
                                         "Min distance:",
                                         sizeStyle='small')
        self.w.minDistance = vanilla.EditText(
            (inset + 80, currentHeight, 60, 19),
            "50",
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.minDistance.getNSTextField().setPlaceholderString_("50")
        self.w.minDistance.getNSTextField().setToolTip_(
            u"Adds kerning if the shortest distance between two glyphs is shorter than specified value. Leave blank or set to zero to ignore."
        )
        self.w.text_22 = vanilla.TextBox(
            (inset + 80 * 2, currentHeight + 3, 80, 14),
            "Max distance:",
            sizeStyle='small')
        self.w.maxDistance = vanilla.EditText(
            (inset + 80 * 3, currentHeight, 60, 19),
            "200",
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.maxDistance.getNSTextField().setPlaceholderString_("200")
        self.w.maxDistance.getNSTextField().setToolTip_(
            u"Adds kerning if the shortest distance between two glyphs is larger than specified value. Leave blank or set to zero to ignore."
        )
        self.w.text_23 = vanilla.TextBox(
            (inset + 80 * 4, currentHeight + 3, 80, 14),
            "Round by:",
            sizeStyle='small')
        self.w.roundFactor = vanilla.EditText(
            (inset + 80 * 5, currentHeight, -inset, 19),
            "10",
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.roundFactor.getNSTextField().setPlaceholderString_("10")
        self.w.roundFactor.getNSTextField().setToolTip_(
            u"Rounds calculated kerning. Leave blank or set to zero to ignore."
        )
        currentHeight += lineHeight

        self.w.text_speed = vanilla.TextBox((inset, currentHeight + 3, 42, 14),
                                            "Speed:",
                                            sizeStyle='small')
        self.w.speedPopup = vanilla.PopUpButton(
            (inset + 42, currentHeight + 1, 80, 17),
            ["very slow", "slow", "medium", "fast", "very fast"],
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.speedPopup.getNSPopUpButton().setToolTip_(
            u"Specifies the number of measurements. Measuring is processor-intensive and can take a while. Slow: many measurements, fast: few measurements."
        )
        intervalIndex = Glyphs.defaults["com.mekkablue.Bumper.speedPopup"]
        if intervalIndex is None:
            intervalIndex = 0
        self.w.text_speedExplanation = vanilla.TextBox(
            (inset + 42 + 90, currentHeight + 3, -15, 14),
            "Measuring every %i units." % intervalList[intervalIndex],
            sizeStyle='small')
        currentHeight += lineHeight

        self.w.text_6 = vanilla.TextBox((inset, currentHeight + 3, 130, 14),
                                        "Ignore height intervals:",
                                        sizeStyle='small')
        self.w.ignoreIntervals = vanilla.EditText(
            (inset + 130, currentHeight, -inset, 19),
            "",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.ignoreIntervals.getNSTextField().setPlaceholderString_(
            "200:300, 400:370, -200:-150")
        self.w.ignoreIntervals.getNSTextField().setToolTip_(
            u"Does not measure on y coordinates in intervals specified as y1:y2. Separate multiple intervals with commas."
        )
        currentHeight += lineHeight

        self.w.keepExistingKerning = vanilla.CheckBox(
            (inset + 5, currentHeight, -inset, 17),
            u"Keep (don’t overwrite) existing kerning",
            value=True,
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.keepExistingKerning.getNSButton().setToolTip_(
            u"If the kern pair already exists in the font, it will not be overwritten."
        )
        currentHeight += lineHeight

        self.w.excludeNonExporting = vanilla.CheckBox(
            (inset + 5, currentHeight, 200, 17),
            u"Exclude non-exporting glyphs",
            value=True,
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.excludeNonExporting.getNSButton().setToolTip_(
            u"If one of the specified glyphs is not set to export, Auto Bumper will skip it."
        )
        self.w.avoidZeroKerning = vanilla.CheckBox(
            (inset + 200, currentHeight, -inset, 17),
            u"Avoid zero kerns",
            value=True,
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.avoidZeroKerning.getNSButton().setToolTip_(
            u"If the calculated (and rounded) kerning value is 0, it will not be added to the font."
        )
        currentHeight += lineHeight

        self.w.reportInMacroWindow = vanilla.CheckBox(
            (inset + 5, currentHeight, -inset, 17),
            u"Also report in Macro Window (a few seconds slower)",
            value=False,
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.reportInMacroWindow.getNSButton().setToolTip_(
            u"Outputs a detailed report in the Macro Window, and opens it.")
        currentHeight += lineHeight

        self.w.openNewTabWithKernPairs = vanilla.CheckBox(
            (inset + 5, currentHeight, -inset, 17),
            u"Open new Edit tab with new kern pairs",
            value=False,
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.openNewTabWithKernPairs.getNSButton().setToolTip_(
            u"If kern pairs were added, opens them in a new Edit tab, for inspection."
        )
        currentHeight += lineHeight

        # Progress Bar:
        self.w.bar = vanilla.ProgressBar((inset, currentHeight, -inset, 16))
        currentHeight += lineHeight

        # (Hidden) Preferences Kern Strings:
        self.w.kernStrings = vanilla.TextEditor((1, currentHeight, -1, -45),
                                                callback=self.SavePreferences)
        self.w.kernStrings.getNSTextView().setToolTip_(
            "Add your default kern strings here. They will show up in the left/right dropdowns at the top. Everything after a hashtag (#) is ignored. Use blank lines for structuring."
        )

        self.w.text_kernStrings = vanilla.TextBox(
            (inset, -14 - inset, -100 - inset, -inset),
            "Expand window below to access default strings.",
            sizeStyle='small')
        self.w.text_kernStrings.getNSTextField().setTextColor_(
            NSColor.colorWithRed_green_blue_alpha_(0, 0, 0, 0.2))

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-100 - inset, -20 - inset, -inset, -inset),
            "Kern",
            sizeStyle='regular',
            callback=self.BumperMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: Auto Bumper could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Пример #10
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 390
        windowHeight = 260
        windowWidthResize = 800  # 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
            "GapFinder",  # window title
            minSize=(windowWidth, windowHeight),  # Maximum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.GapFinder.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"Open tab with kern gaps in current master:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.textScript = vanilla.TextBox((inset, linePos + 2, 42, 14),
                                            u"Script:",
                                            sizeStyle='small',
                                            selectable=True)
        self.w.popupScript = vanilla.ComboBox(
            (inset + 42, linePos - 1, 110, 18), ("latin", "cyrillic", "greek"),
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.textDistance = vanilla.TextBox(
            (inset + 160, linePos + 2, 100, 14),
            "Max distance:",
            sizeStyle='small')
        self.w.maxDistance = vanilla.EditText(
            (inset + 240, linePos - 1, -15, 19), "200", sizeStyle='small')
        linePos += lineHeight

        self.w.textSpeed = vanilla.TextBox((inset, linePos + 2, 42, 14),
                                           u"Speed:",
                                           sizeStyle='small',
                                           selectable=True)
        self.w.popupSpeed = vanilla.PopUpButton(
            (inset + 42, linePos, 110, 17),
            ("very slow", "slow", "medium", "fast", "very fast"),
            callback=self.SavePreferences,
            sizeStyle='small')
        intervalIndex = Glyphs.defaults["com.mekkablue.GapFinder.popupSpeed"]
        if intervalIndex is None:
            intervalIndex = 0
        self.w.text_speedExplanation = vanilla.TextBox(
            (inset + 160, linePos + 2, -inset, 14),
            "Measuring every %i units." % intervalList[intervalIndex],
            sizeStyle='small')
        linePos += lineHeight

        self.w.text_3 = vanilla.TextBox((inset, linePos + 2, 90, 14),
                                        "Left Category:",
                                        sizeStyle='small')
        self.w.popupLeftCat = vanilla.PopUpButton(
            (inset + 90, linePos, -inset, 17),
            categoryList,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.text_4 = vanilla.TextBox((inset, linePos + 2, 90, 14),
                                        "Right Category:",
                                        sizeStyle='small')
        self.w.popupRightCat = vanilla.PopUpButton(
            (inset + 90, linePos, -inset, 17),
            categoryList,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.text_5 = vanilla.TextBox((inset, linePos + 2, 160, 14),
                                        "Exclude glyphs containing:",
                                        sizeStyle='small')
        self.w.excludeSuffixes = vanilla.EditText(
            (inset + 150, linePos, -inset, 19),
            ".locl, .alt, .sups, .sinf, .tf, .tosf, Ldot, ldot, Jacute, jacute",
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.excludeNonExporting = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            "Exclude non-exporting glyphs",
            value=True,
            sizeStyle='small',
            callback=self.SavePreferences)
        linePos += lineHeight

        self.w.reportGapsInMacroWindow = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            "Also report in Macro Window (a few seconds slower)",
            value=False,
            sizeStyle='small',
            callback=self.SavePreferences)
        linePos += lineHeight

        # Percentage:
        self.w.bar = vanilla.ProgressBar((inset, linePos, -inset, 16))

        #self.w.percentage = vanilla.TextBox( (15-1, -30, -100-15, -15), "", sizeStyle='small' )

        # Run Button:
        self.w.runButton = vanilla.Button((-100 - 15, -20 - 15, -15, -15),
                                          "Open Tab",
                                          sizeStyle='regular',
                                          callback=self.GapFinderMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'GapFinder' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Пример #11
0
    def __init__(self):

        # Window 'self.w':
        windowWidth = 360
        windowHeight = 390
        windowWidthResize = 0  # user can resize width by this value
        windowHeightResize = 300  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Insert weight instances",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.InstanceMaker.mainwindow"  # stores last window position and size
        )
        inset, lineheight = 15, 12

        self.w.text_1 = vanilla.TextBox((inset - 1, lineheight + 2, 75, 14),
                                        "Insert",
                                        sizeStyle='small')
        self.w.numberOfInstances = vanilla.PopUpButton(
            (inset + 40, lineheight, 50, 17), [str(x) for x in range(3, 12)],
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.numberOfInstances.getNSPopUpButton().setToolTip_(
            "Choose how many instances you want to add. A full weight spectrum has 9 weights."
        )
        self.w.text_2 = vanilla.TextBox(
            (inset + 40 + 55, lineheight + 2, 120, 14),
            "instances with prefix",
            sizeStyle='small')
        self.w.prefix = vanilla.EditText(
            (inset + 40 + 55 + 120, lineheight - 1, -inset, 19),
            "A-",
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.prefix.getNSTextField().setToolTip_(
            u"Choose text that is added at the beginning of each instance, e.g., ‘Condensed’."
        )
        lineheight += 28

        self.w.text_3 = vanilla.TextBox((inset - 1, lineheight + 2, 60, 14),
                                        "from:",
                                        sizeStyle='small')
        self.w.master1 = vanilla.ComboBox((inset + 35, lineheight - 1, 62, 19),
                                          self.MasterList(1),
                                          callback=self.UpdateSample,
                                          sizeStyle='small')
        self.w.master1.getNSComboBox().setToolTip_(
            "Weight value for the first instance being added, typically the stem width of your lightest weight."
        )
        self.w.text_4 = vanilla.TextBox(
            (inset + 50 + 55 * 1, lineheight + 2, 55, 14),
            "through:",
            sizeStyle='small')
        self.w.master2 = vanilla.ComboBox(
            (inset + 50 + 55 * 2, lineheight - 1, 62, 19),
            self.MasterList(-1),
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.master2.getNSComboBox().setToolTip_(
            "Weight value for the last instance being added, typically the stem width of your boldest weight."
        )
        self.w.text_5 = vanilla.TextBox(
            (inset + 65 + 55 * 3, lineheight + 2, 55, 14),
            "at width:",
            sizeStyle='small')
        self.w.width = vanilla.EditText(
            (inset + 65 + 55 * 4, lineheight - 1, -inset, 19),
            "100",
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.width.getNSTextField().setToolTip_(
            "The Width value for the instances being added. Default is 100. Adapt accordingly if you are adding condensed or extended instances."
        )
        lineheight += 28

        self.w.text_6 = vanilla.TextBox((inset - 1, lineheight + 2, 60, 14),
                                        "using",
                                        sizeStyle='small')
        self.w.algorithm = vanilla.PopUpButton(
            (inset + 35, lineheight, 90, 17),
            ("linear", "Pablo", "Schneider", "Abraham", "Luc(as)"),
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.algorithm.getNSPopUpButton().setToolTip_(
            "The way the Weight values are distributed between the first and last master values you entered above. Linear means equal steps between instances. Luc(as) (after Lucas de Groot) means the same growth percentage between instances. Pablo (after Pablo Impallari) is like Luc(as) at first, then becomes increasingly linear, i.e., flat in the periphery and steep in the middle. Schneider (after Lukas Schneider) is half way between Pablo and Luc(as) algorithms. Abraham (after Abraham Lee) is linear at first, then becomes incresingly like Luc(as), i.e. steep in the periphery, flat in the middle.\nFor a wide spectrum, try Pablo or Schneider. For spectrums that do not grow too bold, try Abraham or Luc(as). The latter tend to have large jumps at the end, which are usually found in the center of the weight spectrum (between Regular and Semibold). Smaller jumps are preferable in the periphery, i.e., for very light and very dark weights."
        )
        self.w.text_7 = vanilla.TextBox(
            (inset + 40 + 85 + 5, lineheight + 2, 110, 14),
            "distribution.",
            sizeStyle='small')
        self.w.help_instances = vanilla.HelpButton(
            (-15 - 21, lineheight + 2, -inset, 20), callback=self.openURL)
        lineheight += 32

        self.w.existingInstances = vanilla.RadioGroup(
            (inset + 20, lineheight, -10, 60),
            ("Leave existing instances as they are",
             "Deactivate existing instances", "Delete existing instances"),
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.existingInstances.set(0)
        lineheight += 70

        self.w.naturalNames = vanilla.CheckBox(
            (inset, lineheight, inset + 225, 19),
            u"Use ‘natural’ weight names, starting at:",
            value=False,
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.naturalNames.getNSButton().setToolTip_(
            "Prefill with standard names and style linking. If turned off, will use the Weight number as instance name."
        )
        self.w.firstName = vanilla.PopUpButton(
            (inset + 225, lineheight, -inset, 17),
            naturalNames,
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.firstName.getNSPopUpButton().setToolTip_(
            "If you use natural weight names, choose here the name of your lightest weight."
        )
        try:  # workaround for macOS 10.9
            self.w.firstName.enable(
                self.w.naturalNames.getNSButton().isEnabled())
        except:
            pass
        lineheight += 20

        self.w.italicStyle = vanilla.CheckBox(
            (inset + 20, lineheight, -inset, 20),
            u"Italic suffixes and style linking",
            value=False,
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.italicStyle.getNSButton().setToolTip_(
            u"If enabled, will add the word ‘Italic’ to all instances, and also add italic style linking."
        )
        lineheight += 24

        self.w.maciej = vanilla.CheckBox((inset, lineheight - 1, 160, 19),
                                         "Maciej y distribution from:",
                                         value=False,
                                         callback=self.UpdateSample,
                                         sizeStyle='small')
        self.w.maciej.getNSButton().setToolTip_(
            "An algorithm proposed by Maciej Ratajski, which introduces slightly different interpolation for y coordinates. Will add interpolationWeightY parameters to the instances. If these value differ greatly from the weight interpolation values, interpolation of your diagonals may suffer."
        )
        self.w.text_maciej_1 = vanilla.TextBox(
            (inset + 165 + 55, lineheight + 2, 55, 19),
            "through:",
            sizeStyle='small')
        self.w.text_maciej_2 = vanilla.TextBox(
            (inset + 15, lineheight + 2 + 20, -40, 40),
            "Provide horizontal stem widths in extreme masters to interpolate contrast rather than stems.",
            sizeStyle='small',
            selectable=True)
        self.w.maciej_light = vanilla.ComboBox(
            (inset + 160, lineheight - 1, 55, 19),
            self.MasterList(1),
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.maciej_bold = vanilla.ComboBox(
            (inset + 160 + 55 + 55, lineheight - 1, -inset, 19),
            self.MasterList(-1),
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.help_maciej = vanilla.HelpButton(
            (-inset - 21, lineheight + 6 + 20, -inset, 20),
            callback=self.openURL)
        self.w.help_maciej.getNSButton().setToolTip_(
            "Will open a website with a detailed description of the Maciej algorithm. Requires an internet connection."
        )
        lineheight += 60

        self.w.shouldRound = vanilla.CheckBox((inset, lineheight, -inset, 19),
                                              "Round all interpolation values",
                                              value=True,
                                              callback=self.UpdateSample,
                                              sizeStyle='small')
        self.w.shouldRound.getNSButton().setToolTip_(
            "If enabled, will round all calculated weight values to integers. Usually a good idea."
        )
        lineheight += 30

        self.w.sample = vanilla.Box((inset, lineheight, -inset, -30 - inset))
        self.w.sample.text = vanilla.TextBox((5, 5, -5, -5),
                                             "",
                                             sizeStyle='small')

        self.w.createButton = vanilla.Button(
            (-90 - inset, -20 - inset, -inset, -inset),
            "Insert",
            sizeStyle='regular',
            callback=self.CreateInstances)
        self.w.setDefaultButton(self.w.createButton)

        if not self.LoadPreferences():
            print(
                "Error: Could not load preferences. Will resort to defaults.")

        self.w.open()
        self.UpdateSample(self)
        self.w.makeKey()
Пример #12
0
    def __init__(self):
        self.w = vanilla.Window((0, 0))

        columnDescriptions = [
            dict(columnPlacement="trailing"),
            dict(width=300, columnPlacement="fill")
        ]

        self.editText = vanilla.EditText("auto",
                                         "Type to test callback.",
                                         callback=self.editTextCallback)
        rows = [
            (vanilla.TextBox("auto",
                             "TextBox:"), vanilla.TextBox("auto", "Hello")),
            (vanilla.TextBox("auto", "EditText:"), self.editText),
            (vanilla.TextBox("auto",
                             "Button:"), vanilla.Button("auto", "Button")),
            (vanilla.TextBox("auto", "PopUpButton:"),
             vanilla.PopUpButton("auto", ["PopUpButton"])),
            (vanilla.TextBox("auto", "ComboBox:"),
             vanilla.ComboBox("auto", ["ComboBox"])),
            (vanilla.TextBox("auto", "CheckBox:"),
             vanilla.CheckBox("auto", "CheckBox 1")),
            dict(rowPadding=(0, 0),
                 cells=(None, vanilla.CheckBox("auto", "CheckBox 2"))),
            dict(rowPadding=(0, 0),
                 cells=(None, vanilla.CheckBox("auto", "CheckBox 3"))),
            (vanilla.TextBox("auto", "SegmentedButton:"),
             vanilla.SegmentedButton(
                 "auto",
                 [dict(title="One"),
                  dict(title="Two"),
                  dict(title="Three")],
                 sizeStyle="regular")),
            (vanilla.TextBox("auto", "Slider:"),
             vanilla.Slider("auto", minValue=0, maxValue=100, value=50)),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "RadioGroup:"),
                        dict(rowAlignment="none",
                             view=vanilla.RadioGroup(
                                 "auto", ["One", "Two", "Three"])))),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "ColorWell:"),
                        dict(width=50,
                             height=75,
                             view=vanilla.ColorWell(
                                 "auto", color=AppKit.NSColor.redColor())))),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "List:"),
                        dict(columnPlacement="fill",
                             rowPlacement="fill",
                             view=vanilla.List("auto",
                                               ["One", "Two", "Three"])))),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "TextEditor:"),
                        vanilla.TextEditor("auto", "TextEditor"))),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "Box:"),
                        vanilla.Box("auto",
                                    fillColor=AppKit.NSColor.blueColor(),
                                    cornerRadius=20))),
        ]
        self.w.gridView = vanilla.GridView(
            "auto",
            rows,
            columnDescriptions=columnDescriptions,
            columnWidth=150,
            columnSpacing=10,
            rowHeight=25,
            rowPadding=(15, 0))
        self.columnCount = len(columnDescriptions)
        self.rowCount = len(rows)

        # append, insert, etc. buttons

        self.appendColumnButton = vanilla.Button(
            "auto", "Append", callback=self.appendColumnButtonCallback)
        self.insertColumnButton = vanilla.Button(
            "auto", "Insert", callback=self.insertColumnButtonCallback)
        self.removeColumnButton = vanilla.Button(
            "auto", "Remove", callback=self.removeColumnButtonCallback)
        self.moveColumnButton = vanilla.Button(
            "auto", "Move", callback=self.moveColumnButtonCallback)
        self.showColumnButton = vanilla.Button(
            "auto", "Show/Hide", callback=self.showColumnButtonCallback)

        self.appendRowButton = vanilla.Button(
            "auto", "Append", callback=self.appendRowButtonCallback)
        self.insertRowButton = vanilla.Button(
            "auto", "Insert", callback=self.insertRowButtonCallback)
        self.removeRowButton = vanilla.Button(
            "auto", "Remove", callback=self.removeRowButtonCallback)
        self.moveRowButton = vanilla.Button(
            "auto", "Move", callback=self.moveRowButtonCallback)
        self.showRowButton = vanilla.Button(
            "auto", "Show/Hide", callback=self.showRowButtonCallback)

        rows = [[
            vanilla.TextBox("auto", "Column:"), self.appendColumnButton,
            self.insertColumnButton, self.removeColumnButton,
            self.moveColumnButton, self.showColumnButton
        ],
                [
                    vanilla.TextBox("auto", "Row:"), self.appendRowButton,
                    self.insertRowButton, self.removeRowButton,
                    self.moveRowButton, self.showRowButton
                ]]
        columnDescriptions = [dict(width=60, columnPlacement="trailing")]
        for i in range(len(rows[0]) - 1):
            columnDescriptions.append({})

        self.w.line = vanilla.HorizontalLine("auto")
        self.w.testButtonGrid = vanilla.GridView(
            "auto",
            rows,
            columnDescriptions=columnDescriptions,
            columnWidth=100,
            columnSpacing=5,
            columnPlacement="fill",
            rowHeight=25)

        rules = [
            "H:|-margin-[gridView]-margin-|", "H:|[line]|",
            "H:|-margin-[testButtonGrid]-margin-|", "V:|"
            "-margin-"
            "[gridView]"
            "-margin-"
            "[line]"
            "-margin-"
            "[testButtonGrid]"
            "-margin-"
            "|"
        ]
        metrics = dict(margin=15)
        self.w.addAutoPosSizeRules(rules, metrics)
        self.w.open()
Пример #13
0
    def __init__(self):
        self.mostImportantObjects = [
            "GSLayer",
            "GSAlignmentZone",
            "GSAnchor",
            "GSAnnotation",
            "GSApplication",
            "GSBackgroundImage",
            "GSClass",
            "GSComponent",
            "GSCustomParameter",
            "GSEditViewController",
            "GSGlyphEditView",
            "GSFeature",
            "GSFeaturePrefix",
            "GSFont",
            "GSFontMaster",
            "GSGlyph",
            "GSGlyphInfo",
            "GSGuideLine",
            "GSHint",
            "GSInstance",
            "GSNode",
            "GSPath",
            "NSBezierPath",
            "NSColor",
            "NSAffineTransform",
            "NSAffineTransformStruct",
            "NSDate",
            "NSImage",
        ]

        # Window 'self.w':
        windowWidth = 250
        windowHeight = 200
        windowWidthResize = 400  # user can resize width by this value
        windowHeightResize = 650  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Method Reporter",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.MethodReporter.mainwindow"  # stores last window position and size
        )

        # UI ELEMENTS:

        # Method Picker:
        self.w.objectPicker = vanilla.ComboBox(
            (10, 10, 120, 19),
            self.mostImportantObjects,
            sizeStyle='small',
            completes=True,
            continuous=False,
            callback=self.MethodReporterMain)
        self.w.objectPicker.set("GSLayer")

        # Filter:
        self.w.text2 = vanilla.TextBox((140, 13, 35, 14),
                                       "Filter:",
                                       sizeStyle='small')
        self.w.filter = vanilla.EditText((180, 10, -10, 19),
                                         "",
                                         sizeStyle='small',
                                         callback=self.MethodReporterMain)

        # Listing of methods:
        self.w.methodList = vanilla.List(
            (0, 40, -0, -0),
            dir(GSLayer),
            autohidesScrollers=False,
            drawVerticalLines=True,
            doubleClickCallback=self.copySelection,
            rowHeight=19,
        )
        self.w.methodList.getNSTableView().tableColumns()[0].setWidth_(501)

        # Load Settings:
        if not self.LoadPreferences():
            print "Note: 'Method Reporter' could not load preferences. Will resort to defaults"

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
        self.MethodReporterMain(None)
Пример #14
0
    def __init__(self):

        # Window 'self.w':
        windowWidth = 360
        windowHeight = 390
        windowWidthResize = 0  # user can resize width by this value
        windowHeightResize = 300  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Insert weight instances",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.InstanceMaker.mainwindow"  # stores last window position and size
        )
        inset, lineheight = 15, 12

        self.w.text_1 = vanilla.TextBox((inset - 1, lineheight + 2, 75, 14),
                                        "Insert",
                                        sizeStyle='small')
        self.w.numberOfInstances = vanilla.PopUpButton(
            (inset + 40, lineheight, 50, 17), [str(x) for x in range(3, 12)],
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.text_2 = vanilla.TextBox(
            (inset + 40 + 55, lineheight + 2, 120, 14),
            "instances with prefix",
            sizeStyle='small')
        self.w.prefix = vanilla.EditText(
            (inset + 40 + 55 + 120, lineheight - 1, -inset, 19),
            "A-",
            callback=self.UpdateSample,
            sizeStyle='small')
        lineheight += 28

        self.w.text_3 = vanilla.TextBox((inset - 1, lineheight + 2, 60, 14),
                                        "from:",
                                        sizeStyle='small')
        self.w.master1 = vanilla.ComboBox((inset + 35, lineheight - 1, 62, 19),
                                          self.MasterList(1),
                                          callback=self.UpdateSample,
                                          sizeStyle='small')
        self.w.text_4 = vanilla.TextBox(
            (inset + 50 + 55 * 1, lineheight + 2, 55, 14),
            "through:",
            sizeStyle='small')
        self.w.master2 = vanilla.ComboBox(
            (inset + 50 + 55 * 2, lineheight - 1, 62, 19),
            self.MasterList(-1),
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.text_5 = vanilla.TextBox(
            (inset + 65 + 55 * 3, lineheight + 2, 55, 14),
            "at width:",
            sizeStyle='small')
        self.w.width = vanilla.EditText(
            (inset + 65 + 55 * 4, lineheight - 1, -inset, 19),
            "100",
            callback=self.UpdateSample,
            sizeStyle='small')
        lineheight += 28

        self.w.text_6 = vanilla.TextBox((inset - 1, lineheight + 2, 60, 14),
                                        "using",
                                        sizeStyle='small')
        self.w.algorithm = vanilla.PopUpButton(
            (inset + 35, lineheight, 90, 17), (
                "linear",
                "Pablo",
                "Schneider",
                "Luc(as)",
            ),
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.text_7 = vanilla.TextBox(
            (inset + 40 + 85 + 5, lineheight + 2, 110, 14),
            "distribution.",
            sizeStyle='small')
        self.w.help_instances = vanilla.HelpButton(
            (-15 - 21, lineheight + 2, -inset, 20), callback=self.openURL)
        lineheight += 32

        self.w.existingInstances = vanilla.RadioGroup(
            (inset + 20, lineheight, -10, 60),
            ("Leave existing instances as they are",
             "Deactivate existing instances", "Delete existing instances"),
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.existingInstances.set(0)
        lineheight += 70

        self.w.naturalNames = vanilla.CheckBox(
            (inset, lineheight, inset + 225, 19),
            u"Use ‘natural’ weight names, starting at:",
            value=False,
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.firstName = vanilla.PopUpButton(
            (inset + 225, lineheight, -inset, 17),
            naturalNames,
            callback=self.UpdateSample,
            sizeStyle='small')
        try:  # workaround for macOS 10.9
            self.w.firstName.enable(
                self.w.naturalNames.getNSButton().isEnabled())
        except:
            pass
        lineheight += 20

        self.w.italicStyle = vanilla.CheckBox(
            (inset + 20, lineheight, -inset, 20),
            u"Italic suffixes and style linking",
            value=False,
            callback=self.UpdateSample,
            sizeStyle='small')
        lineheight += 24

        self.w.maciej = vanilla.CheckBox((inset, lineheight - 1, 160, 19),
                                         "Maciej y distribution from:",
                                         value=False,
                                         callback=self.UpdateSample,
                                         sizeStyle='small')
        self.w.text_maciej_1 = vanilla.TextBox(
            (inset + 165 + 55, lineheight + 2, 55, 19),
            "through:",
            sizeStyle='small')
        self.w.text_maciej_2 = vanilla.TextBox(
            (inset + 15, lineheight + 2 + 20, -40, 40),
            "Provide horizontal stem widths in extreme masters to interpolate contrast rather than stems.",
            sizeStyle='small',
            selectable=True)
        self.w.maciej_light = vanilla.ComboBox(
            (inset + 160, lineheight - 1, 55, 19),
            self.MasterList(1),
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.maciej_bold = vanilla.ComboBox(
            (inset + 160 + 55 + 55, lineheight - 1, -inset, 19),
            self.MasterList(-1),
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.help_maciej = vanilla.HelpButton(
            (-inset - 21, lineheight + 6 + 20, -inset, 20),
            callback=self.openURL)
        lineheight += 60

        self.w.shouldRound = vanilla.CheckBox((inset, lineheight, -inset, 19),
                                              "Round all interpolation values",
                                              value=True,
                                              callback=self.UpdateSample,
                                              sizeStyle='small')
        lineheight += 30

        self.w.sample = vanilla.Box((inset, lineheight, -inset, -30 - inset))
        self.w.sample.text = vanilla.TextBox((5, 5, -5, -5),
                                             "",
                                             sizeStyle='small')

        self.w.createButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            "Create",
            sizeStyle='regular',
            callback=self.CreateInstances)
        self.w.setDefaultButton(self.w.createButton)

        if not self.LoadPreferences():
            print "Error: Could not load preferences. Will resort to defaults."

        self.w.open()
        self.UpdateSample(self)
        self.w.makeKey()
Пример #15
0
         "', sizeStyle='small')")

    eti = vanilla.EditText(
        (leftMargin + scOffset + xOff, setLineHeight(2.7), 65, 20),
        sizeStyle='small')

    masterScaleList.append(eti)

    exec("w.master_" + mname + "_input=eti")

    xOff += 70

w.sidebearing_label = getLabel("SB Factor:", 3.7)

w.sbFactors_combo = vanilla.ComboBox(
    (leftMargin + scOffset, setLineHeight(3.7), -leftMargin, 20), ["0", "1"],
    sizeStyle='small')
w.options_label = getLabel("Options: ", 4.7)

w.baseName_checkbox = getCheckbox("Only Base Name", 3 + 1.7)
w.lowerCase_checkbox = getCheckbox("Make lowercase", 3.7 + 1.7)
w.removeAnchors_checkbox = getCheckbox("Delete Anchors", 4.4 + 1.7)

w.presetsBtnLabel = getLabel("Presets: ", 7)
w.presetsBtn = vanilla.PopUpButton(
    (leftMargin + scOffset, setLineHeight(7) - 3, -leftMargin, 20),
    GetPresets(),
    callback=onPresetsChange,
    sizeStyle='small')

w.mainButton = vanilla.Button((-leftMargin - 150, -40, 150, -leftMargin),
Пример #16
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 180
        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
            "Replace all Paths with Component",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.ReplaceAllPathsWithComponent.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.text_1 = vanilla.TextBox(
            (15, 12, -15, 14),
            "Replace each path in the current font with component:",
            sizeStyle='small')

        self.w.componentPicker = vanilla.ComboBox(
            (15, 11 + 20, -50, 19), (),
            sizeStyle='small',
            completes=True,
            continuous=False,
            callback=self.SavePreferences)
        self.w.update = vanilla.SquareButton((-40, 12 + 20, -15, 18),
                                             u"↺",
                                             sizeStyle='small',
                                             callback=self.updateCurrentGlyphs)

        self.w.text_2 = vanilla.TextBox((15, 14 + 45, 120, 14),
                                        "Component Position:",
                                        sizeStyle='small')
        self.w.align = vanilla.PopUpButton((140, 12 + 45, -15, 17),
                                           self.alignments,
                                           callback=self.SavePreferences,
                                           sizeStyle='small')

        self.w.onlySelectedGlyphs = vanilla.CheckBox(
            (15, 12 + 70, -15, 30),
            "Replace in selected glyphs only",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.onlyExportingGlyphs = vanilla.CheckBox(
            (15, 12 + 90, -15, 30),
            "Replace in exporting glyphs only",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-80 - 15, -20 - 15, -15, -15),
            "Replace",
            sizeStyle='regular',
            callback=self.ReplaceAllPathsWithComponent)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print "Note: 'Replace all Paths with Component' could not load preferences. Will resort to defaults"

        self.updateCurrentGlyphs(None)

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Пример #17
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 320
        windowHeight = 170
        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 rand Feature",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.BuildRandFeature.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"Build a Randomize feature with the following suffix:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.suffixText = vanilla.TextBox((inset, linePos + 3, 45, 14),
                                            u"Suffix:",
                                            sizeStyle='small',
                                            selectable=True)
        self.w.suffix = vanilla.ComboBox(
            (inset + 45, linePos, -inset - 25, 17),
            self.fillSuffixes(),
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.suffix.getNSComboBox().setToolTip_(
            u"Find all (exporting) glyphs that have this suffix and in OT feature ‘rand’, build a one-from-many substitution with them. Hint: keep the dot, but avoid the figures, e.g. for all stylistic sets, type ‘.ss’."
        )
        self.w.suffixReset = vanilla.SquareButton(
            (-inset - 20, linePos, -inset, 18),
            u"↺",
            sizeStyle='small',
            callback=self.updateUI)
        linePos += lineHeight

        self.w.exclude = vanilla.CheckBox((inset, linePos, 160, 20),
                                          "Exclude glyphs containing:",
                                          value=False,
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        self.w.excludeList = vanilla.EditText(
            (inset + 160, linePos, -inset, 19),
            ".build, .ss12",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.excludeList.getNSTextField().setToolTip_(
            "Comma-separated list of glyph name particles. Glyphs contining these partcles in their names will be excluded from the rand feature generation."
        )
        linePos += lineHeight

        self.w.includeDefault = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Include unsuffixed default in randomisation",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeDefault.getNSButton().setToolTip_(
            "If activated will substitute A from [A A.cv01 A.cv02]. If deactivated, will substitute only from [A.cv01 A.cv02]."
        )
        linePos += lineHeight

        self.w.overwrite = vanilla.CheckBox((inset, linePos - 1, -inset, 20),
                                            u"Overwrite existing rand feature",
                                            value=True,
                                            callback=self.SavePreferences,
                                            sizeStyle='small')
        linePos += lineHeight

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-120 - inset, -20 - inset, -inset, -inset),
            "Add Feature",
            sizeStyle='regular',
            callback=self.BuildRandFeatureMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Build rand Feature' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.guiUpdate()
        self.w.open()
        self.w.makeKey()
Пример #18
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 410
        windowHeight = 350
        windowWidthResize = 800  # 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
            "KernCrasher",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.KernCrasher.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"Open tab with kern collisions in current master:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.textScript = vanilla.TextBox((inset, linePos + 2, 42, 14),
                                            u"Script:",
                                            sizeStyle='small',
                                            selectable=True)
        self.w.popupScript = vanilla.ComboBox(
            (inset + 42, linePos - 1, 110, 18), ("latin", "cyrillic", "greek"),
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.popupScript.getNSComboBox().setToolTip_(
            "Limits the kerning pairs only to glyphs of this script, and those of no script."
        )
        self.w.updateScriptsButton = vanilla.SquareButton(
            (inset + 160, linePos, 20, 18),
            "↺",
            sizeStyle='small',
            callback=self.update)
        self.w.updateScriptsButton.getNSButton().setToolTip_(
            "Scans the frontost font for the scripts of all its glyphs (Latin, Greek, Cyrillic, Hebrew, Arabic, Thai, ...) and lists only those in the combo box."
        )
        self.w.textDistance = vanilla.TextBox(
            (inset + 200, linePos + 2, 100, 14),
            "Min distance:",
            sizeStyle='small')
        self.w.minDistance = vanilla.EditText(
            (inset + 280, linePos - 1, -15, 19), "10", sizeStyle='small')
        tooltipText = "Minimum distance required between glyphs in any given pairing with the current setup. Measured in units."
        self.w.textDistance.getNSTextField().setToolTip_(tooltipText)
        self.w.minDistance.getNSTextField().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.textSpeed = vanilla.TextBox((inset, linePos + 2, 42, 14),
                                           u"Speed:",
                                           sizeStyle='small',
                                           selectable=True)
        self.w.popupSpeed = vanilla.PopUpButton(
            (inset + 42, linePos, 110, 17),
            ("very slow", "slow", "medium", "fast", "very fast"),
            callback=self.SavePreferences,
            sizeStyle='small')
        intervalIndex = Glyphs.defaults["com.mekkablue.KernCrasher.popupSpeed"]
        if intervalIndex is None:
            intervalIndex = 0
        self.w.text_speedExplanation = vanilla.TextBox(
            (inset + 160, linePos + 2, -inset, 14),
            "Measuring every %i units." % intervalList[intervalIndex],
            sizeStyle='small')
        tooltipText = "The distances within every glyph pair will be measured from top to bottom. This setting determines how many measurements are taken. Higher speed means less measurements and thus less accuracy. Many measurements are more accurate, but also slow down the script significantly."
        self.w.textSpeed.getNSTextField().setToolTip_(tooltipText)
        self.w.popupSpeed.getNSPopUpButton().setToolTip_(tooltipText)
        self.w.text_speedExplanation.getNSTextField().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.text_popupLeftCat = vanilla.TextBox(
            (inset, linePos + 2, 90, 14), "Left Category:", sizeStyle='small')
        self.w.popupLeftCat = vanilla.PopUpButton(
            (inset + 90, linePos, -inset, 17),
            categoryList,
            callback=self.SavePreferences,
            sizeStyle='small')
        tooltipText = "The category for the glyph on the LEFT side of the kerning pair. In ‘AV’, that would be ‘A’."
        self.w.text_popupLeftCat.getNSTextField().setToolTip_(tooltipText)
        self.w.popupLeftCat.getNSPopUpButton().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.text_popupRightCat = vanilla.TextBox(
            (inset, linePos + 2, 90, 14), "Right Category:", sizeStyle='small')
        self.w.popupRightCat = vanilla.PopUpButton(
            (inset + 90, linePos, -inset, 17),
            categoryList,
            callback=self.SavePreferences,
            sizeStyle='small')
        tooltipText = "The category for the glyph on the RIGHT side of the kerning pair. In ‘AV’, that would be ‘V’."
        self.w.text_popupRightCat.getNSTextField().setToolTip_(tooltipText)
        self.w.popupRightCat.getNSPopUpButton().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.text_limitLeftSuffixes = vanilla.TextBox(
            (inset, linePos + 2, 160, 14),
            "Left glyph must contain:",
            sizeStyle='small')
        self.w.limitLeftSuffixes = vanilla.EditText(
            (inset + 150, linePos, -inset, 19),
            "",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.limitLeftSuffixes.getNSTextField().setPlaceholderString_(
            "tilde, macron, dieresis, circumflex, caron")
        tooltipText = "Only glyphs with these parts in their glyph names will be considered for the LEFT side. Comma-separated list. Usually not necessary, but useful for tracking down problems with wide diacritics."
        self.w.text_limitLeftSuffixes.getNSTextField().setToolTip_(tooltipText)
        self.w.limitLeftSuffixes.getNSTextField().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.text_limitRightSuffixes = vanilla.TextBox(
            (inset, linePos + 2, 160, 14),
            "Right glyph must contain:",
            sizeStyle='small')
        self.w.limitRightSuffixes = vanilla.EditText(
            (inset + 150, linePos, -inset, 19),
            "",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.limitRightSuffixes.getNSTextField().setPlaceholderString_(
            "tilde, macron, dieresis, circumflex, caron")
        tooltipText = "Only glyphs with these parts in their glyph names will be considered for the RIGHT side. Comma-separated list. Usually not necessary, but useful for tracking down problems with wide diacritics."
        self.w.text_limitRightSuffixes.getNSTextField().setToolTip_(
            tooltipText)
        self.w.limitRightSuffixes.getNSTextField().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.text_excludeSuffixes = vanilla.TextBox(
            (inset, linePos + 2, 160, 14),
            "Exclude glyphs containing:",
            sizeStyle='small')
        self.w.excludeSuffixes = vanilla.EditText(
            (inset + 150, linePos, -inset, 19),
            ".locl, .alt, .sups, .sinf, .tf, .tosf, Ldot, ldot, Jacute, jacute",
            callback=self.SavePreferences,
            sizeStyle='small')
        tooltipText = "Glyphs with these parts in their glyph names will be ignored. Comma-separated list. Useful for excluding impossible pairings, like ldot (can only appear before l) and jacute (can only appear after iacute), or OpenType variants."
        self.w.text_excludeSuffixes.getNSTextField().setToolTip_(tooltipText)
        self.w.excludeSuffixes.getNSTextField().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.text_ignoreIntervals = vanilla.TextBox(
            (inset, linePos + 2, 160, 14),
            "Ignore height intervals:",
            sizeStyle='small')
        self.w.ignoreIntervals = vanilla.EditText(
            (inset + 150, linePos, -inset, 19),
            "",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.ignoreIntervals.getNSTextField().setPlaceholderString_(
            "200:300, 400:370, -200:-150")
        tooltipText = "Will not measure between the specified heights. Useful for excluding connectors of connecting script typefaces or rekha lines like in Devanagari, where an overlap is intended by design. Specify two numbers separated by a colon, e.g., 200:300, and it will only measure until y=200 and start measuring again at y=300, skipping everything in between. If you specify multiple ranges, separate them with commas."
        self.w.text_ignoreIntervals.getNSTextField().setToolTip_(tooltipText)
        self.w.ignoreIntervals.getNSTextField().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.pathGlyphsOnly = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Limit to glyphs containing paths (i.e., exclude composites)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.pathGlyphsOnly.getNSButton().setToolTip_(
            "If enabled, will ignore glyphs that do not have paths. Useful for focusing on the base shapes (before you deal with the specific problems of composite diacritics)."
        )
        linePos += lineHeight

        self.w.excludeNonExporting = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            "Exclude non-exporting glyphs",
            value=True,
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.excludeNonExporting.getNSButton().setToolTip_(
            "If enabled, will ignore glyphs that are set to not export. Recommended, otherwise you may get a lot of false positives."
        )
        linePos += lineHeight

        self.w.reportCrashesInMacroWindow = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            "Verbose report in Macro Window",
            value=False,
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.reportCrashesInMacroWindow.getNSButton().setToolTip_(
            "Will output a detailed report of the kern crashing in Window > Macro Panel. Will slow down the script a bit. Usually not necessary, but can be useful for checking if a certain pairing has been taken care of or not."
        )
        self.w.reuseCurrentTab = vanilla.CheckBox(
            (inset + 240, linePos, -inset, 20),
            u"Reuse current tab",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.reuseCurrentTab.getNSButton().setToolTip_(
            "If enabled, will not open a new tab with newly added kern pairs, but reuse the current Edit tab. Will open an Edit tab if none is open."
        )
        linePos += lineHeight

        # Percentage:
        self.w.bar = vanilla.ProgressBar((inset, linePos, -inset, 16))

        #self.w.percentage = vanilla.TextBox( (15-1, -30, -100-15, -15), "", sizeStyle='small' )

        # Buttons:
        self.w.nextButton = vanilla.Button(
            (-inset - 210, -20 - inset, -inset - 100, -inset),
            u"Next Master",
            sizeStyle='regular',
            callback=self.masterSwitch)

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-90 - inset, -20 - inset, -inset, -inset),
            "Open Tab",
            sizeStyle='regular',
            callback=self.KernCrasherMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'KernCrasher' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Пример #19
0
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 410
		windowHeight = 310
		windowWidthResize  = 800 # 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
			"KernCrasher", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.KernCrasher.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"Open tab with kern collisions in current master:", sizeStyle='small', selectable=True )
		linePos += lineHeight
		
		self.w.textScript = vanilla.TextBox( (inset, linePos+2, 42, 14), u"Script:", sizeStyle='small', selectable=True )
		self.w.popupScript = vanilla.ComboBox( (inset+42, linePos-1, 110, 18), ("latin","cyrillic","greek"), callback=self.SavePreferences, sizeStyle='small' )
		self.w.textDistance = vanilla.TextBox( (inset+160, linePos+2, 100, 14), "Min distance:", sizeStyle='small' )
		self.w.minDistance = vanilla.EditText( (inset+240, linePos-1, -15, 19), "10", sizeStyle='small')
		linePos += lineHeight

		self.w.textSpeed = vanilla.TextBox( (inset, linePos+2, 42, 14), u"Speed:", sizeStyle='small', selectable=True )
		self.w.popupSpeed = vanilla.PopUpButton( (inset+42, linePos, 110, 17), ("very slow","slow","medium","fast","very fast"), callback=self.SavePreferences, sizeStyle='small' )
		intervalIndex = Glyphs.defaults["com.mekkablue.KernCrasher.popupSpeed"]
		if intervalIndex is None:
			intervalIndex = 0
		self.w.text_speedExplanation = vanilla.TextBox( (inset+160, linePos+2, -inset, 14), "Measuring every %i units."%intervalList[intervalIndex], sizeStyle='small' )
		linePos += lineHeight
		
		self.w.text_3 = vanilla.TextBox( (inset, linePos+2, 90, 14), "Left Category:", sizeStyle='small' )
		self.w.popupLeftCat = vanilla.PopUpButton( (inset+90, linePos, -inset, 17), categoryList, callback=self.SavePreferences, sizeStyle='small' )
		linePos += lineHeight

		self.w.text_4 = vanilla.TextBox( (inset, linePos+2, 90, 14), "Right Category:", sizeStyle='small' )
		self.w.popupRightCat = vanilla.PopUpButton( (inset+90, linePos, -inset, 17), categoryList, callback=self.SavePreferences, sizeStyle='small' )
		linePos += lineHeight
		
		self.w.text_5 = vanilla.TextBox( (inset, linePos+2, 160, 14), "Exclude glyphs containing:", sizeStyle='small' )
		self.w.excludeSuffixes = vanilla.EditText( (inset+150, linePos, -inset, 19), ".locl, .alt, .sups, .sinf, .tf, .tosf, Ldot, ldot, Jacute, jacute", callback=self.SavePreferences, sizeStyle='small')
		linePos += lineHeight

		self.w.text_6 = vanilla.TextBox( (inset, linePos+2, 160, 14), "Ignore height intervals:", sizeStyle='small' )
		self.w.ignoreIntervals = vanilla.EditText( (inset+150, linePos, -inset, 19), "", callback=self.SavePreferences, sizeStyle='small')
		self.w.ignoreIntervals.getNSTextField().setPlaceholderString_("200:300, 400:370, -200:-150")
		linePos += lineHeight
		
		self.w.pathGlyphsOnly = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Limit to glyphs containing paths (i.e., exclude compounds)", value=False, callback=self.SavePreferences, sizeStyle='small' )
		linePos += lineHeight

		self.w.excludeNonExporting = vanilla.CheckBox( (inset, linePos, -inset, 20), "Exclude non-exporting glyphs", value=True, sizeStyle='small', callback=self.SavePreferences )
		linePos += lineHeight

		self.w.reportCrashesInMacroWindow = vanilla.CheckBox( (inset, linePos, -inset, 20), "Also report in Macro Window (slower)", value=False, sizeStyle='small', callback=self.SavePreferences )
		self.w.reuseCurrentTab = vanilla.CheckBox( (inset+240, linePos, -inset, 20), u"Reuse current tab", value=True, callback=self.SavePreferences, sizeStyle='small' )
		self.w.reuseCurrentTab.getNSButton().setToolTip_(u"If enabled, will not open a new tab with newly added kern pairs, but reuse the current Edit tab. Will open an Edit tab if none is open.")
		linePos += lineHeight
		
		
		# Percentage:
		self.w.bar = vanilla.ProgressBar((inset, linePos, -inset, 16))
		
		#self.w.percentage = vanilla.TextBox( (15-1, -30, -100-15, -15), "", sizeStyle='small' )
		
		# Buttons:
		self.w.nextButton = vanilla.Button( (-inset-210, -20-inset, -inset-100, -inset), u"Next Master", sizeStyle='regular', callback=self.masterSwitch )
		
		# Run Button:
		self.w.runButton = vanilla.Button((-90-inset, -20-inset, -inset, -inset), "Open Tab", sizeStyle='regular', callback=self.KernCrasherMain )
		self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print("Note: 'KernCrasher' could not load preferences. Will resort to defaults")
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
Пример #20
0
    (leftMargin, setLineHeight(1), -leftMargin, leftMargin),
    "Select",
    sizeStyle='regular',
    callback=selectCallback)
w.moveButton = vanilla.Button(
    (leftMargin, setLineHeight(2), -leftMargin, leftMargin),
    "Move",
    sizeStyle='regular',
    callback=moveCallback)

w.angle_label = vanilla.TextBox((leftMargin, setLineHeight(3), 0, 14),
                                "Offset",
                                sizeStyle='small')

w.angle_text = vanilla.ComboBox(
    (leftMargin + 60, setLineHeight(3) - 4, -leftMargin, 20),
    Font.selectedFontMaster.verticalStems,
    sizeStyle='small')

w.angle_text.set("0")
# w.setDefaultButton( w.mainButton )
# w.widthButton = vanilla.Button((leftMargin, setLineHeight(4), -leftMargin, leftMargin), "Correct Width", sizeStyle='regular', callback=setWidthCallback )

w.open()
w.center()

# for l in Font.selectedLayers:
# 	if l.anchors["origin"]:
# 		del(l.anchors["origin"])
# 		# print l.anchors["origin"]