示例#1
0
    def glyphEditorWantsToolbarItems(self, info):

        toolbarItems = info['itemDescriptions']

        label = 'Add Overlap'
        identifier = 'addOverlap'
        callback = self.addOverlap
        index = -2

        bundle = ExtensionBundle("AddOverlap")
        icon = bundle.getResourceImage("AddOverlapButton")

        view = ToolbarGlyphTools((30, 25), [dict(image=icon, toolTip=label)],
                                 trackingMode="one")

        newItem = dict(itemIdentifier=identifier,
                       label=label,
                       callback=callback,
                       view=view)

        toolbarItems.insert(index, newItem)
示例#2
0
# I should probably redo this at some point using angled point instead of doing the math myself. Next time...

from mojo.UI import CurrentGlyphWindow, UpdateCurrentGlyphView
from mojo.events import BaseEventTool, installTool, EditingTool
from AppKit import *
from defconAppKit.windows.baseWindow import BaseWindowController
from mojo.drawingTools import *
from mojo.extensions import ExtensionBundle
from vanilla import *
from mojo.extensions import getExtensionDefault, setExtensionDefault, getExtensionDefaultColor, setExtensionDefaultColor
from lib.tools.defaults import getDefault
from lib.tools import bezierTools

bundle = ExtensionBundle("BoundingTool")
toolbarIcon = bundle.getResourceImage("boundingTool")
try:
    toolbarIcon.setSize_((16, 16))
except:
    pass


class TX:
    @classmethod
    def formatStringValue(cls, f):
        return format(f, '.1f').rstrip('0').rstrip('.')

    @classmethod
    def getItalicOffset(cls, yoffset, italicAngle):
        '''
        Given a y offset and an italic angle, calculate the x offset.
import os
from AppKit import NSApp, NSMenuItem, NSAlternateKeyMask, NSCommandKeyMask
import math
from vanilla import ImageButton
from mojo.tools import CallbackWrapper
from mojo.UI import CurrentFontWindow, getDefault, setDefault
from mojo.extensions import ExtensionBundle, getExtensionDefault, setExtensionDefault
from mojo.subscriber import Subscriber, registerFontOverviewSubscriber

bundle = ExtensionBundle(path="../../fitGlyphCells.roboFontExt")
icon = bundle.getResourceImage("_icon_Fit")


class fitGlyphCells(Subscriber):
    '''
	Scale the glyph cells in Font Overview as large as 
	they can be while justified to the width of the frame.
	
	Ryan Bugden
	'''
    def build(self):

        self.key = 'com.ryanbugden.FitGlyphCells.FitOnStartup'
        self.startupSetting = getExtensionDefault(self.key, fallback=1)

        # put in the menu item
        title = "Fit Glyph Cells on Open"
        font_menu = NSApp().mainMenu().itemWithTitle_("Font")
        if not font_menu:
            print("Fit Glyph Cells - Error")
            return
示例#4
0
# I should probably redo this at some point using angled point instead of doing the math myself. Next time...

from mojo.UI import CurrentGlyphWindow, UpdateCurrentGlyphView
from mojo.events import BaseEventTool, installTool, EditingTool
from AppKit import *
from defconAppKit.windows.baseWindow import BaseWindowController
from mojo.drawingTools import *
from mojo.extensions import ExtensionBundle
from vanilla import *
from mojo.extensions import getExtensionDefault, setExtensionDefault, getExtensionDefaultColor, setExtensionDefaultColor
from lib.tools.defaults import getDefault
from lib.tools import bezierTools

bundle = ExtensionBundle("BoundingTool")
toolbarIcon = bundle.getResourceImage("boundingTool")
try:
    toolbarIcon.setSize_((16, 16))
except:
    pass

class TX:
    
    @classmethod
    def formatStringValue(cls, f): return format(f, '.1f').rstrip('0').rstrip('.')    
    @classmethod
    def getItalicOffset(cls, yoffset, italicAngle):
        '''
        Given a y offset and an italic angle, calculate the x offset.
        '''
        from math import radians, tan