Example #1
0
 def _uninstallable(self):
     list = self.installationList.get()
     selections = self.installationList.getSelection()
     uninstallable = []
     for selection in selections:
         extension = ExtensionBundle(name=list[selection]['filename'])
         if extension.bundleExists():
             uninstallable.append(extension)
     return uninstallable
Example #2
0
    def remoteInstall(self, forcedUpdate=False, showMessages=False):
        """
        Install the extension from the remote. This will call `extensionNeedsUpdate()`

        Optional set `forcedUpdate` to `True` if its needed to install the extension anyhow
        """
        if self.isExtensionInstalled(
        ) and not self.extensionNeedsUpdate() and not forcedUpdate:
            # dont download and install if the current intall is newer (only when it forced)
            return
        # get the zip path
        zipPath = self.remoteZipPath()

        try:
            # try to download the zip file
            # and fail silently with a custom error message
            contents = getDataFromURL(zipPath)
        except Exception as e:
            message = "Could not download the extension zip file for: '%s'" % self.extensionName(
            )
            logger.error(message)
            logger.error(e)
            raise ExtensionRepoError(message)
        # create a temp folder
        tempFolder = tempfile.mkdtemp()
        try:
            # try to extract the zip
            # and fail silently with a custom message
            with zipfile.ZipFile(BytesIO(contents)) as z:
                z.extractall(tempFolder)
        except Exception as e:
            message = "Could not extract the extension zip file for: '%s'" % self.extensionName(
            )
            logger.error(message)
            logger.error(e)
            raise ExtensionRepoError(message)
        # find the extension path
        extensionPath = findExtensionInRoot(
            os.path.basename(self.extensionPath), tempFolder)
        if extensionPath:
            # if found get the bundle and install it
            bundle = ExtensionBundle(path=extensionPath)
            bundle.install(showMessages=showMessages)
            self.resetRemembered()
        else:
            # raise an custom error when the extension is not found in the zip
            message = "Could not find the extension: '%s'" % self.extensionPath
            logger.error(message)
            raise ExtensionRepoError(message)
        # remove the temp folder with the extracted zip
        shutil.rmtree(tempFolder)
Example #3
0
 def __init__(self, name=None, path=None):
     self.config = {}
     self.configured = False
     self.name = name
     self.bundle = ExtensionBundle(name=self.name, path=path)
     self.path = self.bundle.bundlePath()
     self.configure()
Example #4
0
class spaceCenterFlipButton(object):
    def __init__(self):
        addObserver(self, "spaceCenterDidOpen", "spaceCenterDidOpen")
        self.bundle = ExtensionBundle("SpaceFlip")
        self.path1 = self.bundle.resourcesPath() + '/flipButton.pdf'
        self.path2 = self.bundle.resourcesPath() + '/flipButton2.pdf'
        self.flipped = False

    def spaceCenterDidOpen(self, notification):

        s = notification["window"].window()
        s.flipButton = ImageButton((10, 10, 26, 22),
                                   imagePath=self.path1,
                                   title=None,
                                   bordered=0,
                                   callback=self.flip)

        preLine = s.spacingView.top.glyphLinePreInput
        line = s.spacingView.top.glyphLineInput
        for view in [preLine, line]:
            l, t, w, h = view.getPosSize()
            view.setPosSize((l + 32, t, w, h))

        self.s = s

    def flip(self, sender=None):
        sp = CurrentSpaceCenter()
        sp.glyphLineView.contentView().setDisplayMode_("Upside Down")

        if not self.flipped:
            self.s.flipButton.setImage(imagePath=self.path2)
            self.flipped = True
        else:
            self.s.flipButton.setImage(imagePath=self.path1)
            self.flipped = False
Example #5
0
class spaceCenterFlipButton(object):
    def __init__(self):
        addObserver(self, "spaceCenterDidOpen", "spaceCenterDidOpen")
        self.bundle = ExtensionBundle("SpaceFlip")
        self.path1 = self.bundle.resourcesPath() + '/flipButton.pdf'
        self.path2 = self.bundle.resourcesPath() + '/flipButton2.pdf'
        self.flipped = False
        
    def spaceCenterDidOpen(self, notification):
        
        s = notification["window"].window()
        s.flipButton = ImageButton((10, 10, 26, 22), imagePath=self.path1, title=None, bordered=0, callback=self.flip)
        
        preLine = s.spacingView.top.glyphLinePreInput
        line = s.spacingView.top.glyphLineInput
        for view in [preLine, line]:
            l, t, w, h = view.getPosSize()
            view.setPosSize((l+32, t, w, h))

        self.s = s
            
    def flip(self, sender=None):
        sp = CurrentSpaceCenter()
        sp.glyphLineView.contentView().setDisplayMode_("Upside Down")

        if not self.flipped:
            self.s.flipButton.setImage(imagePath=self.path2)
            self.flipped = True
        else:
            self.s.flipButton.setImage(imagePath=self.path1)
            self.flipped = False
Example #6
0
    def _remoteInstallCallback(self, url, data, error):
        if error:
            message = "Could not download the extension zip file for: '%s' at url: '%s'" % (
                self.extensionName(), url)
            logger.error(message)
            logger.error(error)
            raise ExtensionRepoError(message)

        # create a temp folder
        tempFolder = tempfile.mkdtemp()
        try:
            # try to extract the zip
            # and fail silently with a custom message
            with zipfile.ZipFile(io.BytesIO(data.bytes())) as z:
                z.extractall(tempFolder)
        except Exception as e:
            message = "Could not extract the extension zip file for: '%s' at url: '%s'" % (
                self.extensionName(), url)
            logger.error(message)
            logger.error(e)
            raise ExtensionRepoError(message)

        # find the extension path
        extensionPath = findExtensionInRoot(
            os.path.basename(self.extensionPath), tempFolder)
        if extensionPath:
            # if found get the bundle and install it
            bundle = ExtensionBundle(path=extensionPath)
            bundle.install(showMessages=self._showMessages)
            self.resetRemembered()
        else:
            # raise an custom error when the extension is not found in the zip
            message = "Could not find the extension: '%s'" % self.extensionPath
            logger.error(message)
            raise ExtensionRepoError(message)

        # remove the temp folder with the extracted zip
        shutil.rmtree(tempFolder)

        # clear the cache for this extension icon so it may be reloaded
        if self.extensionIconURL():
            CachingURLReader.invalidate_cache_for_url(self.extensionIconURL())
            self._extensionIcon = None

        self._needsUpdate = False
        postEvent(EXTENSION_DID_REMOTE_INSTALL_EVENT_KEY, item=self)
Example #7
0
    def addList(self):
        self.configured = []
        for name in ExtensionBundle.allExtentions():
            extension = Extension(name=name)
            if extension.configured:
                self.configured.append(extension)

        self.settingsList = SettingsList((20,75,-20,-20),
                                         self.configured,
                                         editCallback=self.update)
Example #8
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)
Example #9
0
 def _fetchUpdates(self):
     updates = []
     ignore = Storage.get('ignore')
     for name in ExtensionBundle.allExtentions():
         extension = Extension(name=name)
         if (not extension.bundle.name in ignore and
                 extension.configured):
             try:
                 if not extension.is_current_version():
                     updates.append(extension)
             except:
                 self.unreachable = True
     self._setCached(updates)
     return updates
Example #10
0
class Extension(object):
    """Facilitates loading the configuration from and updating extensions."""
    def __init__(self, name=None, path=None):
        self.config = {}
        self.configured = False
        self.name = name
        self.bundle = ExtensionBundle(name=self.name, path=path)
        self.path = self.bundle.bundlePath()
        self.configure()

    def configure(self):
        """Set config attribute from info.plist contents."""
        self.configPath = os.path.join(self.path, 'info.plist')
        if(os.path.exists(self.configPath)):
            self.config = plistlib.readPlist(self.configPath)
            if 'repository' in self.config:
                extension_path = self.config['extensionPath'] if hasattr(self.config, 'extensionPath') else None
                self.remote = GithubRepo(self.config['repository'], 
                                         name=self.name,
                                         extension_path=extension_path)
                self.configured = True
            
    def update(self, extension_path=None):
        """Download and install the latest version of the extension."""
        if extension_path is None:
            extension_path = self.remote.download()
        
        new_extension = Extension(path=extension_path)

        self.bundle.deinstall()
        new_extension.bundle.install()
        
    def is_current_version(self):
        """Return if extension is at curent version"""
        if not self.remote.version:
            self.remote.get()
        return Version(self.remote.version) <= Version(self.config['version'])
Example #11
0
 def __init__(self):
     self.bundle = ExtensionBundle("JetSetGlyphs")
     self.source_font = False
     self.target_font = False
     self.source_name = ""
     self.source_glyphs = []
     self.glyphset = []
     self.current_glyphs = []
     self.filtered = False
     self.w = Window((10, 20, 240, 560), "JetSetGlyphs", minSize=(240, 450))
     self.w.importFontButton = Button((20, 10, -20, 20), "Import from Font", sizeStyle="small", callback=self.ImportGlyphsFromFont)
     self.w.importFileButton = Button((20, 35, -20, 20), u"Import from File\u2026", sizeStyle="small", callback=self.ShowImportDialog)
     self.w.departBox = Box((10, 65, -10, 100))
     self.w.departPanel = Box((15, 70, -15, 36))
     self.w.departIcon = ImageView((21, 73, 28, 28))
     self.w.departIcon.setImage(imageObject=(self.bundle.get("departures")))
     self.w.departTitle = TextBox((54, 71, -10, 20), "Departures")
     self.w.departTitle.getNSTextField().setTextColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.75))
     self.w.departCount = TextBox((54, 89, -10, 16), "--", sizeStyle="small")
     self.w.departCount.getNSTextField().setTextColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.75))
     self.w.filterListBox = SearchBox((20, 110, -20, 20), sizeStyle="small", placeholder="Search", callback = self.FilterGlyphListView)
     self.w.arriveBox = Box((10, -160, -10, -92))
     self.w.arrivePanel = Box((15, -134, -15, 36))
     self.w.arriveIcon = ImageView((21, -131, 28, 28))
     self.w.arriveIcon.setImage(imageObject=(self.bundle.get("arrivals")))
     self.w.glyphList = List((10, 135, -10, -154), [], enableDelete=False, selectionCallback=self.ToggleEnableRemoveGlyphsButton)
     self.w.glyphList.enable(0)
     self.w.glyphListToolbar = Box((13, -153, -13, 10))
     self.w.glyphListToolbar.getNSBox().setBoxType_(NSBoxCustom)
     self.w.glyphListToolbar.getNSBox().setBorderType_(NSLineBorder)
     self.w.glyphListToolbar.getNSBox().setFillColor_(NSColor.colorWithPatternImage_(self.bundle.get("toolbar")))
     self.w.addGlyphsButton = ImageButton((10, -156, 30, 18), imageObject=(self.bundle.get("add")), sizeStyle="mini", callback=self.ShowAddGlyphItemsSheet)
     self.w.removeGlyphsButton = ImageButton((39, -156, 30, 18), imageObject=(self.bundle.get("remove")), sizeStyle="mini", callback=self.RemoveGlyphItems)
     self.w.addGlyphsButton.getNSButton().setBezelStyle_(NSSmallSquareBezelStyle)
     self.w.removeGlyphsButton.getNSButton().setBezelStyle_(NSSmallSquareBezelStyle)
     self.w.removeGlyphsButton.getNSButton().setEnabled_(NO)
     self.w.glyphListToolbar.getNSBox().setBorderColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.35))
     self.w.arriveTitle = TextBox((54, -134, -10, 20), "Arrivals")
     self.w.arriveTitle.getNSTextField().setTextColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.75))
     self.w.arriveCount = TextBox((54, -116, -10, 16), "--", sizeStyle="small")
     self.w.arriveCount.getNSTextField().setTextColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.75))
     self.w.CreateGlyphsButton = Button((20, -85, -20, 20), "Create Glyphs in Font", sizeStyle="small", callback=self.CreateGlyphsInFont)
     self.w.ExportGlyphsButton = Button((20, -60, -20, 20), u"Export Glyphset to File\u2026", sizeStyle="small", callback=self.ShowExportDialog)
     self.w.CopyToClipBoardButton = Button((20, -35, -20, 20), "Copy Glyphset to Clipboard", sizeStyle="small", callback=self.CopyGlyphsetToClipboard)
     self.ToggleEnableButtons()
     self.w.open()
Example #12
0
basePath = os.path.dirname(__file__)
sourcePath = os.path.join(basePath, "source")
libPath = os.path.join(sourcePath, "code")
licensePath = os.path.join(basePath, "license.txt")
requirementsPath = os.path.join(basePath, "requirements.txt")
resourcesPath = os.path.join(sourcePath, "resources")
if not os.path.exists(resourcesPath):
    resourcesPath = None
extensionFile = "%s.roboFontExt" % name
buildPath = os.path.join(basePath, "build")
extensionPath = os.path.join(buildPath, extensionFile)

# Build the extension.

B = ExtensionBundle()
B.name = name
B.developer = developer
B.developerURL = developerURL
B.version = version
B.launchAtStartUp = launchAtStartUp
B.mainScript = mainScript
docPath = os.path.join(sourcePath, "documentation")
haveDocumentation = False
if os.path.exists(os.path.join(docPath, "index.html")):
    haveDocumentation = True
elif os.path.exists(os.path.join(docPath, "index.md")):
    haveDocumentation = True
if not haveDocumentation:
    docPath = None
B.html = haveDocumentation
Example #13
0
# build RoboFont Extension

import os
import shutil

from mojo.extensions import ExtensionBundle

lib_path = os.path.dirname(__file__)
extension_file = 'CompareOTFs.roboFontExt'
extension_path = os.path.join(lib_path, extension_file)
# extension_html = os.path.join(lib_path, "_docs")
extension_lib_path = os.path.join(extension_path, 'lib')

print 'building extension...',
B = ExtensionBundle()
B.name = u"CompareOTFs"
B.developer = u'Gustavo Ferreira'
B.developerURL = 'http://hipertipo.com/'
B.version = "0.11"
B.mainScript = ""
B.launchAtStartUp = 0
B.addToMenu = [
    {
        'path' : 'compare-otfs.py',
        'preferredName' : 'CompareOTFs',
        'shortKey' : '',
    },
]
B.requiresVersionMajor = '1'
B.requiresVersionMinor = '5'
B.infoDictionary["html"] = 0
Example #14
0
from mojo.roboFont import OpenWindow

from lib.tools.notifications import PostNotification
from lib.cells.colorCell import RFPopupColorPanel, RFColorCell
from lib.tools.misc import NSColorToRgba

from plistlib import readPlist, writePlist

# Our own branch of the defconAppKit GlyphView
from defconAppKitBranch.glyphView import GlyphView
from defconAppKit.windows.baseWindow import BaseWindowController

# Temp name for a key to save the extension's preferences
DEFAULTSKEY = "com.andyclymer.themeManager"

EXTENSIONBUNDLE = ExtensionBundle("ThemeManager")

# Preference keys and names for the theme settings
THEMEKEYS = [
    ("glyphViewOncurvePointsSize", "Oncurve Size", float),
    ("glyphViewOffCurvePointsSize", "Offcurve Size", float),
    ("glyphViewStrokeWidth", "Glyph Stroke Width", int),
    ("glyphViewSelectionStrokeWidth", "Selection Stroke Width", int),
    ("glyphViewHandlesStrokeWidth", "Handle stroke width", int),
    ("glyphViewBackgroundColor", "Background Color", tuple),
    ("glyphViewFillColor", "Fill Color", tuple),
    ("glyphViewPreviewFillColor", "Preview Fill Color", tuple),
    ("glyphViewPreviewBackgroundColor", "Preview Background Color", tuple),
    ("glyphViewAlternateFillColor", "Alternate Fill Color", tuple),
    ("glyphViewStrokeColor", "Stroke Color", tuple),
    ("glyphViewCornerPointsFill", "Corner Point Fill Color", tuple),
from mojo.events import BaseEventTool, installTool
from AppKit import *

from lib.tools.drawing import strokePixelPath

from dialogKit import ModalDialog, TextBox, EditText
from vanilla import RadioGroup

from robofab.pens.reverseContourPointPen import ReverseContourPointPen

from mojo.extensions import ExtensionBundle


# collecting the image data for building cursors and toolbar icons

shapeBundle = ExtensionBundle("ShapeTool")
_cursorOval = CreateCursor(shapeBundle.get("cursorOval"), hotSpot=(6, 6))

_cursorRect = CreateCursor(shapeBundle.get("cursorRect"), hotSpot=(6, 6))

toolbarIcon = shapeBundle.get("toolbarIcon")


class GeometricShapesWindow(object):
    """
    The Modal window that allows numbers input to draw basic geometric shapes.
    """

    def __init__(self, glyph, callback, x, y):
        self.glyph = glyph
        self.callback = callback
Example #16
0
from __future__ import absolute_import
from __future__ import print_function
import os
from mojo.extensions import ExtensionBundle

basePath = os.path.dirname(__file__)
extensionPath = os.path.join(basePath, "SlightlyBetterTransform.roboFontExt")
libPath = os.path.join(basePath, "lib")
htmlPath = os.path.join(basePath, "html")
resourcesPath = os.path.join(basePath, "resources")

B = ExtensionBundle()

B.name = "Slightly Better Transform"
B.version = "1.2"
B.mainScript = "SlightlyBetterTransform.py"

B.developer = "Andy Clymer"
B.developerURL = 'http://www.andyclymer.com/'

B.launchAtStartUp = True
B.addToMenu = []
B.requiresVersionMajor = '3'
B.requiresVersionMinor = '1'
B.infoDictionary["html"] = True

B.save(extensionPath,
       libPath=libPath,
       htmlPath=htmlPath,
       resourcesPath=resourcesPath,
       pycOnly=False)
Example #17
0
 def __init__(self, name=None, path=None):
     self.name = name
     self.bundle = ExtensionBundle(name=self.name, path=path)
Example #18
0
 def all(cls):
     return [cls(name=n) for n in ExtensionBundle.allExtensions()]
Example #19
0
class Extension(object):
    """Facilitates loading the configuration from and updating extensions."""

    @classmethod
    def all(cls):
        return [cls(name=n) for n in ExtensionBundle.allExtensions()]

    @classmethod
    def install_remote(cls, repository, filename):
        remote = GithubRepository(repository, filename)
        path = remote.download()
        extension = cls(path=path).install()
        shutil.rmtree(path) # TODO: removing the tree should happen after download somehow
        return extension

    def __init__(self, name=None, path=None):
        self.name = name
        self.bundle = ExtensionBundle(name=self.name, path=path)

    @evented()
    def update(self, path=None):
        """Download and install the latest version of the extension."""

        if path is None:
            path = self.remote.download()

        Extension(path=path).install()

    @evented()
    def install(self):
        self.bundle.install()

    @evented()
    def uninstall(self):
        self.bundle.deinstall()

    @lazy_property
    def configuration(self):
        return Configuration(self.configuration_path)

    @lazy_property
    def remote(self):
        return GithubRepository(self.repository, self.filename)

    @property
    def is_current_version(self):
        """Return if extension is at curent version"""
        return self.remote.version <= self.version

    @property
    def is_ignored(self):
        return self.bundle.name in Storage.get('ignore')

    @property
    def is_configured(self):
        return self.repository is not None

    @property
    def is_installed(self):
        return self.bundle.bundleExists()

    @property
    def may_update(self):
        return not self.is_ignored and self.is_configured

    @property
    def should_update(self):
        return self.may_update and not self.is_current_version

    @property
    def configuration_path(self):
        return os.path.join(self.path, 'info.plist')

    @property
    def path(self):
        return self.bundle.bundlePath()

    @property
    def repository(self):
        return self.configuration.namespaced('repository') or \
            self.configuration.deprecated('repository')

    @property
    def version(self):
        return Version(self.configuration['version'])

    @property
    def filename(self):
        return os.path.basename(self.bundle.bundlePath())
from mojo.events import BaseEventTool, installTool
from mojo.roboFont import CreateCursor

from mojo.extensions import getExtensionDefault, setExtensionDefault, ExtensionBundle

from lib.tools.notifications import PostNotification
from lib.tools import bezierTools
from lib.tools.defaults import getDefault, setDefault

from settings import *

from generateImages import AddPixelToolRepresentationFactory

AddPixelToolRepresentationFactory()

pixelBundle = ExtensionBundle("PixelTool")
pixelCursor = CreateCursor(pixelBundle.get("pixelCursor"), hotSpot=(1, 19))
pixelToolbarIcon = pixelBundle.get("pixelToolbarIcon")


def _roundPoint(x, y):
    return int(round(x)), int(round(y))


class GridSettingsMenu(object):
    def __init__(self, tool, event, view):
        self.tool = tool

        self.drawingChoices = [RECT_MODE, OVAL_MODE, COMPONENT_MODE]

        self.view = vanilla.Group((0, 0, 0, 0))
'''

with codecs.open(mdPath, mode="r", encoding="utf-8") as f:
    mdSrc = f.read()
M = markdown.Markdown(extensions=[TocExtension(permalink=True), FencedCodeExtension()])
html = htmlTemplate % M.convert(mdSrc)

htmlFile = codecs.open(htmlIndexPath, mode="w", encoding="utf-8")
htmlFile.write(html)
htmlFile.close()

# ----------------
# create extension
# ----------------

B = ExtensionBundle()
B.name = "Glyph Construction"
B.developer = 'Frederk Berlaen'
B.developerURL = 'http://typemytype.com/'
B.version = '0.4'
B.launchAtStartUp = 0
B.mainScript = ''
B.html = True
B.requiresVersionMajor = '1'
B.requiresVersionMinor = '5'
B.addToMenu = [
    {
        'path'         : 'glyphConstructionUI.py',
        'preferredName': 'Glyph Builder',
        'shortKey'     : '',
    },
from mojo.events import BaseEventTool, installTool
from mojo.roboFont import CreateCursor

from mojo.extensions import getExtensionDefault, setExtensionDefault, ExtensionBundle

from lib.tools.notifications import PostNotification
from lib.tools import bezierTools
from lib.tools.defaults import getDefault, setDefault

from settings import *

from generateImages import AddPixelToolRepresentationFactory

AddPixelToolRepresentationFactory()

pixelBundle = ExtensionBundle("PixelTool")
pixelCursor = CreateCursor(pixelBundle.get("pixelCursor"), hotSpot=(9, 9))

def _roundPoint(x, y):
    return int(round(x)), int(round(y))

class GridSettingsMenu(object):
    
    def __init__(self, tool, event, view):
        self.tool = tool
        
        self.drawingChoices = [RECT_MODE, OVAL_MODE, COMPONENT_MODE]
                
        self.view = vanilla.Group((0, 0, 0, 0))
        
        
Example #23
0
 def __init__(self):
     addObserver(self, "spaceCenterDidOpen", "spaceCenterDidOpen")
     self.bundle = ExtensionBundle("SpaceFlip")
     self.path1 = self.bundle.resourcesPath() + '/flipButton.pdf'
     self.path2 = self.bundle.resourcesPath() + '/flipButton2.pdf'
     self.flipped = False
Example #24
0
import os
import hTools2

from mojo.extensions import ExtensionBundle

# data

extension_file = 'hTools2.roboFontExt'
lib_path = os.path.dirname(os.path.dirname(hTools2.__file__))
base_path = os.path.dirname(lib_path)
extension_path = os.path.join(base_path, extension_file)
html_path = os.path.join(base_path, "Documentation/build/html")

# create bundle

B = ExtensionBundle()
# meta
B.name = "hTools2"
B.developer = 'Gustavo Ferreira'
B.developerURL = 'http://hipertipo.com/'
B.version = "1.6"
B.mainScript = "add-RF-menu.py"
B.launchAtStartUp = True
B.addToMenu = []
# lib
B.requiresVersionMajor = '1'
B.requiresVersionMinor = '5'
B.infoDictionary["repository"] = 'gferreira/hTools2'
# html
B.html = 1
# save bundle
Example #25
0
 def inject_version_data(self, headers):
     extension = ExtensionBundle("Ghostlines").version or "Beta"
     version = "RF{};{}".format(RF.version, extension)
     headers["X-Ghostlines-Version"] = version
Example #26
0
class JetSetGlyphs(BaseWindowController):
    
    def __init__(self):
        self.bundle = ExtensionBundle("JetSetGlyphs")
        self.source_font = False
        self.target_font = False
        self.source_name = ""
        self.source_glyphs = []
        self.glyphset = []
        self.current_glyphs = []
        self.filtered = False
        self.w = Window((10, 20, 240, 560), "JetSetGlyphs", minSize=(240, 450))
        self.w.importFontButton = Button((20, 10, -20, 20), "Import from Font", sizeStyle="small", callback=self.ImportGlyphsFromFont)
        self.w.importFileButton = Button((20, 35, -20, 20), u"Import from File\u2026", sizeStyle="small", callback=self.ShowImportDialog)
        self.w.departBox = Box((10, 65, -10, 100))
        self.w.departPanel = Box((15, 70, -15, 36))
        self.w.departIcon = ImageView((21, 73, 28, 28))
        self.w.departIcon.setImage(imageObject=(self.bundle.get("departures")))
        self.w.departTitle = TextBox((54, 71, -10, 20), "Departures")
        self.w.departTitle.getNSTextField().setTextColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.75))
        self.w.departCount = TextBox((54, 89, -10, 16), "--", sizeStyle="small")
        self.w.departCount.getNSTextField().setTextColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.75))
        self.w.filterListBox = SearchBox((20, 110, -20, 20), sizeStyle="small", placeholder="Search", callback = self.FilterGlyphListView)
        self.w.arriveBox = Box((10, -160, -10, -92))
        self.w.arrivePanel = Box((15, -134, -15, 36))
        self.w.arriveIcon = ImageView((21, -131, 28, 28))
        self.w.arriveIcon.setImage(imageObject=(self.bundle.get("arrivals")))
        self.w.glyphList = List((10, 135, -10, -154), [], enableDelete=False, selectionCallback=self.ToggleEnableRemoveGlyphsButton)
        self.w.glyphList.enable(0)
        self.w.glyphListToolbar = Box((13, -153, -13, 10))
        self.w.glyphListToolbar.getNSBox().setBoxType_(NSBoxCustom)
        self.w.glyphListToolbar.getNSBox().setBorderType_(NSLineBorder)
        self.w.glyphListToolbar.getNSBox().setFillColor_(NSColor.colorWithPatternImage_(self.bundle.get("toolbar")))
        self.w.addGlyphsButton = ImageButton((10, -156, 30, 18), imageObject=(self.bundle.get("add")), sizeStyle="mini", callback=self.ShowAddGlyphItemsSheet)
        self.w.removeGlyphsButton = ImageButton((39, -156, 30, 18), imageObject=(self.bundle.get("remove")), sizeStyle="mini", callback=self.RemoveGlyphItems)
        self.w.addGlyphsButton.getNSButton().setBezelStyle_(NSSmallSquareBezelStyle)
        self.w.removeGlyphsButton.getNSButton().setBezelStyle_(NSSmallSquareBezelStyle)
        self.w.removeGlyphsButton.getNSButton().setEnabled_(NO)
        self.w.glyphListToolbar.getNSBox().setBorderColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.35))
        self.w.arriveTitle = TextBox((54, -134, -10, 20), "Arrivals")
        self.w.arriveTitle.getNSTextField().setTextColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.75))
        self.w.arriveCount = TextBox((54, -116, -10, 16), "--", sizeStyle="small")
        self.w.arriveCount.getNSTextField().setTextColor_(NSColor.colorWithCalibratedWhite_alpha_(0, 0.75))
        self.w.CreateGlyphsButton = Button((20, -85, -20, 20), "Create Glyphs in Font", sizeStyle="small", callback=self.CreateGlyphsInFont)
        self.w.ExportGlyphsButton = Button((20, -60, -20, 20), u"Export Glyphset to File\u2026", sizeStyle="small", callback=self.ShowExportDialog)
        self.w.CopyToClipBoardButton = Button((20, -35, -20, 20), "Copy Glyphset to Clipboard", sizeStyle="small", callback=self.CopyGlyphsetToClipboard)
        self.ToggleEnableButtons()
        self.w.open()
        
        
    def ImportGlyphsFromFont(self, sender):
        self.source_font = CurrentFont()
        if self.source_font == None:
            self.showMessage(u"Ergh\u2026", "Open a font to get a glyphset from!")
        else:
            self.source_glyphs = self.GetAllGlyphsFromFont(self.source_font)
            
            if self.source_font.info.familyName != None:
                self.source_name = self.source_font.info.familyName
            else:
                self.source_name = "Unnamed"
            if self.source_font.info.styleName != None:
                self.source_name = self.source_name + " " + self.source_font.info.styleName
            self.glyphset = self.source_glyphs
            self.UpdateGlyphListView(self.glyphset)
            self.UpdateDepartureInfo()
            self.UpdateArrivalInfo()
            self.ResetFilter()
        
    
    def ImportGlyphsFromFile(self, result):
        file_path = str(result[0])
        self.source_name =os.path.basename(file_path)
        f = open(file_path, "r")
        f_str = f.read()
        f.close()
        self.source_glyphs = f_str.split(" ")
        self.glyphset = self.source_glyphs
        self.UpdateGlyphListView(self.glyphset)
        self.UpdateDepartureInfo()
        self.UpdateArrivalInfo()
        self.ResetFilter()
        
        
    def UpdateGlyphListView(self, g_list):
        self.w.glyphList.enable(1)
        self.w.glyphList.set(g_list)
        self.ToggleEnableButtons()
        
    
    def CreateGlyphsInFont(self, sender):
        self.target_font = CurrentFont()
        if len(self.glyphset) > 0:
            if self.target_font != None:
                if self.target_font != self.source_font:
                    
                    newGlyphOrder = self.GetAllGlyphsFromFont(self.target_font)
                    
                    self.w.progressWindow = ProgressWindow(u"Creating Glyphs\u2026", parentWindow=self.w)
                    
                    for glyph in self.glyphset:
                        if glyph not in newGlyphOrder:
                            newGlyphOrder.append(glyph)
                            
                    newGlyphOrder.sort()
                    self.target_font.glyphOrder = newGlyphOrder
                    self.target_font.update()
                    
                    self.w.progressWindow.close()
                    
                else:
                    self.showMessage(u"Ergh\u2026", "You are trying to apply a glyphset to the font you took it from!")
            else:
                self.showMessage(u"Ouch\u2026", "There needs to be an open font to apply the glyphset to!")
        else:
            self.showMessage(u"Ergh\u2026", "No glyphs have been imported yet.")
        
        
    def ExportGlyphsToFile(self, result):
        f = open(str(result), "w")
        f.write(self.GlyphSetToString())
        f.close()
        
        
    def CopyGlyphsetToClipboard(self, sender):
        charSet = self.GlyphSetToString()
        subprocess.Popen(['osascript', '-e', 'set the clipboard to ' + '\"' + charSet + '\"'])
    
        
    def FilterGlyphListView(self, sender):
        search_for = sender.get().strip()
        regex = re.compile(".*(" + search_for + ").*")
        matches = [match.group(0) for c in self.glyphset for match in [regex.search(c)] if match]
        if len(self.glyphset) > 0:
            if search_for != "" or search_for != " ":
                self.UpdateGlyphListView(matches)
                self.filtered = search_for
            else:
                self.UpdateGlyphListView(self.glyphset)
                self.filtered = False
        
        
    def ShowAddGlyphItemsSheet(self, sender):
        self.addGlyphsSheet = Sheet((300, 200), self.w)
        self.addGlyphsSheet.input = TextEditor((10, 10, -10, 150), "")
        self.addGlyphsSheet.cancelButton = Button((-150, -30, 50, 20), "Cancel", sizeStyle="small", callback=self.CancelAddItems)
        self.addGlyphsSheet.addButton = Button((-90, -30, 80, 20), "Add Glyphs", sizeStyle="small", callback=self.AddGlyphItems)
        self.addGlyphsSheet.setDefaultButton(self.addGlyphsSheet.addButton)
        self.addGlyphsSheet.open()
        
        
    def AddGlyphItems(self, sender):
        input_str = str(self.addGlyphsSheet.input.get())
        if input_str != "":
            add_glyphs = input_str.split(" ")
            for a_glyph in add_glyphs:
                a_glyph = a_glyph.strip()
            new_glyphs = self.glyphset
            for a in add_glyphs:
                if a != "" and a not in new_glyphs:
                    new_glyphs.append(a)
            self.glyphset = new_glyphs
            self.UpdateGlyphListView(self.glyphset)
            self.UpdateArrivalInfo()
            
            if self.filtered:
                self.FilterGlyphListView(self.w.filterListBox)
            
        self.addGlyphsSheet.close()
        
        
        
    def CancelAddItems(self, sender):
        self.addGlyphsSheet.close()
        
    
    def RemoveGlyphItems(self, sender):
        rem_index = self.w.glyphList.getSelection()
        visible_glyphs = self.w.glyphList.get()
        if len(rem_index) > 0:
            rem_glyphs = [i for j, i in enumerate(visible_glyphs) if j in rem_index]
            
            for rem_glyph in rem_glyphs:
                if rem_glyph in self.glyphset:
                    self.glyphset.remove(rem_glyph)
                if rem_glyph in visible_glyphs:
                    visible_glyphs.remove(rem_glyph)
                        
            self.UpdateGlyphListView(visible_glyphs)
            self.UpdateArrivalInfo()
            if len(self.glyphset) == 0:
                self.source_name = ""
                self.UpdateDepartureInfo()
        
        
    def ShowImportDialog(self, sender):
        self.showGetFile(["public.plain-text"], self.ImportGlyphsFromFile)
        
    
    def ShowExportDialog(self, sender):
        self.showPutFile(["public.plain-text"], self.ExportGlyphsToFile, fileName = "glyphset.txt")


    def ResetFilter(self):
        self.w.filterListBox.set("")
        
    
    def UpdateDepartureInfo(self):
        d_len = len(self.w.glyphList.get())
        if d_len > 0:
            if d_len == 1:
                d_g_term = " glyph"
            else:
                d_g_term = " glyphs"
            if self.source_name:
                d_count = str(d_len) + d_g_term + " from " + self.source_name
            else:
                d_count = str(d_len) + d_g_term
        else:
            d_count = "--"
        self.w.departCount.set(d_count)
        
        
    def UpdateArrivalInfo(self):
        a_len = len(self.glyphset)
        if a_len > 0:
            if a_len == 1:
                g_a_term = " glyph"
            else:
                g_a_term = " glyphs"
            a_count = str(len(self.glyphset)) + g_a_term
        else:
            a_count = "--"
        self.w.arriveCount.set(a_count)
        
        
    def ToggleEnableRemoveGlyphsButton(self, sender):
        if len(self.w.glyphList.getSelection()) > 0:
            self.w.removeGlyphsButton.getNSButton().setEnabled_(YES)
        else:
            self.w.removeGlyphsButton.getNSButton().setEnabled_(NO)
   
    
    def ToggleEnableButtons(self):
        if len(self.glyphset) > 0:
            self.w.CreateGlyphsButton.getNSButton().setEnabled_(YES)
            self.w.ExportGlyphsButton.getNSButton().setEnabled_(YES)
            self.w.CopyToClipBoardButton.getNSButton().setEnabled_(YES)
        else:
            self.w.CreateGlyphsButton.getNSButton().setEnabled_(NO)
            self.w.ExportGlyphsButton.getNSButton().setEnabled_(NO)
            self.w.CopyToClipBoardButton.getNSButton().setEnabled_(NO)
    
    
    def GetAllGlyphsFromFont(self, f):
        all_glyphs = f.lib["public.glyphOrder"]
        for g in f.glyphOrder:
            if g not in all_glyphs:
                al_glyphs.append(g)
        return all_glyphs
           
          
    def GlyphSetToString(self):
        glyph_set = self.glyphset
        glyph_set = " ".join([aGlyph for aGlyph in glyph_set if aGlyph])
        return glyph_set
licensePath = os.path.join(basePath, 'license.txt')
if not os.path.exists(licensePath):
    licensePath = None

# boolean indicating if only .pyc should be included
pycOnly = False

# name of the compiled extension file
extensionFile = 'EditThatNextMaster.roboFontExt'

# path of the compiled extension
buildPath = basePath
extensionPath = os.path.join(buildPath, extensionFile)

# initiate the extension builder
B = ExtensionBundle()

# name of the extension
B.name = "EditThatNextMaster"

# name of the developer
B.developer = 'LettError'

# URL of the developer
B.developerURL = 'http://letterror.com/tools.html'

if resourcesPath:
    # extension icon (file path or NSImage)
    imagePath = os.path.join(resourcesPath, 'icon.png')
    B.icon = imagePath
Example #28
0
# build RoboFont Extension

import os
import shutil

from mojo.extensions import ExtensionBundle

lib_path = os.path.dirname(__file__)
extension_file = 'MeasureHandles.roboFontExt'
extension_path = os.path.join(os.path.join(lib_path, 'extension'),
                              extension_file)
# extension_html = os.path.join(lib_path, "_docs")
extension_lib_path = os.path.join(extension_path, 'lib')

print 'building extension...',
B = ExtensionBundle()
B.name = u"Measure Handles Tool"
B.developer = u'Gustavo Ferreira, Johannes Breyer'
B.developerURL = 'http://hipertipo.com/'
B.version = "0.1"
B.mainScript = "MeasureHandlesTool.py"
B.launchAtStartUp = 1
B.addToMenu = []
B.requiresVersionMajor = '1'
B.requiresVersionMinor = '5'
B.infoDictionary["html"] = 0
B.infoDictionary["com.robofontmechanic.Mechanic"] = {
    "repository": "johannesbreyer/HandleLength",
    "description":
    "A tool to display length & angle of bezier handles in a glyph",
}
Example #29
0
# -*- coding: utf-8 -*-

from AppKit import NSColor, NSFont, NSFontAttributeName, NSForegroundColorAttributeName, NSCursor
from mojo.events import installTool, EditingTool, BaseEventTool, setActiveEventTool
from mojo.drawingTools import *
from mojo.UI import UpdateCurrentGlyphView
from defconAppKit.windows.baseWindow import BaseWindowController

from gaussTools import *
import vanilla

from mojo.extensions import ExtensionBundle
shapeBundle = ExtensionBundle("LightMeter")
toolbarIcon = shapeBundle.get("LightMeterButton")

"""


    LightMeterTool 02
    
    This is a sort of a light meter for the glyph window. 
    Running this script will install a tool in the toolbar. 
        
    When selected, the tool draws trails of gray rectangles.
    The gray level of a pixel corresponds to the light 
    contributed by the white and black areas around the cursor.
    The blue number indicates the percentage. 

        100    = white + dot
        n      = some level of gray
        0      = black + dot
Example #30
0
    def __init__(self):
        # set defaults
        self.wordCount = 20
        self.minLength = 3
        self.maxLength = 10
        self.case = 0
        self.requiredLetters = ['a', 'o']
        self.bannedLetters = ['-']
        self.requiredGroups = [[], [], []]
        self.limitToCharset = False
        self.banRepetitions = False
        self.randomize = True
        self.outputWords = []
        
        fileName      = 'ukacd'
        contentLimit  = '*****' # If word list file contains a header (e.g. copyright notice), start looking for content after this delimiter
        
        bundle = ExtensionBundle("word-o-mat")
        fo = open(bundle.getResourceFilePath(fileName, ext="txt"))
        lines = fo.read()
        fo.close()
        self.allWords = lines.splitlines()
        try:
            contentStart = self.allWords.index(contentLimit) + 1
            self.allWords = self.allWords[contentStart:]
        except ValueError:
            pass
        
        # preset character groups
        groupPresets = [
            ["Ascenders", ["b", "f", "h", "k", "l"]], 
            ["Descenders", ["g", "j", "p", "q", "y"]], 
            ["Ball-and-Stick", ["b", "d", "p", "q"]], 
            ["Arches", ["n", "m", "h", "u"]], 
            ["Diagonals", ["v", "w", "x", "y"]]]
            
        addObserver(self, "fontOpened", "fontDidOpen")
        addObserver(self, "fontClosed", "fontWillClose")
        
        # dialog window
        self.w = FloatingWindow((325, 518), 'word-o-mat')
        interval = 28
        padding = 10
        boxPadding = 3
        y = 10
        
        self.w.basicsBox = Box((padding, y, -padding, interval*3.85))
        self.w.basicsBox.wcText = TextBox((boxPadding, 5, 170, 22), 'Make this many words:') 
        self.w.basicsBox.lenTextOne = TextBox((boxPadding, 5 + interval * 1.25, 90, 22), 'Word length:') 
        self.w.basicsBox.lenTextTwo = TextBox((141, 5 + interval * 1.25, 20, 22), 'to') 
        self.w.basicsBox.lenTextThree = TextBox((212, 5 + interval * 1.25, 80, 22), 'characters') 
        self.w.basicsBox.wordCount = EditText((160, 3, 40, 22), text=self.wordCount, placeholder=str(20))
        self.w.basicsBox.minLength = EditText((95, 3 + interval * 1.25, 40, 22), text=self.minLength, placeholder=str(3))
        self.w.basicsBox.maxLength = EditText((165, 3 + interval * 1.25, 40, 22), text=self.maxLength, placeholder=str(10))  
        self.w.basicsBox.caseLabel = TextBox((boxPadding, 3 + interval * 2.5, 45, 22), 'Case:') 
        self.w.basicsBox.case = PopUpButton((50, 2 + interval * 2.5, -10, 20), ["leave as is", "all lowercase", "Capitalize", "ALL CAPS"])
        y += interval*4.2

        self.w.reqBox = Box((padding, y, -padding, interval*8.9))
        labelY = [5, 5 + interval*2.25, 5 + interval*6.375]
        labelText = ["Required characters:", "Groups (require at least one in each group):", "Excluded characters:"]
        for i in range(3):
            setattr(self.w.reqBox, "reqLabel%s" % i, TextBox((boxPadding, labelY[i], -boxPadding, 22), labelText[i]))
        self.w.reqBox.mustLettersBox = EditText((boxPadding, 5 + interval*.8, -boxPadding, 22), text=", ".join(self.requiredLetters))
        self.w.reqBox.notLettersBox = EditText((boxPadding, 5 + interval * 7.175, -boxPadding, 22), text=", ".join(self.bannedLetters))
        
        y2 = interval*2.25
        attrNameTemplate = "group%sbox"
        for i in range(3):
            j = i+1
            y2 += interval
            optionsList = ["%s: %s" % (key, ", ".join(value)) for key, value in groupPresets]
            if len(self.requiredGroups[i]) > 0:
                optionsList.insert(0, "Current: " + ", ".join(self.requiredGroups[i]))
            attrName = attrNameTemplate % j
            setattr(self.w.reqBox, attrName, ComboBox((boxPadding, y2-3, -boxPadding, 22), optionsList)) 
        y += interval*9.25
          
        self.w.optionsBox = Box((padding, y, -padding, interval*3.125))
        chkNameTemplate = "checkbox%s"
        chkLabel = ["Limit to characters available in current font", "No repeating characters", "Randomize output"]
        chkValues = [self.limitToCharset, self.banRepetitions, self.randomize]
        for i in range(3):
            y3 = i*interval*.875
            attrName = chkNameTemplate % i
            setattr(self.w.optionsBox, attrName, CheckBox((boxPadding, y3+3, -boxPadding, 22), chkLabel[i], value=chkValues[i])) 
        self.w.optionsBox.checkbox0.enable(CurrentFont()) 
        y += interval*3.5
        self.w.submit = Button((10,y,-10, 22), 'words please!', callback=self.makeWords)
        self.w.bind("close", self.windowClose)
        self.w.open()
from __future__ import absolute_import
from __future__ import print_function
import os
from mojo.extensions import ExtensionBundle

basePath = os.path.dirname(__file__)
extensionPath = os.path.join(basePath, "AndysRFHacks.roboFontExt")
libPath = os.path.join(basePath, "lib")
htmlPath = os.path.join(basePath, "html")
resourcesPath = os.path.join(basePath, "resources")

B = ExtensionBundle()

B.name = "Andy's RF Hacks"
B.version = "1.3"
B.developer = "Andy Clymer"
B.developerURL = 'http://www.andyclymer.com/'

B.mainScript = "Setup.py"
B.launchAtStartUp = True
B.addToMenu = [{
    'path': 'Manager.py',
    'preferredName': 'Preferences',
    'shortKey': '',
}]

B.requiresVersionMajor = '3'
B.requiresVersionMinor = '1'
B.infoDictionary["html"] = True

B.save(extensionPath,
Example #32
0
# -*- coding: utf-8 -*-

from AppKit import NSColor, NSFont, NSFontAttributeName, NSForegroundColorAttributeName, NSCursor
from mojo.events import installTool, EditingTool, BaseEventTool, setActiveEventTool
from mojo.drawingTools import *
from mojo.UI import UpdateCurrentGlyphView
from defconAppKit.windows.baseWindow import BaseWindowController

import vanilla

from mojo.extensions import ExtensionBundle

shapeBundle = ExtensionBundle("ZoneChecker")
toolbarIcon = shapeBundle.get("ZoneCheckerButton")
"""


    Zonechecker
    
    Check for points near the alignment zones.


"""


class ZoneCheckerTool(EditingTool):

    zoneCheckerToolPrefsLibKey = "com.letterror.zoneChecker.prefs"
    textAttributes = {
        NSFontAttributeName: NSFont.systemFontOfSize_(10),
        NSForegroundColorAttributeName: NSColor.whiteColor(),
from __future__ import absolute_import
from __future__ import print_function
import os
from mojo.extensions import ExtensionBundle

basePath = os.path.dirname(__file__)
extensionPath = os.path.join(basePath, "ThemeManager.roboFontExt")
libPath = os.path.join(basePath, "lib")
htmlPath = os.path.join(basePath, "html")
resourcesPath = os.path.join(basePath, "resources")

B = ExtensionBundle()

B.name = "Theme Manager"
B.version = "1.0.2"
B.developer = "Connor Davenport and Andy Clymer"
B.developerURL = 'http://www.connordavenport.com/ http://www.andyclymer.com/'

B.launchAtStartUp = False
B.addToMenu = [{
    'path': 'ThemeManager.py',
    'preferredName': 'Theme Manager...',
    'shortKey': '',
}]

B.requiresVersionMajor = '3'
B.requiresVersionMinor = '1'
B.infoDictionary["html"] = True

B.save(extensionPath,
       libPath=libPath,
import os, shutil
from mojo.extensions import ExtensionBundle

basePath = os.path.dirname(__file__)
sourcePath = os.path.join(basePath, 'source')
libPath = os.path.join(sourcePath, 'code')
htmlPath = os.path.join(sourcePath, 'docs')
resourcesPath = os.path.join(sourcePath, 'resources')
licensePath = os.path.join(basePath, 'LICENSE')
pycOnly = False
extensionFile = 'ShapeTool.roboFontExt'
extensionPath = os.path.join(basePath, extensionFile)

B = ExtensionBundle()
B.name = "ShapeTool"
B.developer = 'TypeMyType'
B.developerURL = 'http://www.typemytype.com'
B.icon = os.path.join(basePath, 'ShapeToolMechanicIcon.png')
B.version = '1.7'
B.launchAtStartUp = True
B.mainScript = 'drawShapesTool.py'
B.html = True
B.requiresVersionMajor = '3'
B.requiresVersionMinor = '2'
B.addToMenu = []

with open(licensePath) as license:
    B.license = license.read()

# copy README + images to extension docs
if not os.path.exists(htmlPath):
# build RoboFont Extension

import os
import shutil

from mojo.extensions import ExtensionBundle

lib_path = os.path.dirname(__file__)
extension_file = 'MeasureHandles.roboFontExt'
extension_path = os.path.join(os.path.join(lib_path, 'extension'), extension_file)
# extension_html = os.path.join(lib_path, "_docs")
extension_lib_path = os.path.join(extension_path, 'lib')

print 'building extension...',
B = ExtensionBundle()
B.name = u"Measure Handles Tool"
B.developer = u'Gustavo Ferreira, Johannes Breyer'
B.developerURL = 'http://hipertipo.com/'
B.version = "0.1"
B.mainScript = "MeasureHandlesTool.py"
B.launchAtStartUp = 1
B.addToMenu = []
B.requiresVersionMajor = '1'
B.requiresVersionMinor = '5'
B.infoDictionary["html"] = 0
B.infoDictionary["com.robofontmechanic.Mechanic"] = {
    "repository" : "johannesbreyer/HandleLength",
    "description" : "A tool to display length & angle of bezier handles in a glyph",
}
B.save(extension_path, libPath=lib_path, htmlPath=None, resourcesPath=None, pycOnly=False)
print 'done.\n'
Example #36
0
import os
import sys
import importlib
from mojo.extensions import getExtensionDefault, setExtensionDefault
from mojo.extensions import ExtensionBundle

KEYPREFIX = "com.andyclymer.andysHacks"

extBundle = ExtensionBundle("AndysRFHacks")
# Clear out any script metadata if it's a new version of the extension
if not extBundle.version == getExtensionDefault("%s.version" % KEYPREFIX,
                                                fallback="0.0"):
    setExtensionDefault("%s.version" % KEYPREFIX, extBundle.version)
    setExtensionDefault("%s.scriptMetadata" % KEYPREFIX, {})

from Scripts import *
Example #37
0
 def toolbarHelp(self, sender):
     ExtensionBundle("Batch").openHelp()
Example #38
0
 def extensionBundle(self):
     # get the bundleName
     bundleName = self.extensionPath.split("/")[-1]
     # get the bundle
     return ExtensionBundle(bundleName)
import math
import AppKit
from mojo.extensions import ExtensionBundle
from mojo.events import installTool, EditingTool
from mojo.drawingTools import *
from mojo.UI import UpdateCurrentGlyphView, getDefault
import merz
from merz.tools.drawingTools import NSImageDrawingTools

#     A visualisation for RoboFont 4 XX
#     Show the ratio between the length of outgoing and incoming sections of bcps and tangents.
#     Show the angle
#     Draw in active and inactive views so we can compare different glyphs
#     [email protected]

angleRatioToolBundle = ExtensionBundle("AngleRatioTool")
toolbarIconPath = os.path.join(angleRatioToolBundle.resourcesPath(), "icon.pdf")
toolbarIcon = AppKit.NSImage.alloc().initWithContentsOfFile_(toolbarIconPath)





def dotSymbolFactory(
        size,
        color,
        strokeColor,
        strokeWidth=0,
        ):
    # create a image draw bot 
    bot = NSImageDrawingTools((size, size))
import hTools2
reload(hTools2)

import os
from mojo.extensions import ExtensionBundle

hTools2_path = os.path.dirname(os.path.dirname(hTools2.__file__ ))
hTools2_html = os.path.join(os.path.dirname(hTools2_path), "Docs/build/html")

extension_file = 'hTools2.roboFontExt'
extension_path = os.path.join(os.path.dirname(__file__), extension_file)

print 'building extension...',

B = ExtensionBundle()
B.name = "hTools2"
B.developer = 'Gustavo Ferreira'
B.developerURL = 'http://hipertipo.com/'
B.version = "1.9"
B.mainScript = "init-RF-extension.py"
B.launchAtStartUp = 1
B.addToMenu = []
B.requiresVersionMajor = '1'
B.requiresVersionMinor = '5'
B.infoDictionary["repository"] = 'gferreira/hTools2'
B.infoDictionary["summary"] = 'A collection of tools to help with common type design & font production tasks.'
B.infoDictionary["html"] = 1
B.save(extension_path, libPath=hTools2_path, htmlPath=hTools2_html, resourcesPath=None, pycOnly=False)

print 'done.'
Example #41
0
# -*- coding: utf-8 -*-

from AppKit import NSColor, NSFont, NSFontAttributeName, NSForegroundColorAttributeName, NSCursor
from mojo.events import installTool, EditingTool, BaseEventTool, setActiveEventTool
from mojo.drawingTools import *
from mojo.UI import UpdateCurrentGlyphView
from defconAppKit.windows.baseWindow import BaseWindowController

from gaussTools import *
import vanilla

from mojo.extensions import ExtensionBundle

shapeBundle = ExtensionBundle("LightMeter")
toolbarIcon = shapeBundle.get("LightMeterButton")

"""


    LightMeterTool 02
    
    This is a sort of a light meter for the glyph window. 
    Running this script will install a tool in the toolbar. 
        
    When selected, the tool draws trails of gray rectangles.
    The gray level of a pixel corresponds to the light 
    contributed by the white and black areas around the cursor.
    The blue number indicates the percentage. 

        100    = white + dot
        n      = some level of gray
Example #42
0
         preferredName="Edit Constructions",
         shortKey="")
]

installAfterBuild = True

basePath = os.path.dirname(__file__)
sourcePath = os.path.join(basePath, "source")
libPath = os.path.join(sourcePath, "code")
licensePath = os.path.join(basePath, "license.txt")
requirementsPath = os.path.join(basePath, "requirements.txt")
extensionFile = "%s.roboFontExt" % name
buildPath = os.path.join(basePath, "build")
extensionPath = os.path.join(buildPath, extensionFile)

B = ExtensionBundle()
B.name = name
B.developer = developer
B.developerURL = developerURL
B.version = version
B.launchAtStartUp = False
B.mainScript = "main.py"
B.html = os.path.exists(os.path.join(sourcePath, "documentation",
                                     "index.html"))
B.requiresVersionMajor = roboFontVersion.split(".")[0]
B.requiresVersionMinor = roboFontVersion.split(".")[1]
B.addToMenu = menuItems
if os.path.exists(licensePath):
    with open(licensePath) as license:
        B.license = license.read()
if os.path.exists(requirementsPath):
import hTools2
import importlib
importlib.reload(hTools2)

import os
from mojo.extensions import ExtensionBundle

hTools2_path = os.path.dirname(os.path.dirname(hTools2.__file__ ))
hTools2_html = os.path.join(os.path.dirname(hTools2_path), "Docs/build/html")

extension_file = 'hTools2.roboFontExt'
extension_path = os.path.join(os.path.dirname(__file__), extension_file)

print('building extension...', end=' ')

B = ExtensionBundle()
B.name = "hTools2"
B.developer = 'Gustavo Ferreira'
B.developerURL = 'http://hipertipo.com/'
B.version = "1.9"
B.mainScript = "init-RF-extension.py"
B.launchAtStartUp = 1
B.addToMenu = []
B.requiresVersionMajor = '1'
B.requiresVersionMinor = '5'
B.infoDictionary["repository"] = 'gferreira/hTools2'
B.infoDictionary["summary"] = 'A collection of tools to help with common type design & font production tasks.'
B.infoDictionary["html"] = 1
B.save(extension_path, libPath=hTools2_path, htmlPath=hTools2_html, resourcesPath=None, pycOnly=False)

print('done.')
Example #44
0
 def getToolbarIcon(self):
     extBundle = ExtensionBundle("SlightlyBetterTransform")
     toolbarIcon = extBundle.get("SlightlyBetterTransform_ToolbarIcon-2x")
     return toolbarIcon
licensePath = os.path.join(basePath, 'license.txt')
if not os.path.exists(licensePath):
    licensePath = None

# boolean indicating if only .pyc should be included
pycOnly = False

# name of the compiled extension file
extensionFile = 'AngleRatioTool.roboFontExt'

# path of the compiled extension
buildPath = basePath
extensionPath = os.path.join(buildPath, extensionFile)

# initiate the extension builder
B = ExtensionBundle()

# name of the extension
B.name = "AngleRatioTool"

# name of the developer
B.developer = 'LettError'

# URL of the developer
B.developerURL = 'http://letterror.com'

if resourcesPath:
    # extension icon (file path or NSImage)
    imagePath = os.path.join(resourcesPath, 'icon.png')
    B.icon = imagePath
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
Example #47
0
libPath = os.path.dirname(__file__)
extensionFile = "RoboFabDocs.roboFontExt"
extensionPath = os.path.join(libPath, extensionFile)
extensionHtml = os.path.join(libPath, "_build/html/")

print "building RoboFab Docs extension...\n"

# remove existing extension
if os.path.exists(extensionPath):
    print "\tremoving old RoboFont extension..."
    shutil.rmtree(extensionPath)

# build new extension
print "\trebuilding the RoboFont extension..."
B = ExtensionBundle()
B.name = "RoboFab Docs"
B.developer = "RoboFab Developers"
B.developerURL = "http://robofab.org/"
B.version = "0.1"
B.mainScript = ""
B.launchAtStartUp = 0
B.addToMenu = [{
    "path" : "docs.py",
    "preferredName" : "RoboFab Docs",
    "shortKey" : "",
}]
B.requiresVersionMajor = "1"
B.requiresVersionMinor = "5"
B.infoDictionary["html"] = 0
B.infoDictionary["com.robofontmechanic.Mechanic"] = {
Example #48
0
# BY DJR, with help from Nina Stössinger. Thanks Nina!

# 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):
        '''
libPath = os.path.dirname(__file__)
extensionFile = "RoboFabDocs.roboFontExt"
extensionPath = os.path.join(libPath, extensionFile)
extensionHtml = os.path.join(libPath, "_build/html/")

print "building RoboFab Docs extension...\n"

# remove existing extension
if os.path.exists(extensionPath):
    print "\tremoving old RoboFont extension..."
    shutil.rmtree(extensionPath)

# build new extension
print "\trebuilding the RoboFont extension..."
B = ExtensionBundle()
B.name = "RoboFab Docs"
B.developer = "RoboFab Developers"
B.developerURL = "http://robofab.org/"
B.version = "0.1"
B.mainScript = ""
B.launchAtStartUp = 0
B.addToMenu = [{
    "path": "docs.py",
    "preferredName": "RoboFab Docs",
    "shortKey": "",
}]
B.requiresVersionMajor = "1"
B.requiresVersionMinor = "5"
B.infoDictionary["html"] = 0
B.infoDictionary["com.robofontmechanic.Mechanic"] = {
Example #50
0
from mojo.events import BaseEventTool, installTool
from AppKit import *

from lib.tools.drawing import strokePixelPath

from dialogKit import ModalDialog, TextBox, EditText
from vanilla import RadioGroup

from robofab.pens.reverseContourPointPen import ReverseContourPointPen

from mojo.extensions import ExtensionBundle

# collecting the image data for building cursors and toolbar icons

shapeBundle = ExtensionBundle("ShapeTool")
_cursorOval = CreateCursor(shapeBundle.get("cursorOval"), hotSpot=(6, 6))

_cursorRect = CreateCursor(shapeBundle.get("cursorRect"), hotSpot=(6, 6))

toolbarIcon = shapeBundle.get("toolbarIcon")


class GeometricShapesWindow(object):
    """
    The Modal window that allows numbers input to draw basic geometric shapes.
    """
    def __init__(self, glyph, callback, x, y):
        self.glyph = glyph
        self.callback = callback
        # create the modal dialog (from dialogKit)
        self.w = ModalDialog((200, 150),
Example #51
0
# BY DJR, with help from Nina Stössinger. Thanks Nina!

# 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.
        '''
# load license text from file
# see choosealicense.com for more open-source licenses
licensePath = os.path.join(basePath, 'license.txt')

# required extensions
requirementsPath = os.path.join(basePath, 'requirements.txt')

# name of the compiled extension file
extensionFile = 'myExtension.roboFontExt'

# path of the compiled extension
buildPath = os.path.join(basePath, 'build')
extensionPath = os.path.join(buildPath, extensionFile)

# initiate the extension builder
B = ExtensionBundle()

# name of the extension
B.name = "myExtension"

# name of the developer
B.developer = 'RoboDocs'

# URL of the developer
B.developerURL = 'http://github.com/roboDocs'

# extension icon (file path or NSImage)
imagePath = os.path.join(resourcesPath, 'icon.png')
B.icon = imagePath

# version of the extension
Example #53
0
import os
from mojo.extensions import ExtensionBundle


basePath = os.path.dirname(__file__)
extensionPath = os.path.join(basePath, "ControlBoard.roboFontExt")
libPath = os.path.join(basePath, "lib")
htmlPath = os.path.join(basePath, "html")
resourcesPath = os.path.join(basePath, "resources")

B = ExtensionBundle()

B.name = "ControlBoard"
B.version = "0.22b"
B.mainScript = "ControlBoard.py"

B.developer = "Andy Clymer"
B.developerURL = 'http://www.andyclymer.com/'

B.launchAtStartUp = False
B.addToMenu = [{"path" : "ControlBoard.py", "preferredName" : "ControlBoard", "shortKey" : ""}]
B.requiresVersionMajor = '1'
B.requiresVersionMinor = '5'
B.infoDictionary["html"] = True

B.save(extensionPath, libPath=libPath, htmlPath=htmlPath, resourcesPath=resourcesPath, pycOnly=False)

print "Done"