示例#1
0
    def __init__(self):
        windowHeight = 180
        self.w = vanilla.FloatingWindow(
            (350, windowHeight),
            "Stitcher",
            minSize=(300, windowHeight),
            maxSize=(500, windowHeight),
            autosaveName="com.mekkablue.ComponentsOnNodes.mainwindow")

        inset = 15
        linePos = 14
        lineGap = 22
        self.w.text_1 = vanilla.TextBox((inset, linePos, 100, 14),
                                        "Place component:",
                                        sizeStyle='small')
        self.w.componentName = vanilla.EditText(
            (inset + 100, linePos, -15, 20),
            "_circle",
            sizeStyle='small',
            callback=self.SavePreferences)

        linePos += lineGap
        self.w.text_2 = vanilla.TextBox((inset, linePos, 15 + 95, 14),
                                        "At intervals of:",
                                        sizeStyle='small')
        self.w.sliderMin = vanilla.EditText((inset + 100, linePos, 50, 20),
                                            "30",
                                            sizeStyle='small',
                                            callback=self.SavePreferences)
        self.w.sliderMax = vanilla.EditText((-inset - 50, linePos, -15, 20),
                                            "60",
                                            sizeStyle='small',
                                            callback=self.SavePreferences)
        self.w.intervalSlider = vanilla.Slider(
            (inset + 100 + 50 + 10, linePos, -inset - 50 - 10, 20),
            value=0,
            minValue=0.0,
            maxValue=1.0,
            sizeStyle='small',
            callback=self.ComponentOnLinesMain)

        linePos += lineGap
        self.w.liveSlider = vanilla.CheckBox((inset, linePos, -inset, 20),
                                             "Live slider",
                                             value=False,
                                             sizeStyle='small')

        linePos += lineGap
        self.w.useBackground = vanilla.CheckBox((inset, linePos, -inset, 20),
                                                "Keep paths in background",
                                                value=True,
                                                sizeStyle='small',
                                                callback=self.SavePreferences)

        linePos += lineGap
        self.w.balanceOverCompletePath = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            u"Balance components over complete path",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')

        self.w.runButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            "Stitch",
            sizeStyle='regular',
            callback=self.ComponentOnLinesMain)
        self.w.setDefaultButton(self.w.runButton)

        try:
            self.LoadPreferences()
        except:
            pass

        self.w.open()
        self.w.makeKey()
示例#2
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 300
        windowHeight = 180
        windowWidthResize = 100  # user can resize width by this value
        windowHeightResize = 0  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Batch Insert Anchor",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.BatchInsertAnchor.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight = 12, 15, 22
        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos, -inset, 14),
            u"In selected glyphs, insert this anchor on all layers:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.anchorNameText = vanilla.TextBox((inset, linePos + 2, 90, 14),
                                                u"Anchor Name:",
                                                sizeStyle='small',
                                                selectable=True)
        self.w.anchorName = vanilla.EditText(
            (inset + 90, linePos - 1, -inset, 19),
            "_connect",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.anchorName.getNSTextField().setToolTip_(
            u"Name of the anchor that will be inserted.")
        linePos += lineHeight

        self.w.xPosText = vanilla.TextBox((inset, linePos + 2, 90, 14),
                                          u"H Position:",
                                          sizeStyle='small',
                                          selectable=True)
        self.w.xPos = vanilla.PopUpButton((inset + 90, linePos, -inset, 17),
                                          xPositions,
                                          sizeStyle='small',
                                          callback=self.SavePreferences)
        self.w.xPos.getNSButton().setToolTip_(
            u"The x coordinate of the anchor.")
        linePos += lineHeight

        self.w.yPosText = vanilla.TextBox((inset, linePos + 2, 90, 14),
                                          u"V Position:",
                                          sizeStyle='small',
                                          selectable=True)
        self.w.yPos = vanilla.PopUpButton((inset + 90, linePos, -inset, 17),
                                          yPositions,
                                          sizeStyle='small',
                                          callback=self.SavePreferences)
        self.w.yPos.getNSButton().setToolTip_(
            u"The y coordinate of the anchor.")
        linePos += lineHeight

        self.w.replaceExisting = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Replace Existing Anchors with Same Name",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.replaceExisting.getNSButton().setToolTip_(
            u"If enabled, will delete anchors that have the same name of the one you are adding, before it is added again at the specified spot. If disabled, the script will skip layers that already have an anchor of the same name."
        )
        linePos += lineHeight

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 175
        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
            "New Tabs with Glyphs Not Reaching Into Zones",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.NewTabsWithGlyphsNotReachingIntoZones.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight = 12, 12, 22
        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, 14),
            u"Open tab with glyphs that are not reaching into zones.",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.allMastersInSeparateTabs = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Include All Masters (in Separate Tabs)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.includeSpecialLayers = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Include Special Layers",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.ignoreGlyphsText = vanilla.TextBox(
            (inset, linePos + 2, 140, 14),
            u"Ignore glyphs containing:",
            sizeStyle='small',
            selectable=True)
        self.w.ignoreGlyphs = vanilla.EditText(
            (inset + 140, linePos - 1, -inset, 19),
            ".sups, .subs, superior, inferior, Arrow",
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.includeText = vanilla.TextBox((inset, linePos + 2, 60, 14),
                                             u"Include:",
                                             sizeStyle='small',
                                             selectable=True)
        self.w.includeMarks = vanilla.CheckBox(
            (inset + 50, linePos - 1, -inset, 20),
            u"Marks",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includeSymbols = vanilla.CheckBox(
            (inset + 110, linePos - 1, -inset, 20),
            u"Symbols",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.includePunctuation = vanilla.CheckBox(
            (inset + 60 * 3, linePos - 1, -inset, 20),
            u"Punctuation",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

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

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'New Tabs with Glyphs Not Reaching Into Zones' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 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
            "New Tab with Transformed Components",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.NewTabWithTransformedComponents.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"Finds and displays components that are transformed:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.findScaled = vanilla.CheckBox((inset, linePos - 1, -inset, 20),
                                             u"Find scaled components",
                                             value=True,
                                             callback=self.SavePreferences,
                                             sizeStyle='small')
        linePos += lineHeight

        self.w.findUnproportionallyScaled = vanilla.CheckBox(
            (inset * 2, linePos - 1, -inset, 20),
            u"Only unproportionally scaled (h≠v)",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.findRotated = vanilla.CheckBox((inset, linePos - 1, -inset, 20),
                                              u"Find rotated components",
                                              value=False,
                                              callback=self.SavePreferences,
                                              sizeStyle='small')
        linePos += lineHeight

        self.w.findMirrored = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Find flipped components",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.findShifted = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Find shifted (otherwise untransformed) components",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.includeNonexporting = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Include non-exporting glyphs",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.includeInactiveLayers = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Include inactive backup layers",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.reuseTab = vanilla.CheckBox((inset, linePos - 1, -inset, 20),
                                           u"Reuse current tab",
                                           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(
            (-110 - inset, -20 - inset, -inset, -inset),
            "Open Tab",
            sizeStyle='regular',
            callback=self.NewTabWithTransformedComponentsMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'New Tab with Transformed Components' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
        self.updateUI()
示例#5
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 340
        windowHeight = 240
        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
            "Copy layer to layer",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.CopyLayerToLayer.mainwindow"  # stores last window position and size
        )

        self.w.text_1 = vanilla.TextBox((15, 12 + 2, 120, 14),
                                        "Copy paths from",
                                        sizeStyle='small')
        self.w.fontSource = vanilla.PopUpButton(
            (120, 12, -15, 17),
            self.GetFontNames(),
            sizeStyle='small',
            callback=self.FontChangeCallback)
        self.w.masterSource = vanilla.PopUpButton(
            (120, 12 + 20, -15, 17),
            self.GetMasterNames("source"),
            sizeStyle='small',
            callback=self.MasterChangeCallback)

        self.w.text_2 = vanilla.TextBox((15, 56 + 2, 120, 14),
                                        "into selection of",
                                        sizeStyle='small')
        self.w.fontTarget = vanilla.PopUpButton(
            (120, 56, -15, 17),
            self.GetFontNames(),
            sizeStyle='small',
            callback=self.FontChangeCallback)
        self.w.masterTarget = vanilla.PopUpButton(
            (120, 56 + 20, -15, 17),
            self.GetMasterNames("target"),
            sizeStyle='small',
            callback=self.MasterChangeCallback)

        self.w.includePaths = vanilla.CheckBox(
            (15 + 150 + 15, 100 + 2, 160, 20),
            "Include paths",
            sizeStyle='small',
            callback=self.SavePreferences,
            value=True)
        self.w.includeComponents = vanilla.CheckBox(
            (15, 100 + 2, 160, 20),
            "Include components",
            sizeStyle='small',
            callback=self.SavePreferences,
            value=True)
        self.w.includeAnchors = vanilla.CheckBox((15, 100 + 20, 160, 20),
                                                 "Include anchors",
                                                 sizeStyle='small',
                                                 callback=self.SavePreferences,
                                                 value=True)
        self.w.includeMetrics = vanilla.CheckBox(
            (15 + 150 + 15, 100 + 20, 160, 20),
            "Include metrics",
            sizeStyle='small',
            callback=self.SavePreferences,
            value=True)

        self.w.copyBackground = vanilla.CheckBox((15, 100 + 45, 160, 20),
                                                 "Into background instead",
                                                 sizeStyle='small',
                                                 callback=self.SavePreferences,
                                                 value=False)
        self.w.keepOriginal = vanilla.CheckBox(
            (15 + 150 + 15, 100 + 45, 160, 20),
            "Keep target layer content",
            sizeStyle='small',
            callback=self.SavePreferences,
            value=False)

        self.w.keepWindowOpen = vanilla.CheckBox((15, 100 + 70, 160, 20),
                                                 "Keep window open",
                                                 sizeStyle='small',
                                                 callback=self.SavePreferences,
                                                 value=True)

        self.w.copybutton = vanilla.Button((-80, -30, -15, -10),
                                           "Copy",
                                           sizeStyle='small',
                                           callback=self.buttonCallback)
        self.w.setDefaultButton(self.w.copybutton)

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

        self.w.open()
        self.w.makeKey()
        self.w.masterTarget.set(1)
    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 += lineHeight // 2
        self.w.whereToCheck = vanilla.Box(
            (inset, linePos, -inset, lineHeight * 7.6))
        insetLinePos = inset * 0.2

        self.w.whereToCheck.ascender = vanilla.CheckBox(
            (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(
            (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(
            (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(
            (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(
            (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(
            (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(
            (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()
示例#7
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, linePos = 14, 24, -10
        linePos += lineHeight

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

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

        self.w.text_left = vanilla.TextBox((inset, linePos + 3, 80, 14),
                                           "Left glyphs:",
                                           sizeStyle='small')
        self.w.leftGlyphs = vanilla.ComboBox(
            (inset + 80, linePos, -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, linePos + 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)."
        )
        linePos += lineHeight

        self.w.text_right = vanilla.TextBox((inset, linePos + 3, 80, 14),
                                            "Right glyphs:",
                                            sizeStyle='small')
        self.w.rightGlyphs = vanilla.ComboBox(
            (inset + 80, linePos, -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, linePos + 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)."
        )
        linePos += lineHeight

        self.w.suffixText = vanilla.TextBox((inset, linePos + 3, 80, 14),
                                            u"Add suffix:",
                                            sizeStyle='small',
                                            selectable=True)
        self.w.suffix = vanilla.EditText((inset + 80, linePos, 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."
        )
        linePos += lineHeight

        self.w.text_21 = vanilla.TextBox((inset, linePos + 3, 80, 14),
                                         "Min distance:",
                                         sizeStyle='small')
        self.w.minDistance = vanilla.EditText((inset + 80, linePos, 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, linePos + 3, 80, 14),
                                         "Max distance:",
                                         sizeStyle='small')
        self.w.maxDistance = vanilla.EditText(
            (inset + 80 * 3, linePos, 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, linePos + 3, 80, 14),
                                         "Round by:",
                                         sizeStyle='small')
        self.w.roundFactor = vanilla.EditText(
            (inset + 80 * 5, linePos, -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."
        )
        linePos += lineHeight

        self.w.text_speed = vanilla.TextBox((inset, linePos + 3, 42, 14),
                                            "Speed:",
                                            sizeStyle='small')
        self.w.speedPopup = vanilla.PopUpButton(
            (inset + 42, linePos + 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, linePos + 3, -15, 14),
            "Measuring every %i units." % intervalList[intervalIndex],
            sizeStyle='small')
        linePos += lineHeight

        self.w.text_6 = vanilla.TextBox((inset, linePos + 3, 130, 14),
                                        "Ignore height intervals:",
                                        sizeStyle='small')
        self.w.ignoreIntervals = vanilla.EditText(
            (inset + 130, linePos, -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."
        )
        linePos += lineHeight

        self.w.keepExistingKerning = vanilla.CheckBox(
            (inset + 5, linePos, -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."
        )
        linePos += lineHeight

        self.w.excludeNonExporting = vanilla.CheckBox(
            (inset + 5, linePos, 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 + 230, linePos, -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."
        )
        linePos += lineHeight

        self.w.reportInMacroWindow = vanilla.CheckBox(
            (inset + 5, linePos, -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.")
        linePos += lineHeight

        self.w.openNewTabWithKernPairs = vanilla.CheckBox(
            (inset + 5, linePos, 200, 17),
            u"Open 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."
        )
        self.w.reuseCurrentTab = vanilla.CheckBox(
            (inset + 230, linePos - 1, -inset, 20),
            u"Reuse current tab",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.reuseCurrentTab.getNSButton().setToolTip_(
            u"If enabled, will not open a new tab with newly added kern pairs, but reuse the current Edit tab. Will open an Edit tab if none is open. Only available in connection with the Open Edit Tab checkbox."
        )
        linePos += lineHeight

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

        # (Hidden) Preferences Kern Strings:
        self.w.kernStrings = vanilla.TextEditor((1, linePos, -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))

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

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-90 - inset, -20 - inset, -inset, -inset),
            "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()
示例#8
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 250
        windowHeight = 190
        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 Small Paths",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.FindSmallPaths.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.text_1 = vanilla.TextBox(
            (15, 10, -15, 30),
            "Open a new tab with glyphs that contain paths with an area smaller than:",
            sizeStyle='small')
        self.w.minArea = vanilla.TextBox((15, 42, -15, 15 + 3),
                                         "1000 square units",
                                         sizeStyle='small',
                                         alignment="center")

        self.w.sliderMin = vanilla.EditText((15, 60 - 1, 50, 19),
                                            "10",
                                            sizeStyle='small',
                                            callback=self.SliderUpdate)
        self.w.sliderMax = vanilla.EditText((-15 - 50, 60 - 1, -15, 19),
                                            "10000",
                                            sizeStyle='small',
                                            callback=self.SliderUpdate)
        self.w.areaSlider = vanilla.Slider(
            (15 + 50 + 10, 60, -15 - 50 - 10, 19),
            value=0.1,
            minValue=0.0,
            maxValue=1.0,
            sizeStyle='small',
            callback=self.SliderUpdate)

        self.w.deleteThemRightAway = vanilla.CheckBox(
            (15, 80 + 10, -15, 20),
            "Delete Small Paths Right Away",
            value=False,
            callback=self.CheckBoxUpdate,
            sizeStyle='small')
        self.w.afterOverlapRemoval = vanilla.CheckBox(
            (15, 100 + 10, -15, 20),
            "After Decomposition and Overlap Removal (slower)",
            value=False,
            callback=self.CheckBoxUpdate,
            sizeStyle='small')

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

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

        self.CheckBoxUpdate(None)
        self.SliderUpdate(None)

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
示例#9
0
    def __init__(self):
        if Font is None:
            Message("No font selected", "Select a font project!")
            return

        self.font = Font

        self.prefs = {}

        self.defaults = [
            "n n",  # LC
            "v n",
            "n o",
            "o n",
            "n a",
            "i n",
            "n u",
            "l n",
            "r n",
            "l H",  # LC/UC
            "H o",
            "H n",
            "H s",
            "H x",
            "H H",
            "H O",
            "H T",
            "H V",
            "E H",
            "one zero",  # numbers
            "one one",
            "one two",
            "one three",
            "one four",
            "one n",  # numbers/LC/UC
            "one H",
            "d exclam",  # LC/spaced-off
            "d colon",
            "one comma",
            "d period",
            "H ampersand",
            "n at",
            "d hyphen",
            "d endash",  # dashes
            "d underscore",
            "endash endash",
            "d quoteright",  # quotes
            "quoteright h",
            "d quoteleft",
            "quoteleft h",
            "guilsinglleft h",
            "d parenleft",  # parens
            "pareneleft h",
            "bracketleft h",
            "h.sc h.sc",  # SC
            "e.sc h.sc",
            "h.sc o.sc",
            "o.sc h.sc",
            "h.sc v.sc",
            "v.sc h.sc",
            "h.sc parenleft.sc",
            "parenleft.sc h.sc",
            "one.sc zero.sc",
            "one.sc one.sc",
            "one.sc two.sc",
            "one.sc three.sc",
            "one.sc four.sc",
            "one.sc comma"
        ]

        if Glyphs.defaults["com.eweracs.setKOmodels.prefs"]:
            for key in Glyphs.defaults["com.eweracs.setKOmodels.prefs"]:
                self.prefs[key] = Glyphs.defaults[
                    "com.eweracs.setKOmodels.prefs"][key]
        else:
            self.prefs = {
                "allMasters": 1,
                "capitalKerning": 1,
                "modelList": self.defaults
            }

        self.master_capital_kern_values = {
            master: 0
            for master in self.font.masters
        }

        self.allMasters = self.prefs["allMasters"]
        self.capitalKerning = self.prefs["capitalKerning"]

        self.models = []

        self.build_font_models()

        self.selected_master = self.font.masters[0]

        self.w = vanilla.FloatingWindow((0, 0), "Set base models")

        self.w.modelsTitle = vanilla.TextBox((10, 10, -10, 14),
                                             "Model list",
                                             sizeStyle="small")
        self.w.editModels = vanilla.TextEditor(
            (10, 32, 145, -40),
            text="\n".join(self.prefs["modelList"]),
            callback=self.edit_models)
        self.w.resetDefaults = vanilla.Button((10, -32, 145, 20),
                                              "Restore defaults",
                                              callback=self.restore_defaults)
        self.w.addCapitalSpacingCheckBox = vanilla.CheckBox(
            (165, 8, -10, 20),
            "Add capital kerning",
            sizeStyle="small",
            value=self.prefs["capitalKerning"],
            callback=self.toggle_capital_kerning)

        self.ypos = 34

        for i, master in enumerate(self.font.masters):
            setattr(
                self.w, "master" + str(i),
                vanilla.TextBox((165, self.ypos, -60, 17),
                                master.name,
                                sizeStyle="regular"))
            setattr(
                self.w, "kern" + str(i),
                vanilla.EditText((-50, self.ypos - 1, -10, 22),
                                 text="0",
                                 callback=self.set_master_kern_value))
            self.ypos += 28

        self.w.kern0.selectAll()

        self.ypos += 70
        if self.ypos <= 160:
            self.ypos = 160

        self.w.allMasters = vanilla.CheckBox((165, -56, -10, 18),
                                             "Apply to all masters",
                                             sizeStyle="small",
                                             value=self.allMasters,
                                             callback=self.select_all_masters)
        self.w.setModelsButton = vanilla.Button((165, -32, -10, 20),
                                                "Set zero models",
                                                callback=self.set_models)

        self.toggle_master_input_fields()
        self.toggle_default_button()

        self.w.setDefaultButton(self.w.setModelsButton)
        self.w.resize(320, self.ypos)
        self.w.open()
        self.w.makeKey()
示例#10
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 480
        windowHeight = 275
        windowWidthResize = 400  # 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
            "Quote Manager: build and align quotes",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.QuoteManager.mainwindow"  # stores last window position and size
        )

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

        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, 14),
            "Syncs single and double quotes with cursive attachment. Reports in Macro Window.",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.defaultQuoteText = vanilla.TextBox((inset, linePos + 2, 90, 14),
                                                  "Default quotes:",
                                                  sizeStyle='small',
                                                  selectable=True)
        self.w.defaultQuote = vanilla.PopUpButton(
            (inset + 90, linePos, -inset, 17),
            ["%s/%s" % (name, names[name]) for name in names],
            sizeStyle='small',
            callback=self.SavePreferences)
        linePos += lineHeight

        self.w.syncWithDefaultQuote = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Sync all quotes with default quotes (metrics keys, anchor placement)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.syncWithDefaultQuote.getNSButton().setToolTip_(
            "If enabled, the default quotes will be taken as reference for metrics keys and distance between #exit and #entry anchors."
        )
        linePos += lineHeight

        self.w.excludeDumbQuotes = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Ignore straight dumb quotes (quotesingle, quotedbl)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.excludeDumbQuotes.getNSButton().setToolTip_(
            "For most actions, tthis option allows you to ignore the (straight) dumb quotes. The Kerning Group button will ignore this setting and always set the groups for the straight quote."
        )
        linePos += lineHeight

        self.w.suffixText = vanilla.TextBox(
            (inset, linePos + 2, 270, 14),
            "Suffix for all quotes involved (leave blank if none):",
            sizeStyle='small',
            selectable=True)
        self.w.suffix = vanilla.EditText(
            (inset + 270, linePos - 1, -inset, 19),
            "",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.suffix.getNSTextField().setToolTip_(
            u"E.g., ‘case’ for .case variants. Entry with or without the leading period. Leave blank for the default quotes (without dot suffixes)."
        )
        linePos += lineHeight

        self.w.openTabWithAffectedGlyphs = vanilla.CheckBox(
            (inset, linePos - 1, 200, 20),
            "Open tab with affected glyphs",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.openTabWithAffectedGlyphs.getNSButton().setToolTip_(
            "Whatever action you take, this option makes sure a new tab will be opened with all the glyphs affected."
        )
        self.w.reuseTab = vanilla.CheckBox(
            (inset + 200, linePos - 1, -inset, 20),
            u"Reuse current tab",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.reuseTab.getNSButton().setToolTip_(
            u"Instead of opening a new tab, will reuse the current tab. Highly recommended."
        )
        linePos += lineHeight

        self.w.buildDoublesButton = vanilla.Button(
            (inset, linePos, 130, 18),
            "Add Components",
            sizeStyle='small',
            callback=self.buildDoublesMain)
        self.w.buildDoublesText = vanilla.TextBox(
            (inset + 135, linePos + 2, -inset, 14),
            "Insert single quotes as components in double quotes",
            sizeStyle='small',
            selectable=True)
        tooltip = "Do this first. Then adjust the position of the second component in the default double quote. Inserting anchors (the next button) will take the distance between the components into account. Or follow the instructions in the tooltip of the next button. Then press the Insert Anchors button."
        self.w.buildDoublesButton.getNSButton().setToolTip_(tooltip)
        self.w.buildDoublesText.getNSTextField().setToolTip_(tooltip)
        linePos += lineHeight

        self.w.insertAnchorsButton = vanilla.Button(
            (inset, linePos, 130, 18),
            "Insert Anchors",
            sizeStyle='small',
            callback=self.insertAnchorsMain)
        self.w.insertAnchorsText = vanilla.TextBox(
            (inset + 135, linePos + 2, -inset, 14),
            "Insert #exit and #entry anchors in single quotes",
            sizeStyle='small',
            selectable=True)
        tooltip = "Hint: After you have done the previous steps, FIRST press button to insert the anchors, THEN adjust the width between the anchors in your default quote, THEN press this button again to sync all other #exit and #entry anchors with the default quotes."
        self.w.insertAnchorsButton.getNSButton().setToolTip_(tooltip)
        self.w.insertAnchorsText.getNSTextField().setToolTip_(tooltip)
        linePos += lineHeight

        self.w.metricKeyButton = vanilla.Button((inset, linePos, 130, 18),
                                                "Add Keys",
                                                sizeStyle='small',
                                                callback=self.metricKeyMain)
        self.w.metricKeyText = vanilla.TextBox(
            (inset + 135, linePos + 2, -inset, 14),
            "Apply metrics keys to single quotes",
            sizeStyle='small',
            selectable=True)
        tooltip = "Adds Metrics Keys to single quotes, so your quotes are all in sync and have the same width. Double quotes should use automatic alignment by now."
        self.w.metricKeyButton.getNSButton().setToolTip_(tooltip)
        self.w.metricKeyText.getNSTextField().setToolTip_(tooltip)
        linePos += lineHeight

        self.w.kernGroupButton = vanilla.Button((inset, linePos, 130, 18),
                                                "Set Groups",
                                                sizeStyle='small',
                                                callback=self.kernGroupMain)
        self.w.kernGroupText = vanilla.TextBox(
            (inset + 135, linePos + 2, -inset, 14),
            "Set kern groups (based on singles)",
            sizeStyle='small',
            selectable=True)
        tooltip = "Sync kern groups between double and single quotes."
        self.w.kernGroupButton.getNSButton().setToolTip_(tooltip)
        self.w.kernGroupText.getNSTextField().setToolTip_(tooltip)
        linePos += lineHeight

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Build and align quotes' 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 = 280
        windowHeight = 240
        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
            "Fix Arrow Positioning",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.FixArrowPositioning.mainwindow"  # stores last window position and size
        )

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

        self.w.explanation = vanilla.TextBox(
            (inset, linePos + 2, -inset, 14),
            "Fixes position and spacing of arrows.",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.referenceForHorizontalArrowsText = vanilla.TextBox(
            (inset, linePos + 2, 130, 14),
            "Reference for H arrows:",
            sizeStyle='small')
        self.w.referenceForHorizontalArrows = vanilla.PopUpButton(
            (inset + 130, linePos, -inset, 17),
            self.hArrows,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.referenceForVerticalArrowsText = vanilla.TextBox(
            (inset, linePos + 2, 130, 14),
            "Reference for V arrows:",
            sizeStyle='small')
        self.w.referenceForVerticalArrows = vanilla.PopUpButton(
            (inset + 130, linePos, -inset, 17),
            self.vArrows,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.referenceForDiagonalArrowsText = vanilla.TextBox(
            (inset, linePos + 2, 130, 14),
            "Reference for D arrows:",
            sizeStyle='small')
        self.w.referenceForDiagonalArrows = vanilla.PopUpButton(
            (inset + 130, linePos, -inset, 17),
            self.dArrows,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.suffixText = vanilla.TextBox((inset, linePos + 2, 70, 14),
                                            "Dot suffix:",
                                            sizeStyle='small',
                                            selectable=False)
        self.w.suffix = vanilla.EditText((inset + 70, linePos, -inset, 19),
                                         "",
                                         sizeStyle='small')
        linePos += lineHeight

        self.w.verticalPosOfHorizontalArrows = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Fix vertical positioning of horizontal arrows",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.verticalPosOfDiagonalArrows = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Fix vertical positioning of diagonal arrows",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

        self.w.addAndUpdateMetricsKeys = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            "Add and update metrics keys",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        linePos += lineHeight

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
    def __init__(self):
        self.w = vanilla.FloatingWindow((320, 95), "Rotate around anchor")

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

        linePos, inset, lineHeight = 10, 12, 22

        self.w.anchor_text = vanilla.TextBox((inset, linePos + 3, 120, 15),
                                             "Set 'rotate' anchor:",
                                             sizeStyle='small')
        self.w.anchor_x = vanilla.EditText((inset + 110, linePos, 40, 19),
                                           "0",
                                           sizeStyle='small',
                                           callback=self.SavePreferences)
        self.w.anchor_y = vanilla.EditText((inset + 110 + 45, linePos, 40, 19),
                                           "0",
                                           sizeStyle='small',
                                           callback=self.SavePreferences)
        self.w.updateButton = vanilla.SquareButton(
            (inset + 110 + 90, linePos, 20, 19),
            u"↺",
            sizeStyle='small',
            callback=self.updateRotateAnchor)
        self.w.anchor_button = vanilla.Button(
            (inset + 110 + 120, linePos + 1, -inset, 19),
            "Insert",
            sizeStyle='small',
            callback=self.insertRotateAnchor)
        linePos += lineHeight

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

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

        if not self.LoadPreferences():
            print(
                "Rotate Around Anchor: Could not load prefs, will resort to defaults."
            )

        self.updateRotateAnchor()
        self.w.open()
        self.w.makeKey()
示例#13
0
    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()
 def __init__(self):
     
     self.fontList = []
     self.fontNames = []
     self.fontStems = []
     self.estimatedStems = None # Estimated stem measurements for the resulting font
     
     # Glyph groups
     self.groups = []
     
     # Case info, normalized after editing
     self.normalizedInfo = {}
     self.dataNorms = {
         "scaleH": dict(default=100, dataType=float, scale=0.01),
         "scaleV": dict(default=100, dataType=float, scale=0.01),
         "interpH": dict(default=100, dataType=float, scale=0.01),
         "interpV": dict(default=100, dataType=float, scale=0.01),
         "tracking": dict(default=0, dataType=float, scale=1)}
     
     self.w = vanilla.Window((317, 700), "Scale And Interpolate %s" % VERSION, minSize=(317, 300), maxSize=(317, 969), autosaveName="ScaleAndInterp") # 882 height
     
     self.g = vanilla.Group((0, 0, 300, 900))
     
     step = 10
     self.g.font0title = vanilla.TextBox((10, step, -10, 25), colorText("Lightest Master (0%)", style="bold"))
     self.g.font0choice = vanilla.PopUpButton((10, step+20, -10, 25), self.fontNames, callback=self.fontChoiceChanged)
     step += 50
     self.g.font0stemTextUC = vanilla.TextBox((20, step, -10, 20), "")
     self.g.font0stemTextLC = vanilla.TextBox((20, step+20, -10, 20), "")
     step += 50
     self.g.font1title = vanilla.TextBox((10, step, -10, 25), colorText("Heaviest Master (100%)", style="bold"))
     self.g.font1choice = vanilla.PopUpButton((10, step+20, -10, 25), self.fontNames, callback=self.fontChoiceChanged)
     step += 50
     self.g.font1stemTextUC = vanilla.TextBox((20, step, -10, 20), "")
     self.g.font1stemTextLC = vanilla.TextBox((20, step+20, -10, 20), "")
     step += 50
     
     self.g.hr1 = vanilla.HorizontalLine((10, step, -10, 1))
     
     step += 15
     self.g.capsTitle = vanilla.TextBox((10, step, -10, 25), colorText("Caps", style="bold"))
     step += 25
     self.g.ucGroups = vanilla.PopUpButton((10, step, -10, 25), [])
     step += 35
     columnDescriptions = [dict(title="Name"), dict(title="Value", editable=True, width=50)]
     capInfo = [
         dict(Name="Scale Horizontal %", attr="scaleH", Value=100),
         dict(Name="Scale Vertical %", attr="scaleV", Value=100),
         dict(Name="Interpolate Horizontal %", attr="interpH", Value=100),
         dict(Name="Interpolate Vertical %", attr="interpV", Value=100),
         dict(Name="Units of tracking", attr="tracking", Value=0)]
     self.g.ucInfo = vanilla.List((10, step, -10, 100), capInfo, columnDescriptions=columnDescriptions, showColumnTitles=False, editCallback=self.dataChanged)
     step += 110
     self.g.resultStemTextUC = vanilla.TextBox((20, step, -10, 20), "")
     step += 30
     
     self.g.lcTitle = vanilla.TextBox((10, step, -10, 25), colorText("Lowercase", style="bold"))
     step += 25
     self.g.lcGroups = vanilla.PopUpButton((10, step, -10, 25), [])
     step += 35
     lcInfo = [
         dict(Name="Scale Horizontal %", attr="scaleH", Value=100),
         dict(Name="Scale Vertical %", attr="scaleV", Value=100),
         dict(Name="Interpolate Horizontal %", attr="interpH", Value=100),
         dict(Name="Interpolate Vertical %", attr="interpV", Value=100),
         dict(Name="Units of tracking", attr="tracking", Value=0)]
     self.g.lcInfo = vanilla.List((10, step, -10, 100), lcInfo, columnDescriptions=columnDescriptions, showColumnTitles=False, editCallback=self.dataChanged)
     step += 110
     self.g.resultStemTextLC = vanilla.TextBox((20, step, -10, 20), "")
     step += 30
     
     self.g.otherTitle = vanilla.TextBox((10, step, -10, 25), colorText("Other glyphs", style="bold"))
     step += 25
     self.g.otherRadio = vanilla.RadioGroup((10, step, -10, 70), 
         ["Copy from the lightest master", 
         "Process at 50% of UC and LC settings", 
         "Skip any other glyphs"], callback=self.dataChanged)
     self.g.otherRadio.set(2)
     
     step += 80
     
     self.g.loadButton = vanilla.SquareButton((100, step, -10, 25), "Load settings from UFO", callback=self.loadSettings)
     step += 35
     
     self.g.hr2 = vanilla.HorizontalLine((10, step, -10, 1))
     step += 15
     self.g.skewBox = vanilla.CheckBox((10, step, -10, 25), "Skew Italic glyphs upright before scaling")
     self.g.skewBox.set(True)
     step += 25
     self.g.infoBox = vanilla.CheckBox((10, step, -10, 25), "Interpolate Font Info whenever possible")
     self.g.infoBox.set(True)
     step += 25
     self.g.scaleComponentBox = vanilla.CheckBox((10, step, -10, 25), "Don’t scale component positions")
     self.g.scaleComponentBox.set(True)
     step += 25
     self.g.doKernBox = vanilla.CheckBox((10, step, -10, 25), "Process Kerning")
     self.g.doKernBox.set(True)
     step += 3
     self.g.testKernButton = vanilla.SquareButton((135, step, -10, 25), "Compatibility Test", callback=self.kernCompatibilityTestCallback)
 
     #step += 40
     self.w.buildButton = vanilla.SquareButton((10, -35, -10, 25), "Make Font", callback=self.makeFontCallback)
     
     # Add the group to a ScrollView
     view = self.g.getNSView()
     self.w.sv = vanilla.ScrollView((0, 0, -0, -45), view, hasHorizontalScroller=False, hasVerticalScroller=True, autohidesScrollers=False, drawsBackground=False)#backgroundColor=NSColor.windowBackgroundColor())
     
     # Update the font info before opening
     self.fontsChanged()
     self.dataChanged()
     
     addObserver(self, "fontsChanged", "fontDidOpen")
     addObserver(self, "fontsChanged", "newFontDidOpen")
     addObserver(self, "fontsChanged", "fontDidClose")
     self.w.bind("close", self.windowClosed)
     self.w.open()
示例#15
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 320
        windowHeight = 190
        windowWidthResize = 50  # 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
            "Zero Kerner",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.ZeroKerner.mainwindow"  # stores last window position and size
        )

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

        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, 44),
            u"Add group kernings with value zero for pairs that are missing in one master but present in others. Helps preserve interpolatable kerning in OTVar exports.",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight * 2.5

        self.w.limitToCurrentMaster = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Limit to current master only (otherwise, all masters)",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.limitToCurrentMaster.getNSButton().setToolTip_(
            "Will apply zero kernings only to the currently selected master. Uncheck if all masters should be zero-kerned."
        )
        linePos += lineHeight

        self.w.reportInMacroWindow = vanilla.CheckBox(
            (inset, linePos - 1, -inset, 20),
            u"Detailed report in Macro Window",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.reportInMacroWindow.getNSButton().setToolTip_(
            "If checked, will write a progress report in the Macro Window (Cmd-Opt-M)."
        )
        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),
            "Zero Kern",
            sizeStyle='regular',
            callback=self.ZeroKernerMain)
        self.w.setDefaultButton(self.w.runButton)

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
示例#16
0
    def __init__(self):

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

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

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

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

        self.w.existingInstances = vanilla.RadioGroup(
            (inset + 30, 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 - 1, inset + 230, 19),
            u"Use ‘natural’ weight names, starting at:",
            value=False,
            callback=self.UpdateSample,
            sizeStyle='small')
        self.w.firstName = vanilla.PopUpButton(
            (inset + 230, lineheight, -inset, 17),
            naturalNames,
            callback=self.UpdateSample,
            sizeStyle='small')
        try:  # workaround for macOS 10.9
            self.w.firstName.enable(
                self.w.naturalNames.getNSButton().isEnabled())
        except:
            pass
        lineheight += 28

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

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

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

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

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

        self.w.open()
        self.UpdateSample(self)
        self.w.makeKey()
示例#17
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),
                                       "–",
                                       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.valueChanged,
            continuous=True)
        self.w.editY = vanilla.EditText((-spX - edX, -YOffset, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.valueChanged)
        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.valueChanged,
            continuous=True)
        self.w.edit5 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.valueChanged)

        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.valueChanged,
            continuous=True)
        self.w.edit4 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.valueChanged)

        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.valueChanged,
            continuous=True)
        self.w.edit3 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.valueChanged)

        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.valueChanged,
            continuous=True)
        self.w.edit2 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.valueChanged)

        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.valueChanged,
            continuous=True)
        self.w.edit1 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.valueChanged)

        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.valueChanged,
            continuous=True)
        self.w.edit0 = vanilla.EditText((-spX - edX, move, edX, sliderY),
                                        "0",
                                        sizeStyle='small',
                                        callback=self.valueChanged)

        YOffset += LineHeight * axisCount

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

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

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

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

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

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

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

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

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

        if len(f.instances) > 0:
            if f.currentTab == None:
                f.newTab("HALOGEN halogen 0123")
            if f.currentTab.previewHeight <= 20.0:
                f.currentTab.previewHeight = 150
            self.setupSliders(0, uiList[0])
    def __init__(self):
        # Window 'self.w':
        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()
示例#19
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.text_1 = vanilla.TextBox((15 - 1, 12 + 2, 140, 14),
                                        "Pixel grid step",
                                        sizeStyle='small')
        self.w.text_2 = vanilla.TextBox((15 - 1, 12 + 26, 140, 14),
                                        "Pixel component name",
                                        sizeStyle='small')
        self.w.pixelRasterWidth = vanilla.EditText((140 + 10, 12, -15, 15 + 4),
                                                   "50",
                                                   sizeStyle='small')
        self.w.pixelComponentName = vanilla.EditText(
            (140 + 10, 12 + 24, -15, 15 + 4),
            "pixel",
            sizeStyle='small',
            callback=self.EnableButton)
        self.w.resetWidths = vanilla.CheckBox((15, 63, -15, 20),
                                              "Snap widths to pixel grid",
                                              value=True,
                                              callback=self.SavePreferences,
                                              sizeStyle='small')
        self.w.decomposeComponents = vanilla.CheckBox(
            (15, 63 + 20, -15, 20),
            "Decompose compounds",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.keepWindowOpen = vanilla.CheckBox((15, 63 + 40, -15, 20),
                                                 "Keep window open",
                                                 value=True,
                                                 callback=self.SavePreferences,
                                                 sizeStyle='small')

        # Run Button:
        self.w.runButton = vanilla.Button((-120 - 15, -20 - 15, -15, -15),
                                          "Insert Pixels",
                                          sizeStyle='regular',
                                          callback=self.PixelateMain)
        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.EnableButton(None)

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

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

        # UI ELEMENTS:

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

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

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
        self.MethodReporterMain(None)
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 240
        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
            "Metrics Key Manager",  # window title
            minSize=(windowWidth,
                     windowHeight - 100),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.MetricsKeyManager.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight, boxHeight = self.getMeasurements()

        self.w.LeftMetricsKeysText = vanilla.TextBox(
            (inset, linePos + 2, 70, 14),
            u"Left Keys:",
            sizeStyle='small',
            selectable=True)
        self.w.LeftMetricsKeys = vanilla.TextEditor(
            (inset + 70, linePos, -inset, boxHeight),
            "",
            callback=self.SavePreferences)  #, sizeStyle='small' )

        linePos += boxHeight + 10
        self.w.RightMetricsKeysText = vanilla.TextBox(
            (inset, linePos + 2, 70, 14),
            u"Right Keys:",
            sizeStyle='small',
            selectable=True)
        self.w.RightMetricsKeys = vanilla.TextEditor(
            (inset + 70, linePos, -inset, boxHeight),
            "",
            callback=self.SavePreferences)  #, sizeStyle='small' )

        editFont = NSFont.legibileFontOfSize_(NSFont.smallSystemFontSize())

        for editField in (self.w.LeftMetricsKeys, self.w.RightMetricsKeys):
            editField.getNSTextView().setToolTip_(
                u"Enter a metrics key like '=H', followed by a colon (:), followed by glyph names, spearated by space, comma, or any other separator that cannot be part of a glyph name. (Glyph names can contain A-Z, a-z, 0-9, period, underscore and hyphen.)\nExample: ‘=H: B D E F’."
            )
            editField.getNSTextView().setFont_(editFont)
            editField.getNSScrollView().setHasVerticalScroller_(1)
            editField.getNSScrollView().setRulersVisible_(1)

        # Buttons:
        self.w.resetButton = vanilla.Button(
            (-280 - inset, -20 - inset, -inset - 190, -inset),
            u"⟲ Reset",
            sizeStyle='regular',
            callback=self.SetDefaults)
        self.w.resetButton.getNSButton().setToolTip_(
            u"Resets the contents of the L+R Keys to their (currently only Latin) defaults."
        )

        self.w.scanButton = vanilla.Button(
            (-180 - inset, -20 - inset, -inset - 90, -inset),
            u"↑ Extract",
            sizeStyle='regular',
            callback=self.ScanFontForKeys)
        self.w.scanButton.getNSButton().setToolTip_(
            u"Scans the current font for all metrics keys and lists them here. Normalizes the preceding equals sign (=). No matter whether you typed them with or without an equals sign, they will show up here with one."
        )

        self.w.runButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            u"↓ Apply",
            sizeStyle='regular',
            callback=self.MetricsKeyManagerMain)
        self.w.runButton.getNSButton().setToolTip_(
            u"Parses the current content of the window and will attempt to set the metrics keys of the respective glyphs in the frontmost font."
        )
        self.w.setDefaultButton(self.w.runButton)

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

        # Bind resizing method:
        self.w.bind("resize", self.windowResize)

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
示例#23
0
    def __init__(self):

        ## Preference Files
        self.lastScriptFile = os.path.join(
            "/".join(os.path.realpath(__file__).split("/")[:-1]),
            "lastscript.ini")
        self.preferencesFile = os.path.join(
            "/".join(os.path.realpath(__file__).split("/")[:-1]),
            "preferences.ini")

        ## Preference Defaults
        self.scriptsDirectory = os.path.join(
            os.getenv("HOME"), "Library/Application Support/RoboFont/scripts")
        self.extensionsDirectory = os.path.join(
            os.getenv("HOME"), "Library/Application Support/RoboFont/plugins")
        self.rememberLast = 1
        self.searchLocal = False
        self.searchUpDir = 3
        # Storage
        self.scripts = {"preferences": ""}  # scriptName : scriptPath

        ## Window
        width = 500
        height = 200

        screen = NSScreen.mainScreen()
        screenRect = screen.frame()
        (screenX, screenY), (screenW, screenH) = screenRect
        screenY = -(screenY + screenH)  # convert to vanilla coordinate system
        x = screenX + ((screenW - width) / 2)
        y = screenY + ((screenH - height) / 2)

        self.w = StatusInteractivePopUpWindow((x, y, width, height),
                                              screen=screen)

        self.w.search_box = vanilla.EditText((10, 10, -10, 21),
                                             "",
                                             callback=self.searchScripts)
        """using EditText because SearchBox overrides tab and Enter buttons"""
        self.w.list = vanilla.List((10, 40, -10, -30),
                                   "",
                                   allowsMultipleSelection=0,
                                   doubleClickCallback=self.runScript)
        self.w.ok_button = vanilla.Button((10, -25, -10, 20),
                                          "Run Script",
                                          callback=self.runScript)

        # off Window
        self.w.closeWindow_button = vanilla.Button((10, 300, -10, 20),
                                                   "Close Window",
                                                   callback=self.closeWindow)
        self.w.prev_button = vanilla.Button((10, 300, -10, 20),
                                            "up",
                                            callback=self.previousScript)
        self.w.next_button = vanilla.Button((10, 300, -10, 20),
                                            "down",
                                            callback=self.nextScript)
        self.w.scriptingWindow_button = vanilla.Button(
            (10, 300, -10, 20),
            "Open in ScriptingWindow",
            callback=self.openScriptInScriptingWindow)

        # Preferences Drawer

        self.d = vanilla.Drawer((100, 160), self.w, preferredEdge="bottom")
        self.w.togglePreferencesDrawer_button = vanilla.Button(
            (10, 300, -10, 20),
            "Preferences",
            callback=self.togglePreferencesDrawer)

        self.d.title = vanilla.TextBox((10, 5, -10, 20), "Preferences")

        self.d.scripts_button = vanilla.Button(
            (10, 30, 100, 20), "Scripts", callback=self.preferencesChanged)
        self.d.scripts_path = vanilla.TextBox(
            (120, 30, -1, 20),
            "default: ~/Library/Application Support/RoboFont/scripts")
        self.d.extensions_button = vanilla.Button(
            (10, 60, 100, 20), "Extensions", callback=self.preferencesChanged)
        self.d.extensions_path = vanilla.TextBox(
            (120, 60, -10, 20),
            "default: ~/Library/Application Support/RoboFont/plugins")

        self.d.local_search_checkbox = vanilla.CheckBox(
            (10, 95, 240, 20),
            "Search near open fonts for scripts",
            value=self.searchLocal,
            callback=self.preferencesChanged)
        self.d.local_search_title = vanilla.TextBox((250, 96, 120, 20),
                                                    "Search up:")
        self.d.local_search_count = vanilla.PopUpButton(
            (320, 95, 40, 22), ["0", "1", "2", "3", "4", "5", "6", "7"],
            callback=self.preferencesChanged)
        self.d.local_search_title2 = vanilla.TextBox((365, 96, -10, 20),
                                                     "directories")

        self.d.remember_title = vanilla.TextBox((10, 130, 120, 20),
                                                "Remember Last:")
        self.d.remember_count = vanilla.PopUpButton(
            (120, 128, 40, 22), [
                "0",
                "1",
                "2",
                "3",
                "4",
                "5",
            ],
            callback=self.preferencesChanged)
        self.d.remember_title2 = vanilla.TextBox((170, 130, -10, 20),
                                                 "scripts")

        self.readPreferences()
        self.lastScriptRead()

        # Bindings
        self.w.prev_button.bind("uparrow", [])
        self.w.next_button.bind("downarrow", [])
        self.w.setDefaultButton(self.w.ok_button)
        self.w.closeWindow_button.bind(chr(27), [])  # esc
        self.w.togglePreferencesDrawer_button.bind(',', ['command', 'option'])
        self.w.scriptingWindow_button.bind(
            'o', ['command', 'option'])  # can we bind option+enter?

        self.w.getNSWindow().makeFirstResponder_(
            self.w.search_box.getNSTextField())

        self.w.open()
示例#24
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 470
        windowHeight = 110
        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
            "Set in All TTF Autohint Options",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.SetTTFAutohintOptions.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.helpButton = vanilla.HelpButton((13, 12, 21, 20),
                                               callback=self.openURL)
        self.w.helpButton.getNSButton().setToolTip_(
            "Opens the ttfAutohint documentation for the currently selected option on freetype.org."
        )

        self.w.ttfAutohintOption = vanilla.PopUpButton(
            (38, 13, 175, 17),
            availableOptions,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.ttfAutohintOption.getNSPopUpButton().setToolTip_(
            "Available ttfAutohint options. Pick one from the list. Careful: also contains deprecated options. Refer to the documentation (click on the Help Button on the left), know what you are doing."
        )

        self.w.optionValue = vanilla.EditText((220, 12, -67 - 50, 20),
                                              "value",
                                              callback=self.SavePreferences,
                                              sizeStyle='small')
        self.w.optionValue.getNSTextField().setToolTip_(
            "Value for the currently selected option, if any. Some options can only be set or removed, some have a value."
        )

        self.w.explanation = vanilla.TextBox(
            (15 - 1, 40, -5, -5),
            "Adds or sets this option in all TTF Autohint Options parameters in the current font. For fallback-stem-width, use * for entering the respective instance weight value, and idotless for measuring the width of the interpolated dotless i. The Del button removes this TTFA option from all instances.",
            sizeStyle='small')

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-60 - 50, 10, -15 - 50, 22),
            "Set",
            sizeStyle='regular',
            callback=self.SetTTFAutohintOptionsMain)
        self.w.runButton.getNSButton().setToolTip_(
            "Updates all TTF Autohint Options parameters with the current option (and value, if any) to all instances in the font."
        )

        self.w.delButton = vanilla.Button((-60, 10, -15, 22),
                                          "Del",
                                          sizeStyle='regular',
                                          callback=self.RemoveOption)
        self.w.delButton.getNSButton().setToolTip_(
            "Removes the current option from all TTF Autohint Options parameters in all instances in the font."
        )

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

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

        # enable or disable the edit box
        self.editValueField()

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
示例#25
0
    def __init__(self, checkForUpdates=False, shouldLoad=False):

        self.w = vanilla.Window((800, 600), "Mechanic 2.1", minSize=(600, 400))

        # toolbar

        self._toolbarSearch = vanilla.SearchBox((0, 0, 300, 0),
                                                callback=self.toolbarSearch)
        self._toolbarSearch.getNSSearchField().setFrame_(((0, 0), (300, 22)))

        toolbarItems = [
            dict(
                itemIdentifier="search",
                label="Search",
                view=self._toolbarSearch.getNSSearchField(),
            ),
            dict(itemIdentifier=NSToolbarFlexibleSpaceItemIdentifier),
            dict(
                itemIdentifier="settings",
                label="Settings",
                imageNamed="prefToolbarMisc",
                callback=self.toolbarSettings,
            ),
        ]

        self.w.addToolbar(toolbarIdentifier="MechanicToolbar",
                          toolbarItems=toolbarItems,
                          addStandardItems=False,
                          displayMode="icon")

        # extension list

        columnDescriptions = [
            dict(title="",
                 key="extensionController",
                 width=25,
                 cell=MCExtensionCirleCell.alloc().init(),
                 editable=False),
            dict(title="Extension",
                 key="extensionController",
                 cell=MCImageTextFieldCell.alloc().init(),
                 formatter=MCExtensionDescriptionFormatter.alloc().init(),
                 editable=False),
        ]

        extensionsGroup = vanilla.Group((0, 0, -0, -0))
        extensionsGroup.extensionList = vanilla.List(
            (0, 0, 0, -40),
            [],
            columnDescriptions=columnDescriptions,
            showColumnTitles=False,
            selectionCallback=self.extensionListSelectionCallback,
            doubleClickCallback=self.extensionListDoubleClickCallback,
            allowsMultipleSelection=True,
            rowHeight=39,
            drawFocusRing=False,
        )
        extensionsGroup.extensionList.setSelection([])

        # bottom bar

        extensionsGroup.checkForUpdates = vanilla.Button(
            (10, -30, 160, 22),
            "Check For Updates",
            callback=self.checkForUpdatesCallback,
            sizeStyle="small")

        extensionsGroup.purchaseButton = vanilla.Button(
            (10, -30, 100, 22), "Purchase", callback=self.purchaseCallback)
        extensionsGroup.installButton = vanilla.Button(
            (10, -30, 100, 22), "Install", callback=self.installCallback)
        extensionsGroup.uninstallButton = vanilla.Button(
            (10, -30, 120, 22), "Uninstall", callback=self.uninstallCallback)
        extensionsGroup.updateButton = vanilla.Button(
            (10, -30, 110, 22), "Update", callback=self.updateCallback)

        allButtons = [
            extensionsGroup.purchaseButton, extensionsGroup.installButton,
            extensionsGroup.uninstallButton, extensionsGroup.updateButton
        ]
        for button in allButtons:
            button.show(False)

        # streams

        streamsGroup = vanilla.Group((0, 0, -0, -0))
        streamsGroup.streamsLabel = vanilla.TextBox((0, 0, -0, -0),
                                                    'my streams',
                                                    sizeStyle='small')
        streamsGroup.streamsList = vanilla.List(
            (0, 20, -0, -40), ["my precious", "testing", "pretty", "buggy"],
            allowsEmptySelection=True,
            drawFocusRing=False)
        # streamsGroup.streamsList.getNSTableView().setUsesAlternatingRowBackgroundColors_(False)
        streamsGroup.streamsList.getNSTableView().setSelectionHighlightStyle_(
            NSTableViewSelectionHighlightStyleSourceList)
        streamsGroup.addStream = vanilla.SquareButton((10, -30, 28, 20), "+")
        streamsGroup.removeStream = vanilla.SquareButton((37, -30, 28, 20),
                                                         "-")

        # filters

        developersGroup = vanilla.Group((0, 0, -0, -0))
        developersGroup.developersLabel = vanilla.TextBox((0, 0, -0, -0),
                                                          'developers',
                                                          sizeStyle='small')
        developersGroup.developersList = vanilla.List(
            (0, 20, -0, -0), [],
            drawHorizontalLines=False,
            drawFocusRing=False,
            selectionCallback=self.filtersCallback)
        developersGroup.developersList.getNSTableView(
        ).setUsesAlternatingRowBackgroundColors_(False)
        # developersGroup.developersList.getNSTableView().setSelectionHighlightStyle_(NSTableViewSelectionHighlightStyleSourceList)

        tagsGroup = vanilla.Group((0, 0, -0, -0))
        tagsGroup.tagsLabel = vanilla.TextBox((0, 0, -0, -0),
                                              'tags',
                                              sizeStyle='small')
        tagsGroup.tagsList = vanilla.List(
            (0, 20, -0, -0), [],
            drawHorizontalLines=False,
            drawFocusRing=False,
            selectionCallback=self.filtersCallback)
        tagsGroup.tagsList.getNSTableView(
        ).setUsesAlternatingRowBackgroundColors_(False)
        # tagsGroup.tagsList.getNSTableView().setSelectionHighlightStyle_(NSTableViewSelectionHighlightStyleSourceList)

        sourcesGroup = vanilla.Group((0, 0, -0, -0))
        sourcesGroup.sourcesLabel = vanilla.TextBox((0, 0, -0, -0),
                                                    'sources',
                                                    sizeStyle='small')
        sourcesGroup.sourcesList = vanilla.List(
            (0, 20, -0, -0), [],
            drawHorizontalLines=False,
            drawFocusRing=False,
            selectionCallback=self.filtersCallback)
        sourcesGroup.sourcesList.getNSTableView(
        ).setUsesAlternatingRowBackgroundColors_(False)
        # sourcesGroup.sourcesList.getNSTableView().setSelectionHighlightStyle_(NSTableViewSelectionHighlightStyleSourceList)

        # split views

        filtersGroup = vanilla.SplitView((0, -0, -0, -0),
                                         paneDescriptions=[
                                             dict(view=developersGroup,
                                                  identifier="developers"),
                                             dict(view=tagsGroup,
                                                  identifier="tags"),
                                             dict(view=sourcesGroup,
                                                  identifier="sources"),
                                         ],
                                         dividerStyle='thin')

        mainPanes = vanilla.SplitView((0, 0, -0, -0),
                                      paneDescriptions=[
                                          dict(view=filtersGroup,
                                               identifier="filters",
                                               size=160,
                                               minSize=160,
                                               maxSize=240),
                                          dict(view=extensionsGroup,
                                               identifier="extensions"),
                                      ],
                                      isVertical=False,
                                      dividerStyle='thin')

        self.w.splitView = vanilla.SplitView((0, 0, -0, -0),
                                             paneDescriptions=[
                                                 dict(view=streamsGroup,
                                                      identifier="streams",
                                                      size=140,
                                                      minSize=120,
                                                      maxSize=200),
                                                 dict(view=mainPanes,
                                                      identifier="main"),
                                             ],
                                             isVertical=True,
                                             dividerStyle='thin')

        self._extensionsGroup = extensionsGroup
        self._developersGroup = developersGroup
        self._tagsGroup = tagsGroup
        self._sourcesGroup = sourcesGroup

        self.w.open()

        self._didCheckedForUpdates = False
        if shouldLoad:
            self.loadExtensions(checkForUpdates)
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 170
        windowWidthResize = 100  # user can resize width by this value
        windowHeightResize = 0  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Set Subscript and Superscript Parameters",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.CalculateSubscriptAndSuperscriptParameters.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),
            "Calculate custom parameters in Font Info > Masters:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.subscriptCheck = vanilla.CheckBox((inset, linePos, 80, 20),
                                                 "Subscript:",
                                                 value=True,
                                                 callback=self.SavePreferences,
                                                 sizeStyle='small')
        self.w.subscriptSample = vanilla.EditText(
            (inset + 85, linePos, -inset - 175, 19),
            "oneinferior",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.subscriptReferenceText = vanilla.TextBox(
            (-inset - 170, linePos + 3, -inset - 95, 14),
            "in relation to:",
            sizeStyle='small',
            selectable=True)
        self.w.subscriptReference = vanilla.EditText(
            (-inset - 95, linePos, -inset - 25, 19),
            "one",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.subscriptReset = vanilla.SquareButton(
            (-inset - 20, linePos + 0.5, -inset, 18),
            "↺",
            sizeStyle='small',
            callback=self.resetValues)
        # tooltips:
        tooltip = "If enabled, will calculate: subscriptXOffsetName, subscriptYOffsetName, subscriptXSizeName, subscriptYSizeName. The subscript glyph (on the left) will be measured in relation to the reference glyph on the right; offset and size scale will be computed from their differences."
        self.w.subscriptSample.getNSTextField().setToolTip_(tooltip)
        self.w.subscriptReference.getNSTextField().setToolTip_(tooltip)
        self.w.subscriptCheck.getNSButton().setToolTip_(tooltip)
        self.w.subscriptReferenceText.getNSTextField().setToolTip_(tooltip)
        self.w.subscriptReset.getNSButton().setToolTip_(
            "Resets the subscript reference glyphs to oneinferior vs. one.")
        linePos += lineHeight

        self.w.superscriptCheck = vanilla.CheckBox(
            (inset, linePos, 80, 20),
            "Superscript:",
            value=True,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.superscriptSample = vanilla.EditText(
            (inset + 85, linePos, -inset - 175, 19),
            "onesuperior",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.superscriptReferenceText = vanilla.TextBox(
            (-inset - 170, linePos + 3, -inset - 95, 14),
            "in relation to:",
            sizeStyle='small',
            selectable=True)
        self.w.superscriptReference = vanilla.EditText(
            (-inset - 95, linePos, -inset - 25, 19),
            "one",
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.superscriptReset = vanilla.SquareButton(
            (-inset - 20, linePos, -inset, 18),
            "↺",
            sizeStyle='small',
            callback=self.resetValues)
        # tooltips:
        tooltip = "If enabled, will calculate: superscriptXOffsetName, superscriptYOffsetName, superscriptXSizeName, superscriptYSizeName. The superscript glyph (on the left) will be measured in relation to the reference glyph on the right; offset and size scale will be computed from their differences."
        self.w.superscriptSample.getNSTextField().setToolTip_(tooltip)
        self.w.superscriptReference.getNSTextField().setToolTip_(tooltip)
        self.w.superscriptCheck.getNSButton().setToolTip_(tooltip)
        self.w.superscriptReferenceText.getNSTextField().setToolTip_(tooltip)
        self.w.superscriptReset.getNSButton().setToolTip_(
            "Resets the superscript reference glyphs to onesuperior vs. one.")
        linePos += lineHeight

        self.w.roundValues = vanilla.CheckBox((inset, linePos, 130, 20),
                                              "Round all values by:",
                                              value=False,
                                              callback=self.SavePreferences,
                                              sizeStyle='small')
        self.w.roundBy = vanilla.EditText((inset + 130, linePos, 50, 19),
                                          "10",
                                          callback=self.SavePreferences,
                                          sizeStyle='small')
        self.w.xSizeEqualsYSize = vanilla.CheckBox(
            (inset + 200, linePos, -inset, 20),
            "xSize=ySize",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        # tooltips:
        tooltip = "If enabled, will round all calculated values by the given amount. Recommended: 5 or 10."
        self.w.roundValues.getNSButton().setToolTip_(tooltip)
        self.w.roundBy.getNSTextField().setToolTip_(tooltip)
        self.w.xSizeEqualsYSize.getNSButton().setToolTip_(
            "If enabled, will set the horizontal scale to the same value as the vertical scale, ensuring a proportional scale. Especially useful for italics."
        )
        linePos += lineHeight

        self.w.syncWithFirstMaster = vanilla.CheckBox(
            (inset, linePos, -inset, 20),
            "Sync all values with first master",
            value=False,
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.syncWithFirstMaster.getNSButton().setToolTip_(
            "If enabled, will insert the same values in all masters.")
        linePos += lineHeight

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

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Calculate Subscript and Superscript Parameters' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.updateUI()
        self.w.open()
        self.w.makeKey()
示例#27
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 110
        windowWidthResize = 500  # user can resize width by this value
        windowHeightResize = 0  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Set Hidden App Preferences",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.SetHiddenAppPreferences.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight = 8, 12, 22
        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, 14),
            "Choose and apply the app defaults:",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.pref = vanilla.ComboBox((inset, linePos - 2, -inset - 100, 25),
                                       self.prefs,
                                       callback=self.SavePreferences,
                                       sizeStyle='regular')
        self.w.pref.getNSComboBox().setFont_(
            NSFont.userFixedPitchFontOfSize_(11))
        self.w.pref.getNSComboBox().setToolTip_(
            "Pick an app default from the list, or type in an identifier.")

        self.w.prefValue = vanilla.EditText((-inset - 90, linePos, -inset, 21),
                                            "",
                                            sizeStyle='regular')
        self.w.prefValue.getNSTextField().setToolTip_(
            "Enter a value for the chosen app default.")
        linePos += lineHeight

        # Run Button:
        self.w.delButton = vanilla.Button(
            (-170 - inset, -20 - inset, -90 - inset, -inset),
            "Reset",
            sizeStyle='regular',
            callback=self.SetHiddenAppPreferencesMain)
        self.w.delButton.getNSButton().setToolTip_(
            "Will delete the setting, effectively resetting it to its default."
        )

        self.w.runButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            "Apply",
            sizeStyle='regular',
            callback=self.SetHiddenAppPreferencesMain)
        self.w.runButton.getNSButton().setToolTip_(
            "Sets the entered value for the chosen app default.")
        self.w.setDefaultButton(self.w.runButton)

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
示例#28
0
    def __init__(self):

        self.drawing = False
        self.fixer = None
        self.showLabels = False
        self.errors = {}

        self.w = vanilla.FloatingWindow((240, 298),
                                        "RedArrow",
                                        closable=not (tool_mode))
        x0 = 25
        x1 = 150
        y = 5
        self.w.showGlyphStatusButton = vanilla.CheckBox(
            (10, y, -10, 25),
            "Show Red Arrows",
            callback=self.checkGlyphStatus,
            sizeStyle="small",
        )
        if tool_mode:
            y += 28
            self.w.fixSelectedButton = vanilla.Button(
                (10, y, -10, 25),
                "Fix Selected",
                callback=self._fixSelected,
                sizeStyle="small",
            )
        y += 28
        self.w.drawLabels = vanilla.CheckBox(
            (10, y, -10, 25),
            "Show Labels",
            callback=self.toggleShowLabels,
            sizeStyle="small",
        )
        y += 28
        self.w.optionsShowBoundingBox = vanilla.CheckBox(
            (10, y, -10, 25),
            "Show Bounding Box",
            value=options.get("show_bbox"),
            callback=self.setShowBoundingBox,
            sizeStyle="small",
        )
        y += 28
        self.w.optionsFractionalIgnorePointZero = vanilla.CheckBox(
            (10, y, -10, 25),
            "Ignore .0 Fractional Coordinates",
            value=options.get("fractional_ignore_point_zero"),
            callback=self.setFractionalIgnorePointZero,
            sizeStyle="small",
        )

        y += 42
        self.w.optionsThresholdLabel = vanilla.TextBox(
            (8, y, -10, 25),
            u"Detection Threshold Values (\u2030 em):",
            sizeStyle="small",
        )

        y += 28
        self.w.optionsExtremumToleranceLabel = vanilla.TextBox(
            (x0, y, 120, 25),
            "Extremum Points",
            sizeStyle="small",
        )
        self.w.optionsExtremumTolerance = vanilla.EditText(
            (x1, y - 3, 32, 21),
            options.get("extremum_ignore_badness_below"),
            callback=self.setExtremumTolerance,
            sizeStyle="small",
        )

        y += 28
        self.w.optionsZeroHandlesToleranceLabel = vanilla.TextBox(
            (x0, y, x1 - x0, 25),
            "Zero Handles",
            sizeStyle="small",
        )
        self.w.optionsZeroHandlesTolerance = vanilla.EditText(
            (x1, y - 3, 32, 21),
            options.get("zero_handles_max_distance"),
            callback=self.setZeroHandlesTolerance,
            sizeStyle="small",
        )

        y += 28
        self.w.optionsSmoothConnectionMaxDistLabel = vanilla.TextBox(
            (x0, y, x1 - x0, 25),
            "Smooth Connections",
            sizeStyle="small",
        )
        self.w.optionsSmoothConnectionMaxDist = vanilla.EditText(
            (x1, y - 3, 32, 21),
            options.get("smooth_connection_max_distance"),
            callback=self.setSmoothConnectionMaxDist,
            sizeStyle="small",
        )

        y += 28
        self.w.optionsCollinearVectorsMaxDistLabel = vanilla.TextBox(
            (x0, y, x1 - x0, 25),
            "Collinear Lines",
            sizeStyle="small",
        )
        self.w.optionsCollinearVectorsMaxDist = vanilla.EditText(
            (x1, y - 3, 32, 21),
            options.get("collinear_vectors_max_distance"),
            callback=self.setCollinearVectorsMaxDist,
            sizeStyle="small",
        )

        y += 28
        self.w.optionsSemiHVVectorsMinDistLabel = vanilla.TextBox(
            (x0, y, x1 - x0, 25),
            "Semi-hor./-vert. Lines",
            sizeStyle="small",
        )
        self.w.optionsSemiHVVectorsMinDist = vanilla.EditText(
            (x1, y - 3, 32, 21),
            options.get("semi_hv_vectors_min_distance"),
            callback=self.setSemiHVVectorsMinDist,
            sizeStyle="small",
        )
        self.w.showGlyphStatusButton.set(True)
        self.showRedArrows()
        self.setUpBaseWindowBehavior()
        self.w.open()
示例#29
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()
示例#30
0
    def __init__(self, data, unicodeVersionString, versionString, joiningTypes=None):
        self.data = data
        self.dataByCategory = collectSearchCategories(data)
        if joiningTypes is None:
            self.joiningTypes = {}
        else:
            self.joiningTypes = joiningTypes
        self.catNames = sorted(self.dataByCategory.keys())
        self.currentSelection = []
        self._typing = False
        self.unicodeVersion = unicodeVersionString
        
        
        topRow = 80
        catWidth = 320

        self.w = vanilla.Window((1200, 500), 
            ("GlyphBrowser with %s and %s"%(self.unicodeVersion, versionString)), 
            minSize=(800, 500),
            autosaveName = "com.letterror.glyphBrowser.mainWindow",
            )
        columnDescriptions = [
            {    'title': u"",
                 'key': 'col1',
                 'width': 50},
            {    'title': u"",
                 'key': 'col2',
                 'width': 50},
            {    'title': "Categories, ranges, namelists",
                    'key': 'name'},
        ]
        self.w.catNames = vanilla.List((5, topRow, catWidth, -5), [],
            columnDescriptions=columnDescriptions,
            selectionCallback=self.callbackCatNameSelect)
        charWidth = 18
        imageCell = ImageMapImageCell.alloc().init()
        imageCell.setImages(joiningTypesimageMap)
        columnDescriptions = [
            {    'title': u"❡",
                 'key': 'nameinfont',
                 'width': charWidth,
                 },
            {    'title': "#",
                 'key': 'unicodeinfont',
                 'width': charWidth,
                 },

            {    'title': "GNUFL name",
                 'key': 'name',
                 'width': 200, },
            {    'title': "Unicode",
                 'key': 'uniHex',
                 'width': 50},
            {    'title': "Cat",
                 'key': 'category',
                 'width': 30},
            {    'title': "jT",
                 'key': 'joiningType',
                 'width': 50,
                 'cell':imageCell
                 },
            {    'title': "Char",
                 'key': 'string',
                 'width': 30},
            {    'title': "Unicode Description",
                 'key': 'uniName',
                     },
            ]
        self.w.searchBox = vanilla.SearchBox((-200, topRow, -5, 22), "", callback=self.callbackSearch)


        dropSettings = {
            'type': AppKit.NSFilenamesPboardType,
            'callback': self.callbackDropOnLocationList,
            'allowDropBetweenRows': False
        }
        if version >= "3.2":
            self.w.selectedNames = vanilla.List(
                (catWidth+10, topRow, -205, -5),
                [],
                columnDescriptions=columnDescriptions,
                selectionCallback=self.callbackGlyphNameSelect,
                otherApplicationDropSettings=dropSettings,
                menuCallback = self.namesMenu_buildMenu,
            )
        else:
            self.w.selectedNames = vanilla.List(
                (catWidth+10, topRow, -205, -5),
                [],
                columnDescriptions=columnDescriptions,
                selectionCallback=self.callbackGlyphNameSelect,
                otherApplicationDropSettings=dropSettings,
            )
        self.w.selectionUnicodeText = vanilla.EditText((0, 0, -0, topRow-5), placeholder=choice(glyphNameBrowserNames), callback=self.callbackEditUnicodeText)
        s = self.w.selectionUnicodeText.getNSTextField()
        s.setFocusRingType_(NSFocusRingTypeNone)

        self.w.selectionGlyphNames = vanilla.EditText((-200, topRow+28, -5, -300), "Selectable Glyph Names", sizeStyle="small")
        self.checkSampleSize()
        self.w.addGlyphPanelButton = vanilla.Button((-200, -65, -5, 20), "Add to Font", callback=self.callbackOpenGlyphSheet)
        self.w.toSpaceCenter = vanilla.Button((-200, -115, -5, 20), "To Spacecenter", callback = self.toSpaceCenter)
        self.w.lookupSelected = vanilla.Button((-200, -90, -5, 20), "Lookup", callback=self.callbackLookup)
        self.w.progress = vanilla.TextBox((-190, -35, -10, 40), "", sizeStyle="small")
        self.w.bind("became main", self.callbackWindowMain)
        self.w.setDefaultButton(self.w.addGlyphPanelButton)

        self.w.addGlyphPanelButton.enable(False)
        self.w.toSpaceCenter.enable(False)
        self.update()
        self.w.bind("close", self.windowClosing)
        self.w.open()
        self.w.catNames.setSelection([0])