Esempio n. 1
0
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 400
		windowHeight = 300
		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
			"Merge Suffixed Glyphs into Color Layers", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.MergeSuffixedGlyphsIntoColorLayers.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), "Merge suffixed glyphs into the following color indexes:", sizeStyle='small', selectable=True )
		linePos += lineHeight
		
		self.w.indexToSuffix = vanilla.TextEditor( (2, linePos, -2, -110), "# Syntax: CPAL index = glyph name suffix\n# list them in chronological order (bottom-up)\n# use hashtags for comments\n0=.shadow\n2=.body\n1=.front", callback=self.SavePreferences, checksSpelling=False )
		#self.w.indexToSuffix.getNSTextEditor().setToolTip_("Syntax: colorindex=.suffix, use hashtags for comments. List them in chronological order (bottom-up). Example:\n0=.shadow\n2=.body\n1=.front")
		
		self.w.indexToSuffix.getNSScrollView().setHasVerticalScroller_(1)
		self.w.indexToSuffix.getNSScrollView().setHasHorizontalScroller_(1)
		self.w.indexToSuffix.getNSScrollView().setRulersVisible_(0)
		legibleFont = NSFont.legibileFontOfSize_(NSFont.systemFontSize())
		textView = self.w.indexToSuffix.getNSTextView()
		textView.setFont_(legibleFont)
		textView.setHorizontallyResizable_(1)
		textView.setVerticallyResizable_(1)
		textView.setAutomaticDataDetectionEnabled_(1)
		textView.setAutomaticLinkDetectionEnabled_(1)
		textView.setDisplaysLinkToolTips_(1)
		textSize = textView.minSize()
		textSize.width = 1000
		textView.setMinSize_(textSize)
		
		linePos = -105
		
		self.w.disableSuffixedGlyphs = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Deactivate export for glyphs with listed suffixes", value=True, callback=self.SavePreferences, sizeStyle='small' )
		linePos += lineHeight
		
		self.w.deletePreexistingColorLayers = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Delete preexisting Color layers in target glyphs", value=True, callback=self.SavePreferences, sizeStyle='small' )
		linePos += lineHeight
		
		self.w.processCompleteFont = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Process complete font (otherwise only add into selected glyphs)", value=False, callback=self.SavePreferences, sizeStyle='small' )
		linePos += lineHeight
		
		# Run Button:
		self.w.runButton = vanilla.Button( (-80-inset, -20-inset, -inset, -inset), "Merge", sizeStyle='regular', callback=self.MergeSuffixedGlyphsIntoColorLayersMain )
		# self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print("Note: 'Merge Suffixed Glyphs into Color Layers' could not load preferences. Will resort to defaults")
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
Esempio n. 2
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 380
        windowHeight = 160
        windowWidthResize = 500  # user can resize width by this value
        windowHeightResize = 600  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Axis Mapper",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.AxisMapper.mainwindow"  # stores last window position and size
        )

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

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

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

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

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

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

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

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

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

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Esempio n. 3
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 550
        windowHeight = 260
        windowWidthResize = 1000  # user can resize width by this value
        windowHeightResize = 1000  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Encoding Converter",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.EncodingConverter.mainwindow"  # stores last window position and size
        )

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

        self.w.descriptionText = vanilla.TextBox(
            (inset, linePos + 2, -inset, 14),
            "Enter conversion text (see tooltips):",
            sizeStyle='small',
            selectable=True)
        linePos += lineHeight

        self.w.recipe = vanilla.TextEditor((1, linePos, -1, -inset * 3),
                                           text="",
                                           callback=self.SavePreferences,
                                           checksSpelling=False)
        self.w.recipe.getNSTextView().setToolTip_(
            "- Freely write comments and empty lines\n- Rename: Lines containing a dash (-) followed by a greater sign (>) will trigger glyph renaming, with or without spaces between names\n- Recipe: Lines containing glyph recipes with plus (+) and equals (=) will be treated like in Glyph > Add Glyphs... as long as the do not contain any space\n- Recipes will overwrite existing glyphs. Renamings will create a number-suffixed glyph if a glyph with the same name already exists."
        )
        self.w.recipe.getNSScrollView().setHasVerticalScroller_(1)
        self.w.recipe.getNSScrollView().setHasHorizontalScroller_(1)
        self.w.recipe.getNSScrollView().setRulersVisible_(0)

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

        # Run Button:
        self.w.openButton = vanilla.Button((inset, -20 - inset, 110, -inset),
                                           "Open Text…",
                                           sizeStyle='regular',
                                           callback=self.importEncoding)
        self.w.saveButton = vanilla.Button(
            (inset + 120, -20 - inset, 110, -inset),
            "Save Text…",
            sizeStyle='regular',
            callback=self.exportEncoding)
        self.w.resetButton = vanilla.Button(
            (inset + 260, -20 - inset, 100, -inset),
            "Reset Text",
            sizeStyle='regular',
            callback=self.resetEncoding)
        self.w.runButton = vanilla.Button(
            (-120 - inset, -20 - inset, -inset, -inset),
            "Convert Font",
            sizeStyle='regular',
            callback=self.EncodingConverterMain)
        self.w.setDefaultButton(self.w.runButton)

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

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Esempio n. 4
0
    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()