Ejemplo n.º 1
0
    def __init__(self):
        self.w = vanilla.FloatingWindow(
            (330, 170),
            "Anchor Mover 2.0",
            minSize=(300, 170),
            maxSize=(1000, 170),
            autosaveName="com.mekkablue.AnchorMover2.mainwindow")

        self.w.text_1 = vanilla.TextBox((15 - 1, 12 + 2, 75, 14),
                                        "Move anchor",
                                        sizeStyle='small')
        self.w.anchor_name = vanilla.PopUpButton(
            (15 + 75, 12, -110 - 15 - 25, 17),
            self.GetAnchorNames(),
            sizeStyle='small')
        self.w.button = vanilla.SquareButton(
            (-110 - 15 - 20, 12, -110 - 15, 18),
            u"↺",
            sizeStyle='small',
            callback=self.SetAnchorNames)
        self.w.text_2 = vanilla.TextBox((-105 - 15, 12 + 2, -15, 14),
                                        "in selected glyphs:",
                                        sizeStyle='small')

        self.w.hLine_1 = vanilla.HorizontalLine((15, 40, -15, 1))
        self.w.hText_1 = vanilla.TextBox((15 - 2, 40 + 12, 20, 14),
                                         u"↔",
                                         sizeStyle='regular')
        self.w.hText_2 = vanilla.TextBox((15 + 20, 40 + 12 + 2, 20, 14),
                                         "to",
                                         sizeStyle='small')
        self.w.hTarget = vanilla.PopUpButton(
            (15 + 40, 40 + 12, -50 - 15 - 15 - 15, 17),
            [x[0] for x in listHorizontal],
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.hText_3 = vanilla.TextBox(
            (-60 - 15 - 15, 40 + 12 + 2, -50 - 15, 14), "+", sizeStyle='small')
        self.w.hChange = vanilla.EditText((-60 - 15, 40 + 12, -15, 19),
                                          "0.0",
                                          sizeStyle='small',
                                          callback=self.SavePreferences)

        self.w.vText_1 = vanilla.TextBox((15, 70 + 12, 20, 14),
                                         u"↕",
                                         sizeStyle='regular')
        self.w.vText_2 = vanilla.TextBox((15 + 20, 70 + 12 + 2, 20, 14),
                                         "to",
                                         sizeStyle='small')
        self.w.vTarget = vanilla.PopUpButton(
            (15 + 40, 70 + 12, -50 - 15 - 15 - 15, 17),
            [y[0] for y in listVertical],
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.vText_3 = vanilla.TextBox(
            (-60 - 15 - 15, 70 + 12 + 2, -50 - 15, 14), "+", sizeStyle='small')
        self.w.vChange = vanilla.EditText((-60 - 15, 70 + 12, -15, 19),
                                          "0.0",
                                          sizeStyle='small',
                                          callback=self.SavePreferences)

        self.w.italic = vanilla.CheckBox((15, 110, -15, 18),
                                         "Respect italic angle",
                                         value=True,
                                         sizeStyle='small',
                                         callback=self.SavePreferences)

        self.w.moveButton = vanilla.Button((-80 - 15, -20 - 15, -15, -15),
                                           "Move",
                                           sizeStyle='regular',
                                           callback=self.MoveCallback)
        self.w.setDefaultButton(self.w.moveButton)

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

        self.w.open()
        self.w.makeKey()
Ejemplo n.º 2
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 270
        windowHeight = 220
        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
            "Monospace Checker",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.MonospaceChecker.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight = 12, 12, 22
        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, lineHeight * 2),
            u"New tab with glyphs that do not match the width of the default glyph in each master:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight * 2

        self.w.defaultGlyphNameText = vanilla.TextBox((inset, linePos, 85, 14),
                                                      u"Default Glyph:",
                                                      sizeStyle='small',
                                                      selectable=True)
        self.w.defaultGlyphName = vanilla.EditText(
            (inset + 85, linePos - 3, -inset, 19),
            "A",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.defaultGlyphName.getNSTextField().setToolTip_(
            u"For each master, will measure the width of this glyph, and compare all other widths to it."
        )
        linePos += lineHeight

        self.w.toleranceText = vanilla.TextBox((inset, linePos, 105, 14),
                                               u"Tolerance in units:",
                                               sizeStyle='small',
                                               selectable=True)
        self.w.tolerance = vanilla.EditText(
            (inset + 105, linePos - 3, -inset, 19),
            "0.0",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.tolerance.getNSTextField().setToolTip_(
            u"Allow deviations up to this value. 1 unit may be acceptable. If you are not sure, keep it at zero."
        )
        linePos += lineHeight

        self.w.reportZeroWidths = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Report Zero Widths in Macro Window",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.reportZeroWidths.getNSButton().setToolTip_(
            u"In the Macro Window (and only there), will also report glyphs that have zero width. Usually you can ignore those."
        )
        linePos += lineHeight

        self.w.includeNonExporting = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Include Non-Exporting Glyphs",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeNonExporting.getNSButton().setToolTip_(
            u"If disabled, will ignore non-exporting glyphs. If you are unsure, leave it off."
        )
        linePos += lineHeight

        self.w.setMonospaceFlag = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Set ‘isFixedPitch’ flag in Font Info",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.setMonospaceFlag.getNSButton().setToolTip_(
            u"Will set the isFixedPitch parameter in Font Info > Font. The parameter sets the isFixedPitch flag in the post table. Indicates whether the font is monospaced. Software can use this information to make sure that all glyphs are rendered with the same amount of pixels horizontally at any given PPM size."
        )
        linePos += lineHeight

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 3
0
    def __init__(self):
        # Window 'self.w':
        offset = 10
        line = 20

        windowWidth = 325
        windowHeight = 2 * offset + 7 * line
        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
            "Delete Small Kerning Pairs",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.DeleteSmallKerningPairs.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.text_1 = vanilla.TextBox(
            (15 - 1, offset + 2, -15, line),
            "In the current font master, delete all pairs smaller than:",
            sizeStyle='small')
        self.w.howMuch = vanilla.EditText(
            (15 - 1, offset + line + 1, -15, line),
            "10",
            sizeStyle='small',
            callback=self.SavePreferences)

        self.w.text_2 = vanilla.TextBox(
            (15 - 1, offset * 2 + line * 2 + 2, -15, line),
            "Only delete:",
            sizeStyle='small')
        self.w.positive = vanilla.CheckBox(
            (25, offset * 2 + line * 3, -15, line),
            "Positive,",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.zero = vanilla.CheckBox((90, offset * 2 + line * 3, -15, line),
                                       "zero, and",
                                       value=False,
                                       callback=self.SavePreferences,
                                       sizeStyle='small')
        self.w.negative = vanilla.CheckBox(
            (162, offset * 2 + line * 3, -15, line),
            "negative pairs",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')

        self.w.keepWindow = vanilla.CheckBox(
            (25, offset * 2 + line * 4, -15, line),
            "Keep window open",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 260
        windowWidthResize = 1000  # user can resize width by this value
        windowHeightResize = 1000  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Production Namer",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.ProductionNamer.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),
            "Will reset the production names of these glyphs:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.recipe = vanilla.TextEditor((1, linePos, -1, -70),
                                           text=defaultString.strip(),
                                           callback=self.SavePreferences,
                                           checksSpelling=False)
        self.w.recipe.getNSTextView().setToolTip_(
            "- Syntax: glyphname -> productionname\n- Whitespace does not matter\n- Only lines containing a dash (-) followed by a greater sign (>) count\n- Freely write comments and empty lines\n- Anything after a hashtag (#) is ignored"
        )
        self.w.recipe.getNSScrollView().setHasVerticalScroller_(1)
        self.w.recipe.getNSScrollView().setHasHorizontalScroller_(1)
        self.w.recipe.getNSScrollView().setRulersVisible_(0)

        legibleFont = NSFont.legibileFontOfSize_(NSFont.systemFontSize())
        textView = self.w.recipe.getNSTextView()
        textView.setFont_(legibleFont)
        textView.setHorizontallyResizable_(1)
        textView.setVerticallyResizable_(1)
        textView.setAutomaticDataDetectionEnabled_(1)
        textView.setAutomaticLinkDetectionEnabled_(1)
        textView.setDisplaysLinkToolTips_(1)
        textSize = textView.minSize()
        textSize.width = 1000
        textView.setMinSize_(textSize)

        # APPLY TO FONTS
        linePos = -inset - 50
        self.w.finger = vanilla.TextBox((inset - 5, linePos, 22, 22),
                                        "👉 ",
                                        sizeStyle='regular',
                                        selectable=True)
        self.w.applyText = vanilla.TextBox((inset + 17, linePos + 2, 70, 14),
                                           "Apply to",
                                           sizeStyle='small',
                                           selectable=True)
        self.w.applyPopup = vanilla.PopUpButton(
            (inset + 70, linePos, 150, 17),
            ("ALL open fonts", "open fonts containing", "frontmost font only"),
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.applyContaining = vanilla.EditText(
            (inset + 70 + 150 + 10, linePos, -inset, 19),
            "",
            callback=self.SavePreferences,
            sizeStyle='small',
            placeholder="enter part of family name here")
        self.w.applyContaining.getNSTextField().setToolTip_(
            "Only applies the settings to fonts that contain this in Font Info > Font > Family Name."
        )
        linePos += lineHeight

        self.w.resetButton = vanilla.Button((inset, -20 - inset, 80, -inset),
                                            "Reset",
                                            sizeStyle='regular',
                                            callback=self.updateUI)

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-120 - inset, -20 - inset, -inset, -inset),
            "Set Names",
            sizeStyle='regular',
            callback=self.ProductionNamerMain)
        self.w.setDefaultButton(self.w.runButton)

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 6
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 430
        windowHeight = 190
        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
            "Travel Tracker",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.TravelTracker.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight = 12, 15, 22

        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, 28),
            u"Finds master-compatible glyphs with nodes that travel more than they should because they interpolate with a wrong node in the other master(s).",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight * 1.8

        self.w.travelPercentageText = vanilla.TextBox(
            (inset, linePos + 2.5, 190, 14),
            u"Acceptable travel ratio in percent:",
            sizeStyle='small',
            selectable=True)
        self.w.travelPercentage = vanilla.EditText(
            (inset + 190, linePos, -inset, 19),
            "50",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.travelPercentage.getNSTextField().setToolTip_(
            u"Anything above 50% is suspicious in a weight interpolation, and above 70% in a width interpolation. (100% is the diagonal of the bounding box of the path the node belongs to.)"
        )
        linePos += lineHeight

        self.w.includeNonExporting = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Include non-exporting glyphs (recommended)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeNonExporting.getNSButton().setToolTip_(
            u"Important if you are using non-exporting glyphs as components inside others, e.g., the slash in the oslash."
        )
        linePos += lineHeight

        self.w.normalizePathPosition = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Normalize path origin (recommended)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.normalizePathPosition.getNSButton().setToolTip_(
            u"Calculates node travel distances as if every path’s origin point were x=0, y=0."
        )
        linePos += lineHeight

        self.w.progress = vanilla.ProgressBar((inset, linePos, -inset, 16))
        self.w.progress.set(0)  # set progress indicator to zero
        linePos += lineHeight

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            "Find",
            sizeStyle='regular',
            callback=self.TravelTrackerMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print "Note: 'Travel Tracker' 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 = 330
        windowHeight = 375
        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
            "Vertical Metrics Manager",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.VerticalMetricsManager.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"Manage and sync hhea, typo and win values.",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.titleAscent = vanilla.TextBox((inset + 70, linePos + 4, 70, 14),
                                             u"Ascender",
                                             sizeStyle='small',
                                             selectable=True)
        self.w.titleDescent = vanilla.TextBox(
            (inset + 140, linePos + 4, 70, 14),
            u"Descender",
            sizeStyle='small',
            selectable=True)
        self.w.titleLineGap = vanilla.TextBox(
            (inset + 210, linePos + 4, 70, 14),
            u"Line Gap",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.titleWin = vanilla.TextBox((inset, linePos + 3, 70, 14),
                                          u"OS/2 usWin",
                                          sizeStyle='small',
                                          selectable=True)
        self.w.winAsc = vanilla.EditText((inset + 70, linePos, 65, 19),
                                         "",
                                         callback=self.SavePreferences,
                                         sizeStyle='small')
        self.w.winAsc.getNSTextField().setToolTip_(
            "OS/2 usWinAscent. Should be the maximum height in your font. Expect clipping or rendering artefacts beyond this point."
        )
        self.w.winDesc = vanilla.EditText((inset + 140, linePos, 65, 19),
                                          "",
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        self.w.winDesc.getNSTextField().setToolTip_(
            "OS/2 usWinDescent (unsigned integer). Should be the maximum depth in your font, like the lowest descender you have. Expect clipping or rendering artefacts beyond this point."
        )
        self.w.winGap = vanilla.EditText((inset + 210, linePos, 65, 19),
                                         "",
                                         callback=None,
                                         sizeStyle='small',
                                         readOnly=True,
                                         placeholder=u"n/a")
        self.w.winGap.getNSTextField().setToolTip_(
            "OS/2 usWinLineGap does not exist, hence greyed out here.")
        self.w.winUpdate = vanilla.SquareButton((inset + 280, linePos, 20, 19),
                                                u"↺",
                                                sizeStyle='small',
                                                callback=self.update)
        self.w.winUpdate.getNSButton().setToolTip_(
            "Will recalculate the OS/2 usWin values in the fields to the left. Takes the measurement settings below into account, except for the Limit options."
        )
        linePos += lineHeight

        self.w.titleTypo = vanilla.TextBox((inset, linePos + 3, 70, 14),
                                           u"OS/2 sTypo",
                                           sizeStyle='small',
                                           selectable=True)
        self.w.typoAsc = vanilla.EditText((inset + 70, linePos, 65, 19),
                                          "",
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        self.w.typoAsc.getNSTextField().setToolTip_(
            "OS/2 sTypoAscender (positive value), should be the same as hheaAscender. Should be the maximum height of the glyphs relevant for horizontal text setting in your font, like the highest accented uppercase letter, typically Aring or Ohungarumlaut. Used for first baseline offset in DTP and office apps and together with the line gap value, also in browsers."
        )
        self.w.typoDesc = vanilla.EditText((inset + 140, linePos, 65, 19),
                                           "",
                                           callback=self.SavePreferences,
                                           sizeStyle='small')
        self.w.typoDesc.getNSTextField().setToolTip_(
            "OS/2 sTypoDescender (negative value), should be the same as hheaDescender. Should be the maximum depth of the glyphs relevant for horizontal text setting in your font, like the lowest descender or bottom accent, typically Gcommaccent, Ccedilla, or one of the lowercase descenders (gjpqy). Together with the line gap value, used for line distance calculation in office apps and browsers."
        )
        self.w.typoGap = vanilla.EditText((inset + 210, linePos, 65, 19),
                                          "",
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        self.w.typoGap.getNSTextField().setToolTip_(
            "OS/2 sTypoLineGap (positive value), should be the same as hheaLineGap. Should be either zero or a value for padding between lines that makes sense visually. Office apps insert this distance between the lines, browsers add half on top and half below each line, also for determining text object boundaries."
        )
        self.w.typoUpdate = vanilla.SquareButton(
            (inset + 280, linePos, 20, 19),
            u"↺",
            sizeStyle='small',
            callback=self.update)
        self.w.typoUpdate.getNSButton().setToolTip_(
            "Will recalculate the OS/2 sTypo values in the fields to the left. Takes the measurement settings below into account."
        )
        linePos += lineHeight

        self.w.titleHhea = vanilla.TextBox((inset, linePos + 3, 70, 14),
                                           u"hhea",
                                           sizeStyle='small',
                                           selectable=True)
        self.w.hheaAsc = vanilla.EditText((inset + 70, linePos, 65, 19),
                                          "",
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        self.w.hheaAsc.getNSTextField().setToolTip_(
            "hheaAscender (positive value), should be the same as OS/2 sTypoAscender. Should be the maximum height of the glyphs relevant for horizontal text setting in your font, like the highest accented uppercase letter, typically Aring or Ohungarumlaut. Used for first baseline offset in Mac office apps and together with the line gap value, also in Mac browsers."
        )
        self.w.hheaDesc = vanilla.EditText((inset + 140, linePos, 65, 19),
                                           "",
                                           callback=self.SavePreferences,
                                           sizeStyle='small')
        self.w.hheaDesc.getNSTextField().setToolTip_(
            "hheaDescender (negative value), should be the same as OS/2 sTypoDescender. Should be the maximum depth of the glyphs relevant for horizontal text setting in your font, like the lowest descender or bottom accent, typically Gcommaccent, Ccedilla, or one of the lowercase descenders (gjpqy). Together with the line gap value, used for line distance calculation in office apps and browsers."
        )
        self.w.hheaGap = vanilla.EditText((inset + 210, linePos, 65, 19),
                                          "",
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        self.w.hheaGap.getNSTextField().setToolTip_(
            "hheaLineGap (positive value), should be the same as OS/2 sTypoLineGap. Should be either zero or a value for padding between lines that makes sense visually. Mac office apps insert this distance between the lines, Mac browsers add half on top and half below each line, also for determining text object boundaries."
        )
        self.w.hheaUpdate = vanilla.SquareButton(
            (inset + 280, linePos, 20, 19),
            u"↺",
            sizeStyle='small',
            callback=self.update)
        self.w.hheaUpdate.getNSButton().setToolTip_(
            "Will recalculate the hhea values in the fields to the left. Takes the measurement settings below into account."
        )
        linePos += lineHeight

        self.w.useTypoMetrics = vanilla.CheckBox(
            (inset + 70, linePos, -inset, 20),
            u"Use Typo Metrics (fsSelection bit 7)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.useTypoMetrics.getNSButton().setToolTip_(
            "Should ALWAYS BE ON. Only uncheck if you really know what you are doing. If unchecked, line behaviour will be not consistent between apps and browsers because some apps prefer win values to sTypo values for determining line distances."
        )
        self.w.useTypoMetricsUpdate = vanilla.SquareButton(
            (inset + 280, linePos, 20, 19),
            u"↺",
            sizeStyle='small',
            callback=self.update)
        self.w.useTypoMetricsUpdate.getNSButton().setToolTip_(
            "Will reset the checkbox to the left to ON, because it should ALWAYS be on. Strongly recommended."
        )
        linePos += lineHeight * 1.5

        self.w.descriptionMeasurements = vanilla.TextBox(
            (inset, linePos + 2, -inset, 14),
            u"Taking Measurements (see tooltips for info):",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.round = vanilla.CheckBox((inset, linePos, 70, 20),
                                        u"Round by:",
                                        value=True,
                                        callback=self.SavePreferences,
                                        sizeStyle='small')
        self.w.round.getNSButton().setToolTip_(
            "Turn on if you want your values rounded. Recommended.")
        self.w.roundValue = vanilla.EditText((inset + 75, linePos, 60, 19),
                                             "10",
                                             callback=self.SavePreferences,
                                             sizeStyle='small')
        self.w.roundValue.getNSTextField().setToolTip_(
            "All value calculations will be rounded up to the next multiple of this value. Recommended: 10."
        )
        linePos += lineHeight

        self.w.includeAllMasters = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Include all masters (otherwise current master only)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeAllMasters.getNSButton().setToolTip_(
            "If checked, all masters will be measured. If unchecked, only the current master will be measured. Since vertical metrics should be the same throughout all masters, it also makes sense to measure on all masters."
        )
        linePos += lineHeight

        self.w.ignoreNonExporting = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Ignore non-exporting glyphs",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.ignoreNonExporting.getNSButton().setToolTip_(
            "If checked, glyphs that do not export will be excluded from measuring. Recommended. (Ignored for calculating the OS/2 usWin values.)"
        )
        linePos += lineHeight

        self.w.preferSelectedGlyphs = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Limit to selected glyphs",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.preferSelectedGlyphs.getNSButton().setToolTip_(
            "If checked, only the current glyphs will be measured. Can be combined with the other Limit options. May make sense if you want your metrics to be e.g. Latin-CE-centric."
        )
        linePos += lineHeight

        self.w.preferScript = vanilla.CheckBox(
            (inset, linePos, inset + 110, 20),
            u"Limit to script:",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.preferScript.getNSButton().setToolTip_(
            "If checked, only measures glyphs belonging to the selected writing system. Can be combined with the other Limit options. (Ignored for calculating the OS/2 usWin values.)"
        )
        self.w.preferScriptPopup = vanilla.PopUpButton(
            (inset + 115, linePos + 1, -inset - 25, 17), (u"latin", u"greek"),
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.preferScriptPopup.getNSPopUpButton().setToolTip_(
            "Choose a writing system ('script') you want the measurements to be limited to. May make sense to ignore other scripts if the font is intended only for e.g. Cyrillic."
        )
        self.w.preferScriptUpdate = vanilla.SquareButton(
            (-inset - 20, linePos + 1, -inset, 18),
            u"↺",
            sizeStyle='small',
            callback=self.update)
        self.w.preferScriptUpdate.getNSButton().setToolTip_(
            "Update the script popup to the left with all scripts (writing systems) found in the current font."
        )
        linePos += lineHeight

        self.w.preferCategory = vanilla.CheckBox(
            (inset, linePos, inset + 110, 20),
            u"Limit to category:",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.preferCategory.getNSButton().setToolTip_(
            "If checked, only measures glyphs belonging to the selected glyph category. Can be combined with the other Limit options. (Ignored for calculating the OS/2 usWin values.)"
        )
        self.w.preferCategoryPopup = vanilla.PopUpButton(
            (inset + 115, linePos + 1, -inset - 25, 17),
            (u"Letter", u"Number"),
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.preferCategoryPopup.getNSPopUpButton().setToolTip_(
            "Choose a glyph category you want the measurements to be limited to. It may make sense to limit only to Letter."
        )
        self.w.preferCategoryUpdate = vanilla.SquareButton(
            (-inset - 20, linePos + 1, -inset, 18),
            u"↺",
            sizeStyle='small',
            callback=self.update)
        self.w.preferCategoryUpdate.getNSButton().setToolTip_(
            "Update the category popup to the left with all glyph categories found in the current font."
        )
        linePos += lineHeight

        # Run Button:
        self.w.helpButton = vanilla.HelpButton(
            (inset - 2, -20 - inset, 21, -inset + 2), callback=self.openURL)
        self.w.helpButton.getNSButton().setToolTip_(
            "Opens the Vertical Metrics tutorial (highly recommended) in your web browser."
        )

        self.w.runButton = vanilla.Button(
            (-120 - inset, -20 - inset, -inset, -inset),
            "Apply to Font",
            sizeStyle='regular',
            callback=self.VerticalMetricsManagerMain)
        self.w.runButton.getNSButton().setToolTip_(
            "Insert the OS/2, hhea and fsSelection values above as custom parameters in the font. The number values will be inserted into each master. Blank values will delete the respective parameters."
        )
        self.w.setDefaultButton(self.w.runButton)

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 8
0
def getEditText(lH=0):
    return vanilla.EditText(
        (leftMargin + scOffset, setLineHeight(lH), -leftMargin, 20),
        sizeStyle='small')
Ejemplo n.º 9
0
    def __init__(self, glyph):
        self.w = StatusInteractivePopUpWindow(
            (250, 0), centerInView=CurrentGlyphWindow().getGlyphView())

        metrics = dict(
            border=15,
            padding1=10,
            padding2=5,
            titleWidth=45,
            inputSpace=70,  # border + title + padding
            killButtonWidth=20,
            navigateButtonWidth=30,
            fieldHeight=22,
        )
        rules = [
            # Left
            "H:|-border-[leftTitle(==titleWidth)]-padding1-[leftField]-border-|",
            "H:|-inputSpace-[leftButton]-padding2-[leftKillButton(==killButtonWidth)]-border-|",
            "V:|-border-[leftTitle(==fieldHeight)]",
            "V:|-border-[leftField(==fieldHeight)]",
            "V:[leftField]-padding2-[leftButton]",
            "V:[leftField]-padding2-[leftKillButton(==leftButton)]",

            # Right
            "H:|-border-[rightTitle(==titleWidth)]-padding1-[rightField]-border-|",
            "H:|-inputSpace-[rightButton]-padding2-[rightKillButton(==killButtonWidth)]-border-|",
            "V:[leftButton]-padding1-[rightTitle(==fieldHeight)]",
            "V:[leftButton]-padding1-[rightField(==fieldHeight)]",
            "V:[rightField]-padding2-[rightButton]",
            "V:[rightField]-padding2-[rightKillButton(==rightButton)]",

            # Width
            "H:|-border-[widthTitle(==titleWidth)]-padding1-[widthField]-border-|",
            "H:|-inputSpace-[widthButton]-padding2-[widthKillButton(==killButtonWidth)]-border-|",
            "V:[rightButton]-padding1-[widthTitle(==fieldHeight)]",
            "V:[rightButton]-padding1-[widthField(==fieldHeight)]",
            "V:[widthField]-padding2-[widthButton]",
            "V:[widthField]-padding2-[widthKillButton(==rightButton)]",

            # Bottom
            "H:|-inputSpace-[line]-border-|",
            "H:|-inputSpace-[previousGlyphButton(==navigateButtonWidth)]-padding2-[nextGlyphButton(==navigateButtonWidth)]-padding1-[doneButton(>=0)]-border-|",
            "V:[widthButton]-padding1-[line]",
            "V:[line]-padding1-[previousGlyphButton]-border-|",
            "V:[line]-padding1-[nextGlyphButton]-border-|",
            "V:[line]-padding1-[doneButton]-border-|",
        ]

        self.w.leftTitle = vanilla.TextBox("auto", "Left:", alignment="right")
        self.w.leftField = vanilla.EditText("auto",
                                            "",
                                            continuous=False,
                                            callback=self.fieldCallback)
        self.w.leftButton = vanilla.Button("auto",
                                           "",
                                           callback=self.buttonCallback)
        self.w.leftKillButton = vanilla.ImageButton(
            "auto",
            imageNamed=NSImageNameStopProgressFreestandingTemplate,
            bordered=False,
            callback=self.buttonCallback)

        self.w.rightTitle = vanilla.TextBox("auto",
                                            "Right:",
                                            alignment="right")
        self.w.rightField = vanilla.EditText("auto",
                                             "",
                                             continuous=False,
                                             callback=self.fieldCallback)
        self.w.rightButton = vanilla.Button("auto",
                                            "",
                                            callback=self.buttonCallback)
        self.w.rightKillButton = vanilla.ImageButton(
            "auto",
            imageNamed=NSImageNameStopProgressFreestandingTemplate,
            bordered=False,
            callback=self.buttonCallback)

        self.w.widthTitle = vanilla.TextBox("auto",
                                            "Width:",
                                            alignment="right")
        self.w.widthField = vanilla.EditText("auto",
                                             "",
                                             continuous=False,
                                             callback=self.fieldCallback)
        self.w.widthButton = vanilla.Button("auto",
                                            "",
                                            callback=self.buttonCallback)
        self.w.widthKillButton = vanilla.ImageButton(
            "auto",
            imageNamed=NSImageNameStopProgressFreestandingTemplate,
            bordered=False,
            callback=self.buttonCallback)

        self.controlGroups = [
            dict(attr="leftMargin",
                 field=self.w.leftField,
                 button=self.w.leftButton,
                 kill=self.w.leftKillButton),
            dict(attr="rightMargin",
                 field=self.w.rightField,
                 button=self.w.rightButton,
                 kill=self.w.rightKillButton),
            dict(attr="width",
                 field=self.w.widthField,
                 button=self.w.widthButton,
                 kill=self.w.widthKillButton),
        ]
        for group in self.controlGroups:
            field = group["field"]
            button = group["button"]
            button.getNSButton().setAlignment_(NSLeftTextAlignment)

        self.w.line = vanilla.HorizontalLine("auto")
        self.w.doneButton = vanilla.Button("auto",
                                           "Close",
                                           callback=self.doneCallback)
        self.w.doneButton.bind(escapeCharacter, [])
        self.w.previousGlyphButton = vanilla.Button(
            "auto", "←", callback=self.previousGlyphCallback)
        self.w.previousGlyphButton.bind("[", ["command"])
        self.w.nextGlyphButton = vanilla.Button(
            "auto", "→", callback=self.nextGlyphCallback)
        self.w.nextGlyphButton.bind("]", ["command"])

        self.w.addAutoPosSizeRules(rules, metrics)

        self.loadGlyph()

        self.w.open()
Ejemplo n.º 10
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 390
        windowHeight = 290
        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.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 (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.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()
Ejemplo n.º 11
0
            font.glyphs[glyphName].layers.append(newLayer)

        # selectedLayer.setLeftMetricsKey_(sourceGlyphName+"*"+str(scaleFactor))
        # selectedLayer.setRightMetricsKey_(sourceGlyphName+"*"+str(scaleFactor))
        selectedLayer.setLeftMetricsKey_(sourceGlyphName)
        selectedLayer.setRightMetricsKey_(sourceGlyphName)

        selectedLayer.syncMetrics()

    Font.enableUpdateInterface()


w = vanilla.FloatingWindow((370, 260), "Generate Sups/Subs")

w.weight_label = getLabel("Weight gain: ", 0)
w.weight_text = vanilla.EditText(
    (leftMargin + scOffset, setLineHeight(0), 60, 20), sizeStyle='small')
w.weight_label2 = getLabel("% (L:~40, R:~20, B:~0)", 0, 153, 100)

w.offset_label = getLabel("Offset: ", 1)
w.offset_text = vanilla.EditText(
    (leftMargin + scOffset, setLineHeight(1), 60, 20), sizeStyle='small')

w.corr_label = getLabel("Correction Y: ", 2)
w.corr_text = vanilla.EditText(
    (leftMargin + scOffset, setLineHeight(2), 60, 20), sizeStyle='small')
w.corr2_label = getLabel("%", 2, 153)

w.figH_label = getLabel("Figures Height: ", 3)
w.figH_text = vanilla.EditText(
    (leftMargin + scOffset, setLineHeight(3), 60, 20), sizeStyle='small')
Ejemplo n.º 12
0
    def __init__(self):
        # Window 'self.w':
        editX = 180
        editY = 22
        textY = 17
        spaceX = 10
        spaceY = 10
        buttonSizeX = 60
        windowWidth = spaceX * 3 + editX * 2 + 85
        windowHeight = 260
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Copy Kerning Pairs",  # window title
            autosaveName=
            "com.Tosche.CopyKerningPairs.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.tabs = vanilla.Tabs((10, 10, -10, -20 - 30), ["Pair", "Preset"])
        tab1 = self.w.tabs[0]
        tab1.text0 = vanilla.TextBox((spaceX, 0, 260, textY),
                                     "Copy the kerning pair between...",
                                     sizeStyle='regular')
        tab1.editL0 = vanilla.EditText((spaceX, spaceY + textY, editX, editY),
                                       "",
                                       sizeStyle='regular',
                                       callback=self.checkField)
        tab1.editR0 = vanilla.EditText(
            (spaceX * 3 + editX + 20, spaceY + textY, editX, editY),
            "",
            sizeStyle='regular',
            callback=self.checkField)
        tab1.checkL0 = vanilla.TextBox(
            (spaceX + editX + 5, spaceY + textY + 2, 40, textY),
            u"Any",
            sizeStyle='regular')
        tab1.checkR0 = vanilla.TextBox(
            (spaceX * 3 + editX * 2 + 25, spaceY + textY + 2, 40, textY),
            u"Any",
            sizeStyle='regular')
        tab1.text1 = vanilla.TextBox(
            (spaceX, spaceY * 2 + textY + editY, 200, textY),
            "...to this pair",
            sizeStyle='regular')
        tab1.editL1 = vanilla.EditText(
            (spaceX, spaceY * 3 + textY * 2 + editY, editX, editY),
            "",
            sizeStyle='regular',
            callback=self.checkField)
        tab1.editR1 = vanilla.EditText(
            (spaceX * 3 + editX + 20, spaceY * 3 + textY * 2 + editY, editX,
             editY),
            "",
            sizeStyle='regular',
            callback=self.checkField)
        tab1.checkL1 = vanilla.TextBox(
            (spaceX + editX + 5, spaceY * 3 + textY * 2 + editY + 2, 40,
             textY),
            u"Any",
            sizeStyle='regular')
        tab1.checkR1 = vanilla.TextBox(
            (spaceX * 3 + editX * 2 + 25, spaceY * 3 + textY * 2 + editY + 2,
             40, textY),
            u"Any",
            sizeStyle='regular')
        tab1.text2 = vanilla.TextBox(
            (spaceX, spaceY * 5 + textY * 3 + editY, 400, textY * 2),
            "Groups will be automatically detected.\nYou can also type group name with @ prefix (e.g. @A)",
            sizeStyle='regular')

        tab2 = self.w.tabs[1]
        tab2.radio = vanilla.RadioGroup((spaceX, 2, 80, 78),
                                        ["Letter", "Numeral"],
                                        isVertical=True,
                                        sizeStyle='regular',
                                        callback=self.checkRadio)
        tab2.popLetter = vanilla.PopUpButton((spaceX + 100, spaceY, 320, 20), [
            "Caps to Small Caps", "Caps & Lowercase to Superscript",
            "Caps & Lowercase to Subscript", "Cap to Lowercase"
        ],
                                             sizeStyle='regular')
        tab2.popNum1 = vanilla.PopUpButton(
            (spaceX + 100, spaceY + 40, 140, 20), [
                "Lining Proportional", "Small Cap", "Numerator", "Denominator",
                "Superscript", "Subscript"
            ],
            sizeStyle='regular')
        tab2.popNum2 = vanilla.PopUpButton(
            (spaceX + 100 + 180, spaceY + 40, 140, 20), [
                "Lining Proportional", "Small Cap", "Numerator", "Denominator",
                "Superscript", "Subscript"
            ],
            sizeStyle='regular')
        tab2.textTo = vanilla.TextBox(
            (spaceX + 100 + 151, spaceY + 40, 20, textY),
            "to",
            sizeStyle='regular')
        tab2.textScale = vanilla.TextBox((spaceX, spaceY + 80, 100, textY),
                                         "Scale\t\t%",
                                         sizeStyle='regular')
        tab2.editScale = vanilla.EditText(
            (spaceX + 40, spaceY + 77, 40, editY), '100', sizeStyle='regular')
        tab2.textSkip = vanilla.TextBox(
            (spaceX + 120, spaceY + 80, 400, textY),
            "Ignore pair values smaller than         units",
            sizeStyle='regular')
        tab2.editSkip = vanilla.EditText(
            (spaceX + 321, spaceY + 77, 30, editY), '10', sizeStyle='regular')
        tab2.textNote = vanilla.TextBox(
            (spaceX, spaceY * 3 + textY + 76, 360, textY * 2),
            "It only copies pairs between the groups.\nBut regular punctuations and symbols are taken care of.",
            sizeStyle='regular')

        # Common:
        self.w.allMaster = vanilla.CheckBox((spaceX, -20 - 15, 100, -15),
                                            "All masters",
                                            sizeStyle='regular')
        self.w.runButton = vanilla.Button((-80 - 15, -20 - 15, -15, -15),
                                          "Run",
                                          sizeStyle='regular',
                                          callback=self.CopyKerningPairsMain)

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

        # Open window and focus on it:
        self.w.open()
        tab2.radio.set(0)
        tab2.popNum1.enable(False)
        tab2.popNum2.enable(False)
        self.w.makeKey()
Ejemplo n.º 13
0
    def window(self):
        self.w = vanilla.FloatingWindow((250, 180),
                                        "HT Letterspacer",
                                        minSize=(225, 180),
                                        maxSize=(225, 180),
                                        autosaveName="com.ht.spacer")
        self.w.text_3 = vanilla.TextBox((210, 25, -170, 14),
                                        "%",
                                        sizeStyle='small')
        self.w.text_4 = vanilla.TextBox((15, 50, 100, 14),
                                        "Area",
                                        sizeStyle='small')
        self.w.text_4b = vanilla.TextBox((120, 50, 50, 14),
                                         self.engine.paramArea,
                                         sizeStyle='small')
        self.w.text_5 = vanilla.TextBox((15, 75, 100, 14),
                                        "Depth",
                                        sizeStyle='small')
        self.w.text_5b = vanilla.TextBox((120, 75, 50, 14),
                                         self.engine.paramDepth,
                                         sizeStyle='small')
        self.w.text_6 = vanilla.TextBox((15, 100, 100, 14),
                                        "Overshoot",
                                        sizeStyle='small')
        self.w.text_6b = vanilla.TextBox((120, 100, 50, 14),
                                         self.engine.paramOver,
                                         sizeStyle='small')
        self.w.LSB = vanilla.CheckBox((15, 15, 40, 18),
                                      "LSB",
                                      value=True,
                                      sizeStyle='small',
                                      callback=self.SavePreferences)
        self.w.RSB = vanilla.CheckBox((15 + 45, 15, 40, 18),
                                      "RSB",
                                      value=True,
                                      sizeStyle='small',
                                      callback=self.SavePreferences)
        self.w.tab = vanilla.CheckBox((15 + 45 + 45, 15, 60, 18),
                                      "Tabular",
                                      value=False,
                                      sizeStyle='small',
                                      callback=self.SavePreferences)
        self.w.width = vanilla.EditText((170, 15, 40, 18),
                                        widthAvg(self.mySelection),
                                        sizeStyle='small')
        self.w.area = vanilla.EditText((170, 50 - 3, 40, 18),
                                       "430",
                                       sizeStyle='small')
        self.w.prof = vanilla.EditText((170, 75 - 3, 40, 18),
                                       "20",
                                       sizeStyle='small')
        self.w.ex = vanilla.EditText((170, 100 - 3, 40, 18),
                                     "0",
                                     sizeStyle='small')

        self.w.copyButton = vanilla.Button((15, 125, -90, 30),
                                           "Copy Parameters",
                                           sizeStyle='small',
                                           callback=self.copyParameters)
        self.w.runButton = vanilla.Button((-80, 125, -15, 30),
                                          "Apply",
                                          sizeStyle='small',
                                          callback=self.dialogCallback)

        self.w.setDefaultButton(self.w.runButton)

        if not self.LoadPreferences():
            GlyphsApp.Message(
                "Error :(",
                "Could not load preferences. Will resort to defaults.",
                OKButton="OK")

        self.w.open()
        self.w.makeKey()
Ejemplo n.º 14
0
    def __init__(self):
        edX = 40
        txX = 70
        sliderY = 18
        spX = 10
        axisX = 60
        windowWidth = 350
        windowHeight = 260
        windowWidthResize = 3000  # user can resize width by this value
        windowHeightResize = 3000  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Instance Slider",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.Tosche.InstanceSlider.mainwindow"  # stores last window position and size
        )

        YOffset = 27
        self.w.add = vanilla.Button((6, -YOffset, 24, 20),
                                    "+",
                                    callback=self.addDelButtons)
        self.w.delete = vanilla.Button((34, -YOffset, 24, 20),
                                       u"–",
                                       callback=self.addDelButtons)
        self.w.revert = vanilla.Button((62, -YOffset, 60, 20),
                                       "Revert",
                                       callback=self.revert)

        global av
        LineHeight = 26
        YOffset += LineHeight
        axisCount = len([v for v in av if v[0] != ""])

        self.w.textY = vanilla.TextBox((spX, -YOffset, txX, 14),
                                       "WeightY",
                                       sizeStyle='small')
        self.w.checkY = vanilla.CheckBox((txX - spX, -YOffset - 3, -10, 18),
                                         "",
                                         sizeStyle='small',
                                         callback=self.checkboxY,
                                         value=False)
        self.w.sliderY = vanilla.Slider(
            (spX + txX, -YOffset, -spX * 2 - edX, sliderY),
            minValue=av[0][1],
            maxValue=av[0][2],
            tickMarkCount=5,
            sizeStyle="small",
            callback=self.slide,
            continuous=True)
        self.w.editY = vanilla.EditText((-spX - edX, -YOffset, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.typeValue)
        YOffset += LineHeight

        move = -LineHeight * 2

        move -= LineHeight if axisCount == 6 else 0
        self.w.text5 = vanilla.TextBox((spX, move, txX, 14),
                                       av[5][0],
                                       sizeStyle='small')
        self.w.slider5 = vanilla.Slider(
            (spX + txX, move, -spX * 2 - edX, sliderY),
            minValue=av[5][1],
            maxValue=av[5][2],
            tickMarkCount=5,
            sizeStyle="small",
            callback=self.slide,
            continuous=True)
        self.w.edit5 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.typeValue)

        move -= LineHeight if axisCount >= 5 else 0
        self.w.text4 = vanilla.TextBox((spX, move, txX, 14),
                                       av[4][0],
                                       sizeStyle='small')
        self.w.slider4 = vanilla.Slider(
            (spX + txX, move, -spX * 2 - edX, sliderY),
            minValue=av[4][1],
            maxValue=av[4][2],
            tickMarkCount=5,
            sizeStyle="small",
            callback=self.slide,
            continuous=True)
        self.w.edit4 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.typeValue)

        move -= LineHeight if axisCount >= 4 else 0
        self.w.text3 = vanilla.TextBox((spX, move, txX, 14),
                                       av[3][0],
                                       sizeStyle='small')
        self.w.slider3 = vanilla.Slider(
            (spX + txX, move, -spX * 2 - edX, sliderY),
            minValue=av[3][1],
            maxValue=av[3][2],
            tickMarkCount=5,
            sizeStyle="small",
            callback=self.slide,
            continuous=True)
        self.w.edit3 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.typeValue)

        move -= LineHeight if axisCount >= 3 else 0
        self.w.text2 = vanilla.TextBox((spX, move, txX, 14),
                                       av[2][0],
                                       sizeStyle='small')
        self.w.slider2 = vanilla.Slider(
            (spX + txX, move, -spX * 2 - edX, sliderY),
            minValue=av[2][1],
            maxValue=av[2][2],
            tickMarkCount=5,
            sizeStyle="small",
            callback=self.slide,
            continuous=True)
        self.w.edit2 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.typeValue)

        move -= LineHeight if axisCount >= 2 else 0
        self.w.text1 = vanilla.TextBox((spX, move, txX, 14),
                                       av[1][0],
                                       sizeStyle='small')
        self.w.slider1 = vanilla.Slider(
            (spX + txX, move, -spX * 2 - edX, sliderY),
            minValue=av[1][1],
            maxValue=av[1][2],
            tickMarkCount=5,
            sizeStyle="small",
            callback=self.slide,
            continuous=True)
        self.w.edit1 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.typeValue)

        move -= LineHeight if axisCount >= 1 else 0
        self.w.text0 = vanilla.TextBox((spX, move, txX, 14),
                                       av[0][0],
                                       sizeStyle='small')
        self.w.slider0 = vanilla.Slider(
            (spX + txX, move, -spX * 2 - edX, sliderY),
            minValue=av[0][1],
            maxValue=av[0][2],
            tickMarkCount=5,
            sizeStyle="small",
            callback=self.slide,
            continuous=True)
        self.w.edit0 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.typeValue)

        YOffset += LineHeight * axisCount

        av = [v for v in av if v[0] != ""]
        axisElements = [
            [self.w.text0, self.w.slider0, self.w.edit0],
            [self.w.text1, self.w.slider1, self.w.edit1],
            [self.w.text2, self.w.slider2, self.w.edit2],
            [self.w.text3, self.w.slider3, self.w.edit3],
            [self.w.text4, self.w.slider4, self.w.edit4],
            [self.w.text5, self.w.slider5, self.w.edit5],
        ]

        for els in axisElements[len(av):]:
            els[0].show(False)
            els[1].show(False)
            els[2].show(False)

        self.usedAxisElements = axisElements[:len(av)]

        # TODO: disable WeightY if Weight doesn't exist
        if "Weight" not in [a[0] for a in av]:
            self.w.checkY.enable(False)

        columnTitles = [{
            "title": "Instance",
            "width": self.w.getPosSize()[2] - axisX * (len(av) + 1)
        }]
        for i in range(len(av)):
            columnTitles += [{"title": av[i][0], "width": axisX}]

        self.w.list = vanilla.List((0, 0, -0, -(YOffset - 18)),
                                   insList,
                                   selectionCallback=self.listClick,
                                   allowsMultipleSelection=False,
                                   allowsEmptySelection=False,
                                   columnDescriptions=columnTitles)
        self.w.list._nsObject.setBorderType_(NSNoBorder)
        tableView = self.w.list._tableView
        tableView.setAllowsColumnReordering_(False)
        tableView.unbind_(
            "sortDescriptors")  # Disables sorting by clicking the title bar
        for i in range(len(av)):
            if i == 0:
                tableView.tableColumns()[i].setResizingMask_(1)
            else:
                tableView.tableColumns()[i].setResizingMask_(0)
            # setResizingMask_() 0=Fixed, 1=Auto-Resizable (Not user-resizable). There may be more options?

        tableView.setColumnAutoresizingStyle_(5)
        # AutoresizingStyle:
        # 0 Disable table column autoresizing.
        # 1 Autoresize all columns by distributing space equally, simultaneously.
        # 2 Autoresize each table column sequentially, from the last auto-resizable column to the first auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size.
        # 3 Autoresize each table column sequentially, from the first auto-resizable column to the last auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size.
        # 4 Autoresize only the last table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead.
        # 5 Autoresize only the first table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead.

        self.w.line = vanilla.HorizontalLine((0, -(YOffset - 18), -0, 1))
        self.w.open()
        self.w.makeKey()

        # initialisation:
        # set the first instance in preview if there is an instance
        # set the slider and text
        # set preview area if closed
        # redraw
        uiList = self.w.list

        if len(f.instances) > 0:
            if f.currentTab == None:
                f.newTab("HALOGEN halogen 0123")
            if f.currentTab.previewHeight <= 20.0:
                f.currentTab.previewHeight = 150
            self.setupSliders(0, uiList[0])
    def __init__(self):
        self.Tool = GlyphsPathPlugin.alloc().init()

        # Window 'self.w':
        windowWidth = 300
        windowHeight = 245
        windowWidthResize = 300  # 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
            "Green Blue Manager",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.GreenBlueManager.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight = 5, 15, 22
        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, lineHeight * 2),
            u"Validates the connection state of nodes, green vs. blue, according to the angle between them. Optionally corrects green/blue state and handles.",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight * 2.5

        self.w.thresholdAngleText = vanilla.TextBox((inset, linePos, 110, 14),
                                                    u"Threshold Angle:",
                                                    sizeStyle='small',
                                                    selectable=True)
        self.w.thresholdAngle = vanilla.EditText(
            (inset + 110, linePos - 2, -inset, 19),
            "11",
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.completeFont = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Process complete font (otherwise selection)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.completeFont.getNSButton().setToolTip_(
            "If checked, will go through all active (i.e., master, brace and bracket) layers of all glyphs. If unchecked, will only go through selected layers. Careful: can take a minute."
        )
        linePos += lineHeight

        self.w.fixGreenBlue = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Fix green vs. blue connection for on-curves",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.fixGreenBlue.getNSButton().setToolTip_(
            "Sets the green/blue state of an on-curve node according to the connection angle. Any connection below the threshold angle will be green, otherwise blue. Deselect both Fix and Realign options for a new tab with all glyphs that have nodes with wrong connections according to the threshold angle."
        )
        linePos += lineHeight

        self.w.realignHandles = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Realign handles attached to green nodes",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.realignHandles.getNSButton().setToolTip_(
            "If a BCP (grey handle) follows a green node, it will be aligned to the previous two points. Deselect both Fix and Realign options for a new tab with all glyphs that have nodes with wrong connections according to the threshold angle."
        )
        linePos += lineHeight

        self.w.reportInMacroWindow = vanilla.CheckBox(
            (inset, linePos - 1, 160, 20),
            u"Report in Macro window",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.reportInMacroWindowVerbose = vanilla.CheckBox(
            (inset + 160, linePos - 1, -inset, 20),
            u"Verbose",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.reportInMacroWindow.getNSButton().setToolTip_(
            "If enabled, will output a report in Window > Macro Panel.")
        self.w.reportInMacroWindowVerbose.getNSButton().setToolTip_(
            "If enabled, will output a verbose (detailed) report in Window > Macro Panel."
        )
        linePos += lineHeight

        self.w.progress = vanilla.ProgressBar((inset, linePos, -inset, 16))
        self.w.progress.set(0)  # set progress indicator to zero
        linePos += lineHeight

        self.w.processingText = vanilla.TextBox(
            (inset, linePos + 2, -120 - inset, 14),
            u"",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-120 - inset, -20 - inset, -inset, -inset),
            "Treat Points",
            sizeStyle='regular',
            callback=self.GreenBlueManagerMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print "Note: 'Set Green Or Blue According To Angle' could not load preferences. Will resort to defaults"

        self.checkGUI()

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 16
0
	def __init__( self ):
		self.listOfMasters = []
		self.updateListOfMasters() 
		
		# Window 'self.w':
		windowWidth  = 400
		windowHeight = 220
		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
			"Steal Metrics", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.MetricsCopy.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 two fonts and select glyphs in the target font.", sizeStyle='small', selectable=True )
		linePos += lineHeight
		
		
		self.w.text_anchor = vanilla.TextBox( (inset, linePos+2, 130, 17), "Transfer metrics from:", sizeStyle='small')
		self.w.from_font = vanilla.PopUpButton( (inset+130, linePos, -inset, 17), self.listOfMasterNames(), sizeStyle='small', callback=self.buttonCheck)
		
		linePos += lineHeight
		self.w.text_value = vanilla.TextBox( (inset, linePos+2, 130, 17), "To selected glyphs in:", sizeStyle='small')
		self.w.to_font = vanilla.PopUpButton( (inset+130, linePos, -inset, 17), self.listOfMasterNames()[::-1], sizeStyle='small', callback=self.buttonCheck)
		
		linePos += lineHeight
		self.w.lsb   = vanilla.CheckBox( ( inset, linePos-1, 80, 20), "LSB", value=True, callback=self.buttonCheck, sizeStyle='small' )
		self.w.rsb   = vanilla.CheckBox( ( inset+80, linePos-1, 80, 20), "RSB", value=True, callback=self.buttonCheck, sizeStyle='small' )
		self.w.width = vanilla.CheckBox( ( inset+80*2, linePos-1, 80, 20), "Width", value=False, callback=self.buttonCheck, sizeStyle='small' )
		self.w.lsb.getNSButton().setToolTip_("If enabled, will transfer values for left sidebearings.")
		self.w.rsb.getNSButton().setToolTip_("If enabled, will transfer values for right sidebearings.")
		self.w.width.getNSButton().setToolTip_("If enabled, will transfer values for advance widths.")
		
		
		linePos += lineHeight
		self.w.preferMetricKeys  = vanilla.CheckBox( (inset, linePos, -inset, 20), "Prefer (glyph and layer) metrics keys whenever available", value=False, sizeStyle='small', callback=self.buttonCheck )
		self.w.preferMetricKeys.getNSButton().setToolTip_("If enabled, will transfer the metrics key rather than the metric value, if a metrics key is persent in the source font.")
		
		linePos += lineHeight
		self.w.onlyMetricsKeys = vanilla.CheckBox( (inset*2, linePos-1, -inset, 20), u"Only transfer metrics keys (ignore LSB, RSB, Width)", value=False, callback=self.buttonCheck, sizeStyle='small' )
		self.w.onlyMetricsKeys.enable(False)
		self.w.onlyMetricsKeys.getNSButton().setToolTip_("If enabled, will only transfer metrics keys and not change any metric values. The checkboxes for LSB, RSB and Width will be disabled.")
		
		linePos += lineHeight
		self.w.ignoreSuffixes    = vanilla.CheckBox( (inset, linePos, 190, 20), "Ignore dotsuffix in source glyph:", value=False, sizeStyle='small', callback=self.buttonCheck )
		self.w.suffixToBeIgnored = vanilla.EditText( (inset+190, linePos, -inset, 20), ".alt", sizeStyle = 'small')
		self.w.suffixToBeIgnored.getNSTextField().setToolTip_(u"Will copy metrics from source glyph ‘eacute’ to target glyph ‘eacute.xxx’. Useful for transfering metrics to dotsuffixed glyph variants.")
		
		self.w.copybutton = vanilla.Button((-80-inset, -20-inset, -inset, -inset), "Transfer", sizeStyle='small', callback=self.copyMetrics)
		self.w.setDefaultButton( self.w.copybutton )
		
		if not self.LoadPreferences( ):
			self.outputError( "Could not load preferences at startup. Will resort to defaults." )
		
		self.w.open()
		self.w.makeKey()
		
		self.buttonCheck( None )
Ejemplo n.º 17
0
    def __init__(self):

        self.w = vanilla.Window(
            (self.windowWidth, self.windowHeight),
            "Export OTF and TTF into Subfolder",
            minSize=(self.windowWidth, self.windowHeight),
            maxSize=(self.windowWidth, self.windowHeight),
            autosaveName="com.harbortype.exportOtfTtf.mainwindow")

        fontName = NSAttributedString.alloc().initWithString_attributes_(
            "File: " + os.path.basename(Glyphs.font.filepath), self.attributes)
        self.w.currentFont = vanilla.TextBox(
            (self.margin, self.margin - 10, -self.margin, self.line),
            fontName,
            alignment="right")
        self.currentLine += self.line

        self.w.subfolder_title = vanilla.TextBox(
            (self.margin, self.margin + self.currentLine, 80, self.line),
            "Subfolder: ")
        self.w.subfolder = vanilla.EditText(
            (self.margin + 80, self.margin + self.currentLine - 3,
             -self.margin, self.line), )
        self.currentLine += self.line + 13

        self.w.allOpenFonts = vanilla.CheckBox(
            (self.margin, self.margin + self.currentLine, self.column,
             self.line),
            "All open fonts",
            callback=self.savePreferences)

        self.currentLine += self.line + 13

        self.w.line = vanilla.VerticalLine(
            (self.windowWidth / 2, self.margin + self.currentLine, 1,
             self.line * 3))

        self.w.otf = vanilla.CheckBox(
            (self.margin, self.margin + self.currentLine, self.column,
             self.line),
            "Export OTF",
            callback=self.savePreferences)
        self.currentLine += self.line
        self.w.otfRemoveOverlaps = vanilla.CheckBox(
            (self.margin * 2, self.margin + self.currentLine, self.column,
             self.line),
            "Remove overlaps",
            callback=self.savePreferences)
        self.currentLine += self.line
        self.w.otfAutohint = vanilla.CheckBox(
            (self.margin * 2, self.margin + self.currentLine, self.column,
             self.line),
            "Autohint",
            callback=self.savePreferences)
        self.currentLine -= self.line * 2

        self.w.ttf = vanilla.CheckBox(
            (self.margin * 3 + self.column, self.margin + self.currentLine,
             self.column, self.line),
            "Export TTF",
            callback=self.savePreferences)
        self.currentLine += self.line
        self.w.ttfRemoveOverlaps = vanilla.CheckBox(
            (self.margin * 4 + self.column, self.margin + self.currentLine,
             self.column, self.line),
            "Remove overlaps",
            callback=self.savePreferences)
        self.currentLine += self.line
        self.w.ttfAutohint = vanilla.CheckBox(
            (self.margin * 4 + self.column, self.margin + self.currentLine,
             self.column, self.line),
            "Autohint",
            callback=self.savePreferences)
        self.currentLine += self.line * 1.5

        self.w.progress = vanilla.ProgressBar(
            (self.margin, self.margin + self.currentLine,
             self.windowWidth - self.margin * 2, 16), )
        self.w.progress.set(0)  # set progress indicator to zero

        self.w.closeButton = vanilla.Button(
            (self.margin, -self.margin - self.line,
             self.windowWidth - self.margin * 2, self.line),
            "Cancel",
            callback=self.closeWindow)
        self.w.runButton = vanilla.Button(
            (self.margin, -self.margin - self.line * 2 - 8,
             self.windowWidth - self.margin * 2, self.line),
            "Export fonts",
            callback=self.export)

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

        self.w.setDefaultButton(self.w.runButton)
        try:
            # Python 3
            self.w.closeButton.bind(chr(27), [])
        except:
            # Python 2
            self.w.closeButton.bind(unichr(27), [])
        self.w.open()
        self.w.makeKey()
    def __init__(self):
        # Window 'self.w':
        windowWidth = 355
        windowHeight = 345
        windowWidthResize = 600  # 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
            "Straight Stem Cruncher",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.StraightStemCruncher.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"In current master, looks for stems close but not exactly at:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.stemsText = vanilla.TextBox((inset, linePos + 3, 80, 14),
                                           u"Stem Widths:",
                                           sizeStyle='small',
                                           selectable=True)
        self.w.stems = vanilla.EditText((inset + 80, linePos, -inset - 25, 19),
                                        "20, 30, 40",
                                        callback=self.SavePreferences,
                                        sizeStyle='small')
        self.w.stems.getNSTextField().setToolTip_(
            "Comma-separated list of stem sizes to look for. If the script finds stems deviating from these sizes, within the given min/max deviations, it will report them."
        )
        self.w.stemUpdate = vanilla.SquareButton(
            (-inset - 20, linePos, -inset, 19),
            u"↺",
            sizeStyle='small',
            callback=self.update)
        self.w.stemUpdate.getNSButton().setToolTip_(
            "Populate the stems with the stems of the current master.")
        linePos += lineHeight

        self.w.stemFindText = vanilla.TextBox(
            (inset, linePos + 3, 175, 14),
            u"Find deviating stems, min/max:",
            sizeStyle='small',
            selectable=True)
        self.w.deviationMin = vanilla.EditText((inset + 175, linePos, 45, 19),
                                               "0.4",
                                               callback=self.SavePreferences,
                                               sizeStyle='small')
        self.w.deviationMin.getNSTextField().setToolTip_(
            "Deviations up to this value will be tolerated. Half a unit is a good idea to avoid false positives from rounding errors."
        )
        self.w.deviationMax = vanilla.EditText(
            (inset + 175 + 55, linePos, 45, 19),
            "3.1",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.deviationMax.getNSTextField().setToolTip_(
            "Deviations up to this value will be reported. Do not exaggerate value, otherwise you get false positives from cases where the opposing segment is not the other side of the stem."
        )
        linePos += lineHeight

        self.w.minimumSegmentLengthText = vanilla.TextBox(
            (inset, linePos + 2, 145, 14),
            u"Minimum segment length:",
            sizeStyle='small',
            selectable=True)
        self.w.minimumSegmentLength = vanilla.EditText(
            (inset + 145, linePos, -inset - 25, 19),
            "200",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.minimumSegmentLength.getNSTextField().setToolTip_(
            "Looks for straight-line segments with at least this length and measures from their center to the opposing segment. Half x-height is a good idea."
        )
        self.w.segmentLengthUpdate = vanilla.SquareButton(
            (-inset - 20, linePos, -inset, 19),
            u"↺",
            sizeStyle='small',
            callback=self.update)
        self.w.segmentLengthUpdate.getNSButton().setToolTip_(
            "Reset to 40% of x-height.")
        linePos += lineHeight

        self.w.ignoreDiagonals = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Ignore diagonal stems",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.ignoreDiagonals.getNSButton().setToolTip_(
            "If activated, only measures completely horizontal and completely vertical segments."
        )
        linePos += lineHeight

        self.w.checkSpecialLayers = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Also check bracket layers",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.checkSpecialLayers.getNSButton().setToolTip_(
            "If checked, also measures on bracket ayers. Otherwise only on master layers."
        )
        linePos += lineHeight

        self.w.selectedGlyphsOnly = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Measure selected glyphs only (otherwise all glyphs in font)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.selectedGlyphsOnly.getNSButton().setToolTip_(
            "Uncheck for measuring complete font.")
        linePos += lineHeight

        self.w.includeNonExporting = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Include non-exporting glyphs",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeNonExporting.getNSButton().setToolTip_(
            "Usually not necessary because the algorithm decomposes and removes overlap first."
        )
        linePos += lineHeight

        self.w.includeCompounds = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Include components",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeCompounds.getNSButton().setToolTip_(
            "If checked, also measures components (after decomposition and removing overlap). If unchecked, only measures outlines."
        )
        linePos += lineHeight

        self.w.excludeGlyphs = vanilla.CheckBox((inset, linePos, 165, 20),
                                                u"Exclude glyphs containing:",
                                                value=False,
                                                callback=self.SavePreferences,
                                                sizeStyle='small')
        self.w.excludeGlyphNames = vanilla.EditText(
            (inset + 165, linePos, -inset - 25, 19),
            self.defaultExcludeList,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.excludeGlyphNames.getNSTextField().setToolTip_(
            "Comma-separated list of glyph name parts (e.g., suffixes). Glyphs containing these will not be measured if checkbox is enabled."
        )
        self.w.excludeGlyphNamesReset = vanilla.SquareButton(
            (-inset - 20, linePos, -inset, 19),
            u"↺",
            sizeStyle='small',
            callback=self.update)
        self.w.excludeGlyphNamesReset.getNSButton().setToolTip_(
            "Reset to: %s." % self.defaultExcludeList)
        linePos += lineHeight

        self.w.reportNonMeasurements = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Report layers without measurements",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.reportNonMeasurements.getNSButton().setToolTip_(
            "In Macro Window, report if a layer does not have any measurements. Most likely causes: no straight stems in the paths, or wrong path direction."
        )
        linePos += lineHeight

        self.w.openTab = vanilla.CheckBox((inset, linePos, -inset, 20),
                                          u"Open tab with affected glyphs",
                                          value=True,
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        self.w.openTab.getNSButton().setToolTip_(
            "If unchecked, will bring macro window with detailed report to front."
        )
        linePos += lineHeight

        self.w.progress = vanilla.ProgressBar((inset, linePos, -inset, 16))
        self.w.progress.set(0)  # set progress indicator to zero
        linePos += lineHeight

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 19
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 400
        windowHeight = 260
        windowWidthResize = 300  # 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
            "Spacing Checker",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.SpacingChecker.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),
            "Find glyphs with unusual sidebearings. Open tab with glyphs where:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.asymmetricSBs = vanilla.CheckBox((inset, linePos, -inset, 20),
                                                "LSB & RSB differ more than:",
                                                value=False,
                                                callback=self.SavePreferences,
                                                sizeStyle='small')
        self.w.asymmetricDifference = vanilla.EditText(
            (inset + 170, linePos, -inset - 35, 19),
            "50",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.asymmetricUpdateButton = vanilla.SquareButton(
            (-inset - 30, linePos + 0.5, -inset, 18),
            u"↺ K",
            sizeStyle='small',
            callback=self.updateValues)
        self.w.asymmetricUpdateButton.getNSButton().setToolTip_(
            "Update the entry with the measurements for uppercase K, presumably the largest difference in most designs."
        )
        linePos += lineHeight

        self.w.largeLSB = vanilla.CheckBox((inset, linePos, -inset, 20),
                                           "LSBs larger than:",
                                           value=False,
                                           callback=self.SavePreferences,
                                           sizeStyle='small')
        self.w.lsbThreshold = vanilla.EditText(
            (inset + 110, linePos, -inset - 35, 19),
            "70",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.lsbThresholdUpdateButton = vanilla.SquareButton(
            (-inset - 30, linePos + 0.5, -inset, 18),
            u"↺ H",
            sizeStyle='small',
            callback=self.updateValues)
        self.w.lsbThresholdUpdateButton.getNSButton().setToolTip_(
            "Update the entry with the measurements for uppercase H, presumably the largest LSB in most designs."
        )
        linePos += lineHeight

        self.w.largeRSB = vanilla.CheckBox((inset, linePos, -inset, 20),
                                           "RSBs larger than:",
                                           value=False,
                                           callback=self.SavePreferences,
                                           sizeStyle='small')
        self.w.rsbThreshold = vanilla.EditText(
            (inset + 110, linePos, -inset - 35, 19),
            "70",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.rsbThresholdUpdateButton = vanilla.SquareButton(
            (-inset - 30, linePos + 0.5, -inset, 18),
            u"↺ H",
            sizeStyle='small',
            callback=self.updateValues)
        self.w.rsbThresholdUpdateButton.getNSButton().setToolTip_(
            "Update the entry with the measurements for uppercase H, presumably the largest RSB in most designs."
        )
        linePos += lineHeight

        self.w.whiteGlyphs = vanilla.CheckBox((inset, linePos, 180, 20),
                                              "LSB+RSB make up more than:",
                                              value=False,
                                              callback=self.SavePreferences,
                                              sizeStyle='small')
        self.w.whitePercentage = vanilla.EditText(
            (inset + 180, linePos, -inset - 100, 19),
            "50",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.whiteGlyphsText = vanilla.TextBox(
            (-inset - 100, linePos + 3, -inset, 14),
            "% of overall width",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.includeBraceAndBracketLayers = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            "Include brace and bracket layers",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.allMasters = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            "Look on all masters (otherwise current master only)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.ignoreNonexportingGlyphs = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Ignore glyphs that do not export",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.progress = vanilla.ProgressBar((inset, linePos, -inset, 16))
        self.w.progress.set(0)  # set progress indicator to zero
        linePos += lineHeight

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 20
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 320
        windowHeight = 490
        windowWidthResize = 300  # 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
            "Find Near Vertical Misses",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.FindNearVerticalMisses.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"Find glyphs with nodes not exactly on vertical metrics:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.devianceText = vanilla.TextBox(
            (inset, linePos + 3, inset + 135, 14),
            u"Find nodes off by up to:",
            sizeStyle='small',
            selectable=True)
        self.w.deviance = vanilla.EditText((inset + 135, linePos, -inset, 19),
                                           "1",
                                           callback=self.SavePreferences,
                                           sizeStyle='small')
        self.w.deviance.getNSTextField().setToolTip_(
            u"Finds nodes that are not equal to the metric, but off up to this value in units. Minimum: 1 unit."
        )
        linePos += lineHeight

        # BOX
        linePos += int(lineHeight // 2)
        self.w.whereToCheck = vanilla.Box(
            (inset, linePos, -inset, int(lineHeight * 7.6)))
        insetLinePos = int(inset * 0.2)

        self.w.whereToCheck.ascender = vanilla.CheckBox(
            (int(0.5 * inset), insetLinePos - 1, -inset, 20),
            u"Ascender (caps ignored)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.whereToCheck.ascender.getNSButton().setToolTip_(
            u"Checks if points are not exactly on, but just off the ascender of the corresponding master."
        )
        linePos += lineHeight
        insetLinePos += lineHeight

        self.w.whereToCheck.capHeight = vanilla.CheckBox(
            (int(0.5 * inset), insetLinePos - 1, -inset, 20),
            u"Cap Height (lowercase ignored)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.whereToCheck.capHeight.getNSButton().setToolTip_(
            u"Checks if points are not exactly on, but just off the capHeight of the corresponding master."
        )
        linePos += lineHeight
        insetLinePos += lineHeight

        self.w.whereToCheck.shoulderHeight = vanilla.CheckBox(
            (int(0.5 * inset), insetLinePos - 1, -inset, 20),
            u"shoulderHeight (UC, LC, SC ignored)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.whereToCheck.shoulderHeight.getNSButton().setToolTip_(
            u"Checks if points are not exactly on, but just off the shoulderHeight of the corresponding master."
        )
        linePos += lineHeight
        insetLinePos += lineHeight

        self.w.whereToCheck.smallCapHeight = vanilla.CheckBox(
            (int(0.5 * inset), insetLinePos - 1, -inset, 20),
            u"smallCapHeight (only considers smallcaps)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.whereToCheck.smallCapHeight.getNSButton().setToolTip_(
            u"Checks if points are not exactly on, but just off the smallCapHeight of the corresponding master."
        )
        linePos += lineHeight
        insetLinePos += lineHeight

        self.w.whereToCheck.xHeight = vanilla.CheckBox(
            (int(0.5 * inset), insetLinePos - 1, -inset, 20),
            u"x-height (caps ignored)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.whereToCheck.xHeight.getNSButton().setToolTip_(
            u"Checks if points are not exactly on, but just off the xHeight of the corresponding master."
        )
        linePos += lineHeight
        insetLinePos += lineHeight

        self.w.whereToCheck.baseline = vanilla.CheckBox(
            (int(0.5 * inset), insetLinePos - 1, -inset, 20),
            u"Baseline",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.whereToCheck.baseline.getNSButton().setToolTip_(
            u"Checks if points are not exactly on, but just off the baseline of the corresponding master."
        )
        linePos += lineHeight
        insetLinePos += lineHeight

        self.w.whereToCheck.descender = vanilla.CheckBox(
            (int(0.5 * inset), insetLinePos - 1, -inset, 20),
            u"Descender",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.whereToCheck.descender.getNSButton().setToolTip_(
            u"Checks if points are not exactly on, but just off the descender of the corresponding master."
        )
        linePos += lineHeight
        insetLinePos += lineHeight

        linePos += lineHeight
        # BOX END

        self.w.tolerateIfNextNodeIsOn = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Tolerate near miss if next node is on",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.tolerateIfNextNodeIsOn.getNSButton().setToolTip_(
            "Will skip the just-off node if the next or previous on-curve node is EXACTLY on the metric line. Useful if you have very thin serifs or short segments near the metric lines."
        )
        linePos += lineHeight

        self.w.tolerateIfExtremum = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Tolerate near miss for left/right curve extremum",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.tolerateIfExtremum.getNSButton().setToolTip_(
            "Will skip the just-off node if the next and previous nodes are VERTICAL OFF-CURVES. Recommended for avoiding false positives."
        )
        linePos += lineHeight

        self.w.includeHandles = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Include off-curve points",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeHandles.getNSButton().setToolTip_(
            u"Also checks BCPs (Bézier control points), vulgo ‘handles’. Otherwise only considers on-curve nodes"
        )
        linePos += lineHeight

        self.w.includeNonExporting = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Include non-exporting glyphs",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeNonExporting.getNSButton().setToolTip_(
            u"Also check for near misses in glyphs that are set to not export. Useful if you are using non-exporting parts as components in other glyphs."
        )
        linePos += lineHeight

        self.w.removeOverlap = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Check outlines after Remove Overlap (slower)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.removeOverlap.getNSButton().setToolTip_(
            u"Only checks outlines after overlap removal. That way, ignores triangular overlaps (‘opened corners’). Use this option if you have too many false positives."
        )
        linePos += lineHeight

        self.w.markNodes = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Mark affected nodes with %s" % self.marker,
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.markNodes.getNSButton().setToolTip_(
            u"Sets the name of affected nodes to this emoji, so you can easily find it. ATTENTION: If Remove Overlap option is on, will use the emoji as an annotation instead."
        )
        linePos += lineHeight

        self.w.excludeText = vanilla.TextBox((inset, linePos + 3, 150, 14),
                                             u"Exclude glyphs containing:",
                                             sizeStyle='small',
                                             selectable=True)
        self.w.exclude = vanilla.EditText((inset + 150, linePos, -inset, 19),
                                          ".ornm, .notdef",
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        linePos += lineHeight

        self.w.openTab = vanilla.CheckBox((inset, linePos - 1, -inset, 20),
                                          u"Open tab with affected layers",
                                          value=True,
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        self.w.openTab.getNSButton().setToolTip_(
            u"If it finds nodes just off the indicated metrics, will open a new tab with the layers if found the deviating nodes on. Otherwise please check the detailed report in Macro Window."
        )
        linePos += lineHeight

        self.w.progress = vanilla.ProgressBar((inset, linePos, -inset, 16))
        self.w.progress.set(0)  # set progress indicator to zero
        linePos += lineHeight

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            "Find",
            sizeStyle='regular',
            callback=self.FindNearVerticalMissesMain)
        self.w.setDefaultButton(self.w.runButton)

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 21
0
    def __init__(self):
        self.mostImportantObjects = [
            "GSLayer", "GSAlignmentZone", "GSAnchor", "GSAnnotation",
            "GSApplication", "GSBackgroundImage", "GSClass", "GSComponent",
            "GSCustomParameter", "GSEditViewController", "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)
Ejemplo n.º 22
0
    def __init__(self):
        self.w = vanilla.FloatingWindow((320, 95), "Rotate around anchor")

        self.w.anchor_text = vanilla.TextBox((15, 15, 120, 15),
                                             "Set 'rotate' anchor to:",
                                             sizeStyle='small')
        self.w.anchor_x = vanilla.EditText((15 + 125, 15 - 3, 40, 15 + 3),
                                           "0",
                                           sizeStyle='small')
        self.w.anchor_y = vanilla.EditText((15 + 125 + 45, 15 - 3, 40, 15 + 3),
                                           "0",
                                           sizeStyle='small')
        self.w.anchor_button = vanilla.Button((-80, 15, -15, 15 - 3),
                                              "Set",
                                              sizeStyle='small',
                                              callback=self.setRotateAnchor)

        self.w.rotate_text1 = vanilla.TextBox((15, 40, 55, 15),
                                              "Rotate by",
                                              sizeStyle='small')
        self.w.rotate_degrees = vanilla.EditText((15 + 60, 40 - 3, 35, 15 + 3),
                                                 "10",
                                                 sizeStyle='small',
                                                 callback=self.SavePreferences)
        self.w.rotate_text2 = vanilla.TextBox((15 + 60 + 40, 40, 50, 15),
                                              "degrees:",
                                              sizeStyle='small')
        self.w.rotate_ccw = vanilla.Button((-150, 40, -85, 15 - 3),
                                           u"↺ ccw",
                                           sizeStyle='small',
                                           callback=self.rotate)
        self.w.rotate_cw = vanilla.Button((-80, 40, -15, 15 - 3),
                                          u"↻ cw",
                                          sizeStyle='small',
                                          callback=self.rotate)

        self.w.stepAndRepeat_text1 = vanilla.TextBox((15, 65, 55, 15),
                                                     "Repeat",
                                                     sizeStyle='small')
        self.w.stepAndRepeat_times = vanilla.EditText(
            (15 + 60, 65 - 3, 35, 15 + 3),
            "5",
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.stepAndRepeat_text2 = vanilla.TextBox(
            (15 + 60 + 40, 65, 50, 15), "times:", sizeStyle='small')
        self.w.stepAndRepeat_ccw = vanilla.Button((-150, 65, -85, 15 - 3),
                                                  u"↺+ ccw",
                                                  sizeStyle='small',
                                                  callback=self.rotate)
        self.w.stepAndRepeat_cw = vanilla.Button((-80, 65, -15, 15 - 3),
                                                 u"↻+ cw",
                                                 sizeStyle='small',
                                                 callback=self.rotate)

        if not self.LoadPreferences():
            self.logToConsole(
                "Rotate: Could not load prefs, will resort to defaults.")
        self.setDefaultRotateAnchor()
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 23
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 250
        windowHeight = 185
        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
            "Pixelate",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.Pixelate.mainwindow"  # stores last window position and size
        )

        # UI elements:

        self.w.pixelRasterText = vanilla.TextBox((15 - 1, 12 + 2, 140, 14),
                                                 "Pixel grid step",
                                                 sizeStyle='small')
        self.w.pixelRasterWidth = vanilla.EditText(
            (140 + 10, 12, -15, 15 + 4),
            "50",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.pixelRasterWidth.getNSTextField().setToolTip_(
            "The distance between all pixel elements.")

        self.w.pixelComponentText = vanilla.TextBox((15 - 1, 12 + 26, 140, 14),
                                                    "Pixel component name",
                                                    sizeStyle='small')
        self.w.pixelComponentName = vanilla.EditText(
            (140 + 10, 12 + 24, -15, 15 + 4),
            "pixel",
            callback=self.EnablePixelateButton,
            sizeStyle='small')
        self.w.pixelComponentName.getNSTextField().setToolTip_(
            "The name of the glyph containing the pixel element. If it does not exist in the font, the Insert button will deactivate."
        )

        self.w.resetWidths = vanilla.CheckBox((15, 63, -15, 20),
                                              "Snap widths to pixel grid",
                                              value=True,
                                              callback=self.SavePreferences,
                                              sizeStyle='small')
        self.w.resetWidths.getNSButton().setToolTip_(
            u"Also snaps the glyph’s advance width (RSB) to the pixel grid.")

        self.w.decomposeComponents = vanilla.CheckBox(
            (15, 63 + 20, -15, 20),
            "Decompose compounds",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.decomposeComponents.getNSButton().setToolTip_(
            "If on, will insert outlines instead of components.")

        self.w.keepWindowOpen = vanilla.CheckBox((15, 63 + 40, -15, 20),
                                                 "Keep window open",
                                                 value=True,
                                                 callback=self.SavePreferences,
                                                 sizeStyle='small')
        self.w.keepWindowOpen.getNSButton().setToolTip_(
            "If off, the window will close after pressing the Insert button.")

        # Run Button:
        self.w.runButton = vanilla.Button((-120 - 15, -20 - 15, -15, -15),
                                          "Insert Pixels",
                                          sizeStyle='regular',
                                          callback=self.PixelateMain)
        self.w.runButton.getNSButton().setToolTip_(
            "The button will deactivate if there is no glyph with the name entered above."
        )
        self.w.setDefaultButton(self.w.runButton)

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

        # Check if run button should be enabled:
        self.EnablePixelateButton()
        Glyphs.addCallback(self.EnablePixelateButton, UPDATEINTERFACE)

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

        # 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(
            (3, 2, 133, 24),
            self.mostImportantObjects,
            sizeStyle='regular',
            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, 6, 35, 14),
                                       "Find:",
                                       sizeStyle='small')
        self.w.filter = vanilla.EditText((173, 1, -1, 24),
                                         "",
                                         sizeStyle='regular',
                                         callback=self.MethodReporterMain)
        self.w.filter.getNSTextField().setToolTip_(
            "Type one or more (space-separated) search terms here. Case is ignored. Use * as wildcard at beginning, middle or end of term. Multiple search terms are AND-concatenated."
        )

        # Listing of methods:
        self.w.methodList = vanilla.List(
            (0, 26, -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)
Ejemplo n.º 25
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()
    def __init__(self):
        # Window 'self.w':
        windowWidth = 440
        windowHeight = 160
        windowWidthResize = 600  # 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
            "Italic Shift Feature",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.ItalicShiftFeature.mainwindow"  # stores last window position and size
        )

        # UI elements:
        inset = 15
        lineStep = 22
        lineheight = 12
        self.w.text_1 = vanilla.TextBox(
            (inset - 1, lineheight + 2, -inset, 14),
            "Insert GPOS lookup for shifting punctuation in italic angle of 1st master:",
            sizeStyle='small')

        lineheight += lineStep
        self.w.edit_1a = vanilla.EditText((inset, lineheight, 70, 19),
                                          "case",
                                          sizeStyle='small',
                                          placeholder="smcp,c2sc",
                                          callback=self.SavePreferences)
        self.w.edit_1b = vanilla.EditText((75 + inset, lineheight, 55, 19),
                                          "100",
                                          sizeStyle='small',
                                          placeholder="80",
                                          callback=self.SavePreferences)
        self.w.edit_1c = vanilla.EditText(
            (75 + 75, lineheight, -inset, 19),
            "exclamdown questiondown",
            sizeStyle='small',
            placeholder="parenleft parenright bracketleft bracketright",
            callback=self.SavePreferences)

        lineheight += lineStep
        self.w.edit_2a = vanilla.EditText((inset, lineheight, 70, 19),
                                          "case",
                                          sizeStyle='small',
                                          placeholder="smcp,c2sc",
                                          callback=self.SavePreferences)
        self.w.edit_2b = vanilla.EditText((75 + inset, lineheight, 55, 19),
                                          "50",
                                          sizeStyle='small',
                                          placeholder="80",
                                          callback=self.SavePreferences)
        self.w.edit_2c = vanilla.EditText(
            (75 + 75, lineheight, -inset, 19),
            "parenleft parenright braceleft braceright bracketleft bracketright",
            sizeStyle='small',
            placeholder="parenleft parenright bracketleft bracketright",
            callback=self.SavePreferences)

        lineheight += lineStep
        self.w.edit_3a = vanilla.EditText((inset, lineheight, 70, 19),
                                          "",
                                          sizeStyle='small',
                                          placeholder="smcp,c2sc",
                                          callback=self.SavePreferences)
        self.w.edit_3b = vanilla.EditText((75 + inset, lineheight, 55, 19),
                                          "",
                                          sizeStyle='small',
                                          placeholder="80",
                                          callback=self.SavePreferences)
        self.w.edit_3c = vanilla.EditText(
            (75 + 75, lineheight, -inset, 19),
            "",
            sizeStyle='small',
            placeholder="parenleft parenright bracketleft bracketright",
            callback=self.SavePreferences)

        # Run Button:
        self.w.copyButton = vanilla.Button(
            (-180 - inset, -20 - inset, -inset - 90, -inset),
            "Copy Code",
            sizeStyle='regular',
            callback=self.ItalicShiftFeatureMain)
        self.w.runButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            "Insert",
            sizeStyle='regular',
            callback=self.ItalicShiftFeatureMain)
        self.w.setDefaultButton(self.w.runButton)

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 27
0
	def __init__(self):
		self.w = vanilla.Window((300, 100), "Add Label")
		self.w.editText = vanilla.EditText((10, 10, -10, 22), "name", sizeStyle='small', callback=self.editTextCallback)
		self.w.myButton = vanilla.Button((10, 40, -10, 20), "add", sizeStyle='small', callback=self.nameLabel)
		self.w.open()
		self.w.makeKey()
Ejemplo n.º 28
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 320
        windowHeight = 470
        windowWidthResize = 100  # user can resize width by this value
        windowHeightResize = 0  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Path Problem Finder",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.PathProblemFinder.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight = 12, 15, 22
        indent = 170
        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, 14),
            u"New tab with layers containing path problems:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.zeroHandles = vanilla.CheckBox((inset, linePos, -inset, 20),
                                              u"Zero handles",
                                              value=True,
                                              callback=self.SavePreferences,
                                              sizeStyle='small')
        self.w.zeroHandles.getNSButton().setToolTip_(
            u"Zero handles (a.k.a. half-dead curves) can cause problems with screen rendering, hinting and interpolation. Indicated with purple disks in the Show Angled Handles plug-in."
        )
        linePos += lineHeight

        self.w.outwardHandles = vanilla.CheckBox((inset, linePos, -inset, 20),
                                                 u"Outward-bent handles",
                                                 value=False,
                                                 callback=self.SavePreferences,
                                                 sizeStyle='small')
        self.w.outwardHandles.getNSButton().setToolTip_(
            u"Will find handles that point outside the stretch of their enclosing on-curves. Usually unwanted."
        )
        linePos += lineHeight

        self.w.largeHandles = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Overshooting handles (larger than 100%)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.largeHandles.getNSButton().setToolTip_(
            u"Handles that are longer than 100%, i.e. going beyond the intersection with the opposing handle. Indicated with laser beams in the Show Angled Handles plug-in."
        )
        linePos += lineHeight

        self.w.shortHandles = vanilla.CheckBox((inset, linePos, indent, 20),
                                               u"Handles shorter than:",
                                               value=False,
                                               callback=self.SavePreferences,
                                               sizeStyle='small')
        self.w.shortHandlesThreshold = vanilla.EditText(
            (inset + indent, linePos, -inset - 55, 19),
            "12",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.shortHandlesText = vanilla.TextBox(
            (-inset - 50, linePos + 2, -inset, 14),
            u"units",
            sizeStyle='small',
            selectable=True)
        tooltipText = u"Will find handles shorter than the specified amount in units. Short handles may cause kinks when rounded to the grid."
        self.w.shortHandlesThreshold.getNSTextField().setToolTip_(tooltipText)
        self.w.shortHandles.getNSButton().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.angledHandles = vanilla.CheckBox((inset, linePos, indent, 20),
                                                u"Angled handles up to:",
                                                value=True,
                                                callback=self.SavePreferences,
                                                sizeStyle='small')
        self.w.angledHandlesAngle = vanilla.EditText(
            (inset + indent, linePos, -inset - 55, 19),
            "8",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.angledHandlesText = vanilla.TextBox(
            (-inset - 50, linePos + 2, -inset, 14),
            u"degrees",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.shallowCurveBBox = vanilla.CheckBox(
            (inset, linePos, indent, 20),
            u"Curve bbox smaller than:",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.shallowCurveBBoxThreshold = vanilla.EditText(
            (inset + indent, linePos, -inset - 55, 19),
            "10",
            sizeStyle='small')
        self.w.shallowCurveBBoxText = vanilla.TextBox(
            (-inset - 50, linePos + 2, -inset, 14),
            u"units",
            sizeStyle='small',
            selectable=True)
        tooltipText = u"Will find very flat curve segments. Flat curves leave little manœuvring space for handles (BCPs), or cause very short handles, which in turn causes grid rounding problems. Can usually be fixed by removing an extremum point or adding an overlap."
        self.w.shallowCurveBBoxThreshold.getNSTextField().setToolTip_(
            tooltipText)
        self.w.shallowCurveBBox.getNSButton().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.shallowCurve = vanilla.CheckBox((inset, linePos, indent, 20),
                                               u"Curves shallower than:",
                                               value=False,
                                               callback=self.SavePreferences,
                                               sizeStyle='small')
        self.w.shallowCurveThreshold = vanilla.EditText(
            (inset + indent, linePos, -inset - 55, 19), "5", sizeStyle='small')
        self.w.shallowCurveText = vanilla.TextBox(
            (-inset - 50, linePos + 2, -inset, 14),
            u"units",
            sizeStyle='small',
            selectable=True)
        tooltipText = u"Finds curve segments where the handles deviate less than the specified threshold from the enclosing on-curves."
        self.w.shallowCurveThreshold.getNSTextField().setToolTip_(tooltipText)
        self.w.shallowCurve.getNSButton().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.shortLine = vanilla.CheckBox((inset, linePos, indent, 20),
                                            u"Line segments shorter than:",
                                            value=False,
                                            callback=self.SavePreferences,
                                            sizeStyle='small')
        self.w.shortLineThreshold = vanilla.EditText(
            (inset + indent, linePos, -inset - 55, 19), "8", sizeStyle='small')
        self.w.shortLineText = vanilla.TextBox(
            (-inset - 50, linePos + 2, -inset, 14),
            u"units",
            sizeStyle='small',
            selectable=True)
        tooltipText = u"Finds line segments (two consecutive on-curve nodes) shorter than the specified threshold length. Very short line segments may be deleted because they are barely visible. Also, if not orthogonal, may pose grid rounding problems."
        self.w.shortLineThreshold.getNSTextField().setToolTip_(tooltipText)
        self.w.shortLine.getNSButton().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.almostOrthogonalLines = vanilla.CheckBox(
            (inset, linePos, indent, 20),
            u"Non-orthogonal lines:",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.almostOrthogonalLinesThreshold = vanilla.EditText(
            (inset + indent, linePos, -inset - 75, 19),
            "3",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.almostOrthogonalLinesText = vanilla.TextBox(
            (-inset - 70, linePos + 2, -inset, 14),
            u"units deep",
            sizeStyle='small',
            selectable=True)
        tooltipText = u"Will find line segments that are close to, but not completely horizontal or vertical. Will look for segments where the x or y distance between the two nodes is less than the specified threshold. Often unintentional."
        self.w.almostOrthogonalLinesThreshold.getNSTextField().setToolTip_(
            tooltipText)
        self.w.almostOrthogonalLines.getNSButton().setToolTip_(tooltipText)
        linePos += lineHeight

        self.w.badOutlineOrder = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Bad outline order",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.badOutlineOrder.getNSButton().setToolTip_(
            u"If the first path is clockwise, paths are most likely in the wrong order."
        )
        linePos += lineHeight

        self.w.twoPointOutlines = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Paths with two on-curve nodes only",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.twoPointOutlines.getNSButton().setToolTip_(
            u"Paths with only two on-curve nodes are most likely leftover debris from a previous operation."
        )
        linePos += lineHeight

        self.w.offcurveAsStartPoint = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Off-curve point (handle) as startpoint",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.offcurveAsStartPoint.getNSButton().setToolTip_(
            u"Finds paths where the first point happens to be a BCP. Not really an issue, but you’ll like it if you are going full OCD on your font."
        )
        linePos += lineHeight

        self.w.openPaths = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Open paths (except _corner, _cap, etc.)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.openPaths.getNSButton().setToolTip_(
            u"Finds unclosed paths. Special glyphs that are supposed to have open paths, like corner and cap components, are ignored."
        )
        linePos += lineHeight

        self.w.line = vanilla.HorizontalLine((inset, linePos + 3, -inset, 1))
        linePos += int(lineHeight / 2)

        # Script Options:
        self.w.includeAllGlyphs = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Check complete font (i.e., ignore glyph selection)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeAllGlyphs.getNSButton().setToolTip_(
            u"If enabled, will ignore your current (glyph) selection, and simply go through the complete font. Recommended. May still ignore non-exporting glyph, see following option."
        )
        linePos += lineHeight

        self.w.includeNonExporting = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Include non-exporting glyphs",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeNonExporting.getNSButton().setToolTip_(
            u"If disabled, will ignore glyphs that are set to not export.")
        linePos += lineHeight

        self.w.reuseTab = vanilla.CheckBox((inset, linePos, -inset, 20),
                                           u"Reuse existing tab",
                                           value=True,
                                           callback=self.SavePreferences,
                                           sizeStyle='small')
        self.w.reuseTab.getNSButton().setToolTip_(
            u"If enabled, will only open a new tab if none is open. Recommended."
        )
        linePos += lineHeight

        # Progress Bar and Status text:
        self.w.progress = vanilla.ProgressBar((inset, linePos, -inset, 16))
        self.w.progress.set(0)  # set progress indicator to zero
        self.w.status = vanilla.TextBox((inset, -18 - inset, -inset - 100, 14),
                                        u"🤖 Ready.",
                                        sizeStyle='small',
                                        selectable=True)
        linePos += lineHeight

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 29
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 260
        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
            "Punctuation Unifier",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.PunctuationUnifier.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"Unifies the shapes of the periods in punctuation.",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.periodBaseText = vanilla.TextBox((inset, linePos + 2, 100, 14),
                                                u"Model for period:",
                                                sizeStyle='small',
                                                selectable=True)
        self.w.periodBase = vanilla.PopUpButton(
            (inset + 100, linePos, -inset, 17),
            self.periodBase,
            sizeStyle='small',
            callback=self.SavePreferences)
        linePos += lineHeight

        self.w.commaBaseText = vanilla.TextBox((inset, linePos + 2, 100, 14),
                                               u"Model for comma:",
                                               sizeStyle='small',
                                               selectable=True)
        self.w.commaBase = vanilla.PopUpButton(
            (inset + 100, linePos, -inset, 17),
            self.commaBase,
            sizeStyle='small',
            callback=self.SavePreferences)
        linePos += lineHeight

        self.w.scaleToHeight = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Scale to height",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.text_1 = vanilla.TextBox((inset - 1, linePos + 2, 75, 14),
                                        "inset",
                                        sizeStyle='small')
        self.w.popup_1 = vanilla.PopUpButton((inset + 80, linePos, 50, 17),
                                             [str(x) for x in range(3, 12)],
                                             callback=self.SavePreferences,
                                             sizeStyle='small')
        self.w.edit_1 = vanilla.EditText(
            (inset + 80 + 55, linePos, -inset, 19),
            "insert text here",
            sizeStyle='small',
            callback=self.SavePreferences)
        linePos += lineHeight

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Ejemplo n.º 30
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 280
        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
            "Short Segment Finder",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.ShortSegmentFinder.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight = 12, 15, 22

        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, 30),
            u"Finds short segments in interpolations or masters, and opens a new tab with them",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight * 2

        self.w.text_1 = vanilla.TextBox((inset, linePos + 2, 185, 14),
                                        "Acceptable min segment length:",
                                        sizeStyle='small')
        self.w.minSegmentLength = vanilla.EditText(
            (inset + 185, linePos - 1, -inset, 19),
            "3",
            sizeStyle='small',
            callback=self.SavePreferences)
        self.w.minSegmentLength.getNSTextField().setToolTip_(
            "Minimum length for every segment in all paths, measured in units."
        )
        linePos += lineHeight

        self.w.findShortSegmentsInMasters = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Look in masters instead (i.e., not in interpolations)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.findShortSegmentsInMasters.getNSButton().setToolTip_(
            "If checked, will not calculate interpolations, but only measure segments in your master drawings, bracket and brace layers."
        )
        linePos += lineHeight

        self.w.allGlyphs = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Process all glyphs in font (i.e., ignore selection)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.allGlyphs.getNSButton().setToolTip_(
            "If unchecked, will only process the currently selected glyph(s).")
        linePos += lineHeight

        self.w.exportingOnly = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Ignore non-exporting glyphs",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.exportingOnly.getNSButton().setToolTip_(
            "If checked, will skip glyphs that do not export. Always skips compounds."
        )
        linePos += lineHeight

        self.w.reportIncompatibilities = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Report incompatibilities and no paths in Macro Window",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.reportIncompatibilities.getNSButton().setToolTip_(
            "If checked, will warn about incompatibilities and if a glyph has no paths. Usually you want this off, because it will report all compounds."
        )
        linePos += lineHeight

        self.w.markSegments = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Mark segments in first layer",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.markSegments.getNSButton().setToolTip_(
            "If checked, will mark affected segments with a warning emoji and the minimum segment length. Will mark the corresponding segment in the first layer if it finds a short segment in a calculated instance. Will use an annotation if the segment cannot be found (e.g. if the segment is in a corner component)."
        )
        linePos += lineHeight

        self.w.bringMacroWindowToFront = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Bring Macro Window to front",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.bringMacroWindowToFront.getNSButton().setToolTip_(
            "A detailed report is written to the Macro Window. Activate this check box, and the Macro Window will be brought to the front ever time you run this script."
        )
        linePos += lineHeight

        self.w.progress = vanilla.ProgressBar((inset, linePos, -inset, 16))
        self.w.progress.set(0)  # set progress indicator to zero
        linePos += lineHeight

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()

        #
        self.adaptUItext(None)