├── .gitignore ├── DrawBot.glyphsPlugin └── Contents │ ├── Info.plist │ ├── MacOS │ └── plugin │ └── Resources │ ├── DrawBotDocument.py │ ├── DrawBotWindow.py │ ├── drawBot │ ├── __init__.py │ ├── context │ │ ├── __init__.py │ │ ├── baseContext.py │ │ ├── drawBotContext.py │ │ ├── dummyContext.py │ │ ├── gifContext.py │ │ ├── icnsContext.py │ │ ├── imageContext.py │ │ ├── movContext.py │ │ ├── mp4Context.py │ │ ├── pdfContext.py │ │ ├── printContext.py │ │ ├── svgContext.py │ │ └── tools │ │ │ ├── SFNTLayoutTypes.py │ │ │ ├── __init__.py │ │ │ ├── gifTools.py │ │ │ ├── gifsicleLicense │ │ │ ├── imageObject.py │ │ │ ├── mp4Tools.py │ │ │ ├── openType.py │ │ │ ├── traceImage.py │ │ │ └── variation.py │ ├── drawBotDrawingTools.py │ ├── drawBotPageDrawingTools.py │ ├── drawBotSettings.py │ ├── macOSVersion.py │ ├── misc.py │ ├── scriptTools.py │ └── ui │ │ ├── __init__.py │ │ ├── codeEditor.py │ │ ├── debug.py │ │ ├── drawView.py │ │ ├── lineNumberRulerView.py │ │ └── splitView.py │ ├── externalTools │ ├── ffmpeg │ ├── gifsicle │ ├── mkbitmap │ └── potrace │ ├── lib │ └── python2.7 │ │ └── config │ ├── pygments │ ├── __init__.py │ ├── cmdline.py │ ├── console.py │ ├── filter.py │ ├── filters │ │ └── __init__.py │ ├── formatter.py │ ├── formatters │ │ ├── __init__.py │ │ ├── _mapping.py │ │ ├── bbcode.py │ │ ├── html.py │ │ ├── img.py │ │ ├── latex.py │ │ ├── other.py │ │ ├── rtf.py │ │ ├── svg.py │ │ ├── terminal.py │ │ └── terminal256.py │ ├── lexer.py │ ├── lexers │ │ ├── __init__.py │ │ ├── _mapping.py │ │ ├── parsers.py │ │ └── python.py │ ├── modeline.py │ ├── plugin.py │ ├── regexopt.py │ ├── scanner.py │ ├── sphinxext.py │ ├── style.py │ ├── styles │ │ ├── __init__.py │ │ ├── autumn.py │ │ ├── borland.py │ │ ├── bw.py │ │ ├── colorful.py │ │ ├── default.py │ │ ├── emacs.py │ │ ├── friendly.py │ │ ├── fruity.py │ │ ├── igor.py │ │ ├── manni.py │ │ ├── monokai.py │ │ ├── murphy.py │ │ ├── native.py │ │ ├── paraiso_dark.py │ │ ├── paraiso_light.py │ │ ├── pastie.py │ │ ├── perldoc.py │ │ ├── rrt.py │ │ ├── tango.py │ │ ├── trac.py │ │ ├── vim.py │ │ ├── vs.py │ │ └── xcode.py │ ├── token.py │ ├── unistring.py │ └── util.py │ └── xmlWriter.py ├── GlyphsLogoDrawBot.png ├── README.md └── license.txt /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.pyc 3 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | plugin 9 | CFBundleIdentifier 10 | com.GeorgSeifert.DrawBot 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | DrawBot 15 | CFBundleShortVersionString 16 | 0.0.5 17 | CFBundleVersion 18 | 4 19 | CFBundleDocumentTypes 20 | 21 | 22 | CFBundleTypeExtensions 23 | 24 | py 25 | 26 | CFBundleTypeRole 27 | Editor 28 | LSItemContentTypes 29 | 30 | public.python-script 31 | 32 | NSDocumentClass 33 | DrawBotDocument 34 | 35 | 36 | UpdateFeedURL 37 | https://raw.githubusercontent.com/schriftgestalt/DrawBotGlyphsPlugin/master/DrawBot.glyphsPlugin/Contents/Info.plist 38 | productPageURL 39 | https://github.com/schriftgestalt/DrawBotGlyphsPlugin 40 | productReleaseNotes 41 | Improve Dark Mode 42 | NSHumanReadableCopyright 43 | Copyright, Georg Seifert, 2018 44 | NSPrincipalClass 45 | DrawBotPlugin 46 | PyMainFileNames 47 | 48 | DrawBotDocument.py 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/MacOS/plugin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schriftgestalt/DrawBotGlyphsPlugin/ed0f9f104be6d76d2be06d1bf933181782597492/DrawBot.glyphsPlugin/Contents/MacOS/plugin -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/DrawBotDocument.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import objc 3 | import sys, os, re 4 | from objc import super 5 | 6 | from Foundation import NSLog, NSString, NSUTF8StringEncoding 7 | from AppKit import NSApplication, NSDocumentController, NSDocument, NSMenuItem 8 | 9 | from GlyphsApp import Glyphs, FILE_MENU 10 | from GlyphsApp.plugins import GeneralPlugin 11 | 12 | class DrawBotPlugin(GeneralPlugin): 13 | 14 | @objc.python_method 15 | def settings(self): 16 | self.name = Glyphs.localize({'en': 'DrawBot'}) 17 | @objc.python_method 18 | def start(self): 19 | newMenuItem = NSMenuItem("New Drawbot", self.newDocument_) 20 | Glyphs.menu[FILE_MENU].insert(1, newMenuItem) 21 | 22 | def newDocument_(self, sender): 23 | newDoc = DrawBotDocument.new() 24 | NSDocumentController.sharedDocumentController().addDocument_(newDoc) 25 | newDoc.makeWindowControllers() 26 | newDoc.showWindows() 27 | 28 | class DrawBotDocument (NSDocument): 29 | 30 | def init(self): 31 | """ 32 | You can add an observer like in the example. 33 | Do all initializing here. 34 | """ 35 | self = super(DrawBotDocument, self).init() 36 | self.text = "" 37 | return self 38 | 39 | 40 | def makeWindowControllers(self): 41 | from DrawBotWindow import GlyphsDrawBotController 42 | WindowController = GlyphsDrawBotController.alloc().init() 43 | self.addWindowController_(WindowController) 44 | 45 | def windowController(self): 46 | return self.windowControllers()[0] 47 | 48 | # def __del__(self): 49 | # """ 50 | # Remove all observers you added in init(). 51 | # """ 52 | # pass 53 | 54 | def dataRepresentationOfType_(self, aType): 55 | if len(self.text) > 0: 56 | return NSString.stringWithString_(self.text).dataUsingEncoding_(NSUTF8StringEncoding) 57 | else: 58 | NSdata.data() 59 | 60 | def loadDataRepresentation_ofType_(self, data, aType): 61 | self.text = NSString.alloc().initWithData_encoding_(data, NSUTF8StringEncoding) 62 | return True 63 | 64 | def writableTypes(self): 65 | return ["public.python-script"] 66 | 67 | def isNativeType_(self, aType): 68 | return "public.python-script" == aType 69 | 70 | def autosavesInPlace(self): 71 | return False 72 | 73 | def autosavesDrafts(self): 74 | return True 75 | 76 | def font(self): 77 | return None 78 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .drawBotDrawingTools import _drawBotDrawingTool 4 | 5 | _drawBotDrawingTool._addToNamespace(globals()) 6 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .pdfContext import PDFContext 4 | from .imageContext import PNGContext, JPEGContext, TIFFContext, BMPContext 5 | from .gifContext import GIFContext 6 | from .svgContext import SVGContext 7 | from .movContext import MOVContext 8 | from .printContext import PrintContext 9 | from .mp4Context import MP4Context 10 | from .icnsContext import ICNSContext 11 | 12 | 13 | allContexts = [ 14 | PDFContext, 15 | PNGContext, 16 | JPEGContext, 17 | TIFFContext, 18 | SVGContext, 19 | GIFContext, 20 | BMPContext, 21 | MP4Context, 22 | MOVContext, 23 | ICNSContext, 24 | PrintContext 25 | ] 26 | 27 | 28 | def subscribeContext(context): 29 | for ctx in list(allContexts): 30 | if ctx.__name__ == context.__name__: 31 | allContexts.remove(ctx) 32 | allContexts.append(context) 33 | 34 | 35 | def getContextForFileExt(ext): 36 | for context in allContexts: 37 | if ext in context.fileExtensions: 38 | return context() 39 | return None 40 | 41 | 42 | def getContextOptions(): 43 | options = set() 44 | for context in allContexts: 45 | for key, _ in context.saveImageOptions: 46 | options.add(key) 47 | return options 48 | 49 | 50 | def getFileExtensions(): 51 | extensions = [] 52 | for context in allContexts: 53 | for ext in context.fileExtensions: 54 | if ext not in extensions: 55 | extensions.append(ext) 56 | return extensions 57 | 58 | 59 | def getContextOptionsDocs(formatter="* `%s`: %s"): 60 | docs = [] 61 | for context in allContexts: 62 | if context.saveImageOptions: 63 | ext = ", ".join(context.fileExtensions) 64 | docs.append("*%s options:*" % ext) 65 | docs.append("") 66 | for key, doc in context.saveImageOptions: 67 | docs.append(formatter % (key, doc)) 68 | docs.append("") 69 | return docs 70 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/drawBotContext.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import Quartz 4 | 5 | from .pdfContext import PDFContext 6 | 7 | 8 | class DrawBotContext(PDFContext): 9 | 10 | def getNSPDFDocument(self): 11 | if not self._hasContext: 12 | return None 13 | Quartz.CGPDFContextEndPage(self._pdfContext) 14 | Quartz.CGPDFContextClose(self._pdfContext) 15 | doc = Quartz.PDFDocument.alloc().initWithData_(self._pdfData) 16 | self._hasContext = False 17 | self._pdfContext = None 18 | self._pdfData = None 19 | return doc 20 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/dummyContext.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, print_function 2 | 3 | from .baseContext import BaseContext 4 | 5 | 6 | class DummyContext(BaseContext): 7 | 8 | pass 9 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/gifContext.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import Quartz 4 | 5 | import tempfile 6 | 7 | from .imageContext import ImageContext, getSaveImageOptions 8 | 9 | from .tools.gifTools import generateGif 10 | 11 | 12 | class GIFContext(ImageContext): 13 | 14 | fileExtensions = ["gif"] 15 | 16 | saveImageOptions = getSaveImageOptions([ 17 | "imageGIFDitherTransparency", 18 | "imageGIFRGBColorTable", 19 | "imageColorSyncProfileData", 20 | ]) 21 | 22 | _delay = 10 23 | 24 | def __init__(self): 25 | super(GIFContext, self).__init__() 26 | self._delayData = [] 27 | 28 | def _frameDuration(self, seconds): 29 | # gifsicle -h: Set frame delay to TIME (in 1/100sec). 30 | self._delayData[-1] = int(seconds * 100) 31 | 32 | def _newPage(self, width, height): 33 | super(GIFContext, self)._newPage(width, height) 34 | self._delayData.append(self._delay) 35 | 36 | def _writeDataToFile(self, data, path, options): 37 | pdfDocument = Quartz.PDFDocument.alloc().initWithData_(data) 38 | pageCount = pdfDocument.pageCount() 39 | shouldBeAnimated = pageCount > 1 40 | 41 | tempPath = path 42 | if shouldBeAnimated: 43 | options["multipage"] = True 44 | tempPath = tempfile.mkstemp(suffix=".gif")[1] 45 | 46 | inputPaths = super(GIFContext, self)._writeDataToFile(data, tempPath, options) 47 | 48 | if shouldBeAnimated: 49 | generateGif(inputPaths, path, self._delayData) 50 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/icnsContext.py: -------------------------------------------------------------------------------- 1 | import Quartz 2 | import os 3 | import shutil 4 | import tempfile 5 | 6 | from drawBot.misc import executeExternalProcess, DrawBotError 7 | from drawBot.context.imageContext import ImageContext 8 | 9 | 10 | class ICNSContext(ImageContext): 11 | 12 | fileExtensions = ["icns"] 13 | 14 | allowedPageSizes = [16, 32, 128, 256, 512, 1024] 15 | 16 | def _writeDataToFile(self, data, path, options): 17 | # create a iconset folder 18 | iconsetPath = tempfile.mkdtemp(suffix=".iconset") 19 | try: 20 | # get the complete pdf 21 | pdfDocument = Quartz.PDFDocument.alloc().initWithData_(data) 22 | pageCount = pdfDocument.pageCount() 23 | # set the image resolution 24 | options["imageResolution"] = 72 25 | # make a copy and alter the resolution 26 | options_2x = dict(options) 27 | options_2x["imageResolution"] = 144 28 | # start loop over all pages 29 | for index in range(pageCount): 30 | # get the pdf page 31 | page = pdfDocument.pageAtIndex_(index) 32 | # get the pdf page, this acts also as pdf document... 33 | pageData = page.dataRepresentation() 34 | # extract the size of the page 35 | _, (w, h) = page.boundsForBox_(Quartz.kPDFDisplayBoxArtBox) 36 | w = int(round(w)) 37 | h = int(round(h)) 38 | # dont allow any other size, the command iconutil will not work otherwise 39 | if w not in self.allowedPageSizes or w != h: 40 | raise DrawBotError("The .icns can not be build with the size '%sx%s'. Must be either: %s" % (w, h, ", ".join(["%sx%s" % (i, i) for i in self.allowedPageSizes]))) 41 | # generate a 72 dpi png in the iconset path 42 | pngPath = os.path.join(iconsetPath, "icon_%sx%s.png" % (w, h)) 43 | super(ICNSContext, self)._writeDataToFile(pageData, pngPath, options) 44 | # generate a 144 dpi png in the iconset path 45 | pngPath_2x = os.path.join(iconsetPath, "icon_%sx%s@2x.png" % (w, h)) 46 | super(ICNSContext, self)._writeDataToFile(pageData, pngPath_2x, options_2x) 47 | # collect all iconutil commands 48 | cmds = [ 49 | "iconutil", 50 | "--convert", 51 | "icns", 52 | "--output", 53 | path, 54 | iconsetPath, 55 | ] 56 | # execute the commands 57 | stdout, stderr = executeExternalProcess(cmds) 58 | finally: 59 | # always remove the iconset 60 | shutil.rmtree(iconsetPath) 61 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/imageContext.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division 2 | 3 | import AppKit 4 | import Quartz 5 | 6 | import os 7 | 8 | from .pdfContext import PDFContext 9 | from .baseContext import Color 10 | 11 | 12 | def _nsDataConverter(value): 13 | if isinstance(value, AppKit.NSData): 14 | return value 15 | return AppKit.NSData.dataWithBytes_length_(value, len(value)) 16 | 17 | 18 | def _nsColorConverter(color): 19 | if isinstance(color, AppKit.NSColor): 20 | return color 21 | color = Color(*color) 22 | return color.getNSObject() 23 | 24 | 25 | def _tiffCompressionConverter(value): 26 | if value is None: 27 | return AppKit.NSTIFFCompressionNone 28 | elif isinstance(value, int): 29 | return value 30 | else: 31 | t = dict(lzw=AppKit.NSTIFFCompressionLZW, packbits=AppKit.NSTIFFCompressionPackBits) 32 | return t.get(value.lower(), AppKit.NSTIFFCompressionNone) 33 | 34 | 35 | _nsImageOptions = { 36 | # DrawBot Key NSImage property key converter or None doc 37 | "imageColorSyncProfileData": (AppKit.NSImageColorSyncProfileData, _nsDataConverter, "A bytes or NSData object containing the ColorSync profile data."), 38 | "imageTIFFCompressionMethod": (AppKit.NSImageCompressionMethod, _tiffCompressionConverter, "None, or 'lzw' or 'packbits', or an NSTIFFCompression constant"), 39 | "imagePNGGamma": (AppKit.NSImageGamma, None, "The gamma value for the image. It is a floating-point number between 0.0 and 1.0, with 0.0 being black and 1.0 being the maximum color."), 40 | "imagePNGInterlaced": (AppKit.NSImageInterlaced, None, "Boolean value that indicates whether the image should be interlaced."), # XXX doesn't seem to work 41 | "imageJPEGCompressionFactor": (AppKit.NSImageCompressionFactor, None, "A float between 0.0 and 1.0, with 1.0 resulting in no compression and 0.0 resulting in the maximum compression possible"), # number 42 | "imageJPEGProgressive": (AppKit.NSImageProgressive, None, "Boolean that indicates whether the image should use progressive encoding."), 43 | # "imageJPEGEXIFData": (AppKit.NSImageEXIFData, None, ""), # dict XXX Doesn't seem to work 44 | "imageFallbackBackgroundColor": (AppKit.NSImageFallbackBackgroundColor, _nsColorConverter, "The background color to use when writing to an image format (such as JPEG) that doesn't support alpha. The color's alpha value is ignored. The default background color, when this property is not specified, is white. The value of the property should be an NSColor object or a DrawBot RGB color tuple."), 45 | "imageGIFDitherTransparency": (AppKit.NSImageDitherTransparency, None, "Boolean that indicates whether the image is dithered"), 46 | "imageGIFRGBColorTable": (AppKit.NSImageRGBColorTable, _nsDataConverter, "A bytes or NSData object containing the RGB color table."), 47 | } 48 | 49 | 50 | def getSaveImageOptions(options): 51 | return ImageContext.saveImageOptions + [ 52 | (dbKey, _nsImageOptions[dbKey][-1]) for dbKey in options if dbKey in _nsImageOptions 53 | ] 54 | 55 | 56 | class ImageContext(PDFContext): 57 | 58 | _saveImageFileTypes = { 59 | "jpg": AppKit.NSJPEGFileType, 60 | "jpeg": AppKit.NSJPEGFileType, 61 | "tiff": AppKit.NSTIFFFileType, 62 | "tif": AppKit.NSTIFFFileType, 63 | "gif": AppKit.NSGIFFileType, 64 | "png": AppKit.NSPNGFileType, 65 | "bmp": AppKit.NSBMPFileType 66 | } 67 | fileExtensions = [] 68 | 69 | saveImageOptions = [ 70 | ("imageResolution", "The resolution of the output image in PPI. Default is 72."), 71 | ("multipage", "Output a numbered image for each page or frame in the document."), 72 | ] 73 | 74 | def _writeDataToFile(self, data, path, options): 75 | multipage = options.get("multipage") 76 | if multipage is None: 77 | multipage = False 78 | fileName, fileExt = os.path.splitext(path) 79 | ext = fileExt[1:] 80 | pdfDocument = Quartz.PDFDocument.alloc().initWithData_(data) 81 | firstPage = 0 82 | pageCount = pdfDocument.pageCount() 83 | pathAdd = "_1" 84 | if not multipage: 85 | firstPage = pageCount - 1 86 | pathAdd = "" 87 | outputPaths = [] 88 | imageResolution = options.get("imageResolution", 72.0) 89 | properties = {} 90 | for key, value in options.items(): 91 | if key in _nsImageOptions: 92 | nsKey, converter, _ = _nsImageOptions[key] 93 | if converter is not None: 94 | value = converter(value) 95 | properties[nsKey] = value 96 | for index in range(firstPage, pageCount): 97 | pool = AppKit.NSAutoreleasePool.alloc().init() 98 | try: 99 | page = pdfDocument.pageAtIndex_(index) 100 | image = AppKit.NSImage.alloc().initWithData_(page.dataRepresentation()) 101 | imageRep = _makeBitmapImageRep(image, imageResolution) 102 | imageData = imageRep.representationUsingType_properties_(self._saveImageFileTypes[ext], properties) 103 | imagePath = fileName + pathAdd + fileExt 104 | imageData.writeToFile_atomically_(imagePath, True) 105 | pathAdd = "_%s" % (index + 2) 106 | outputPaths.append(imagePath) 107 | del page, imageRep, imageData 108 | finally: 109 | del pool 110 | return outputPaths 111 | 112 | 113 | def _makeBitmapImageRep(image, imageResolution=72.0, colorSpaceName=AppKit.NSCalibratedRGBColorSpace): 114 | """Construct a bitmap image representation at a given resolution.""" 115 | scaleFactor = max(1.0, imageResolution) / 72.0 116 | rep = AppKit.NSBitmapImageRep.alloc().initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_( 117 | None, # planes 118 | int(image.size().width * scaleFactor), # pixelsWide 119 | int(image.size().height * scaleFactor), # pixelsHigh 120 | 8, # bitsPerSample 121 | 4, # samplesPerPixel 122 | True, # hasAlpha 123 | False, # isPlanar 124 | colorSpaceName, # colorSpaceName 125 | 0, # bytesPerRow 126 | 0 # bitsPerPixel 127 | ) 128 | rep.setSize_(image.size()) 129 | 130 | AppKit.NSGraphicsContext.saveGraphicsState() 131 | try: 132 | AppKit.NSGraphicsContext.setCurrentContext_( 133 | AppKit.NSGraphicsContext.graphicsContextWithBitmapImageRep_(rep)) 134 | image.drawAtPoint_fromRect_operation_fraction_((0, 0), AppKit.NSZeroRect, AppKit.NSCompositeSourceOver, 1.0) 135 | finally: 136 | AppKit.NSGraphicsContext.restoreGraphicsState() 137 | return rep 138 | 139 | 140 | # ================================ 141 | # = contexts for file extensions = 142 | # ================================ 143 | 144 | class JPEGContext(ImageContext): 145 | 146 | fileExtensions = ["jpg", "jpeg"] 147 | 148 | saveImageOptions = getSaveImageOptions([ 149 | "imageJPEGCompressionFactor", 150 | "imageJPEGProgressive", 151 | "imageFallbackBackgroundColor", 152 | "imageColorSyncProfileData", 153 | ]) 154 | 155 | 156 | class BMPContext(ImageContext): 157 | 158 | fileExtensions = ["bmp"] 159 | 160 | 161 | class PNGContext(ImageContext): 162 | 163 | fileExtensions = ["png"] 164 | 165 | saveImageOptions = getSaveImageOptions([ 166 | "imagePNGGamma", 167 | "imagePNGInterlaced", 168 | "imageColorSyncProfileData", 169 | ]) 170 | 171 | 172 | class TIFFContext(ImageContext): 173 | 174 | fileExtensions = ["tif", "tiff"] 175 | 176 | saveImageOptions = getSaveImageOptions([ 177 | "imageTIFFCompressionMethod", 178 | "imageColorSyncProfileData", 179 | ]) 180 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/movContext.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import AppKit 4 | import QTKit 5 | import Quartz 6 | 7 | import os 8 | 9 | from drawBot.misc import DrawBotError 10 | from .pdfContext import PDFContext 11 | 12 | 13 | class MOVContext(PDFContext): 14 | 15 | fileExtensions = ["mov"] 16 | saveImageOptions = [] 17 | 18 | _saveMovieAttributes = { 19 | QTKit.QTAddImageCodecType: "png " 20 | } 21 | 22 | _frameLength = 3000 23 | _frameScale = 30000 24 | 25 | def __init__(self): 26 | super(MOVContext, self).__init__() 27 | self._frameDurationData = [] 28 | 29 | def _newPage(self, width, height): 30 | super(MOVContext, self)._newPage(width, height) 31 | self._frameDurationData.append((self._frameLength, self._frameScale)) 32 | self.save() 33 | self.fill(1, 1, 1, 1) 34 | self.rect(0, 0, self.width, self.height) 35 | self.restore() 36 | 37 | def _frameDuration(self, seconds): 38 | length = seconds * self._frameScale 39 | self._frameDurationData[-1] = length, self._frameScale 40 | 41 | def _writeDataToFile(self, data, path, options): 42 | if os.path.exists(path): 43 | os.remove(path) 44 | movie, error = QTKit.QTMovie.alloc().initToWritableFile_error_(path, None) 45 | if error: 46 | raise DrawBotError("Could not create a quick time movie, %s" % error.localizedDescription()) 47 | 48 | pdfDocument = Quartz.PDFDocument.alloc().initWithData_(data) 49 | 50 | for index in range(pdfDocument.pageCount()): 51 | pool = AppKit.NSAutoreleasePool.alloc().init() 52 | try: 53 | frameLength, frameScale = self._frameDurationData[index] 54 | duration = QTKit.QTMakeTime(frameLength, frameScale) 55 | page = pdfDocument.pageAtIndex_(index) 56 | image = AppKit.NSImage.alloc().initWithData_(page.dataRepresentation()) 57 | movie.addImage_forDuration_withAttributes_(image, duration, self._saveMovieAttributes) 58 | finally: 59 | del pool 60 | movie.updateMovieFile() 61 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/mp4Context.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import tempfile 5 | import shutil 6 | from drawBot.misc import warnings 7 | 8 | from .imageContext import PNGContext, getSaveImageOptions 9 | 10 | from .tools.mp4Tools import generateMP4 11 | 12 | 13 | class MP4Context(PNGContext): 14 | 15 | fileExtensions = ["mp4"] 16 | 17 | saveImageOptions = [ 18 | ("ffmpegCodec", "The codec to be used by ffmpeg. By default it is 'libx264' (for H.264). The 'mpeg4' codec gives better results when importing the movie into After Effects, at the expense of a larger file size."), 19 | ] + [(key, doc) for key, doc in PNGContext.saveImageOptions if key != "multipage"] 20 | 21 | _defaultFrameDuration = 1 / 10 22 | 23 | def __init__(self): 24 | super(MP4Context, self).__init__() 25 | self._frameDurations = [] 26 | 27 | def _frameDuration(self, frameDuration): 28 | self._frameDurations[-1] = frameDuration 29 | 30 | def _newPage(self, width, height): 31 | super(MP4Context, self)._newPage(width, height) 32 | self._frameDurations.append(self._defaultFrameDuration) 33 | 34 | def _writeDataToFile(self, data, path, options): 35 | frameRate = round(1.0 / self._frameDurations[0], 3) 36 | frameDurations = set(self._frameDurations) 37 | if len(frameDurations) > 1: 38 | warnings.warn("Exporting to mp4 doesn't support varying frame durations, only the first value was used.") 39 | 40 | options["multipage"] = True 41 | codec = options.get("ffmpegCodec", "libx264") 42 | tempDir = tempfile.mkdtemp(suffix=".mp4tmp") 43 | try: 44 | super(MP4Context, self)._writeDataToFile(data, os.path.join(tempDir, "frame.png"), options) 45 | generateMP4(os.path.join(tempDir, "frame_%d.png"), path, frameRate, codec) 46 | finally: 47 | shutil.rmtree(tempDir) 48 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/printContext.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, print_function 2 | import AppKit 3 | from fontTools.pens.basePen import AbstractPen 4 | 5 | from .baseContext import BaseContext 6 | 7 | 8 | class StringPen(AbstractPen): 9 | 10 | def __init__(self, seperator=None): 11 | self.data = [] 12 | if seperator is None: 13 | seperator = " " 14 | self.seperator = seperator 15 | 16 | def moveTo(self, pt): 17 | x, y = pt 18 | self.data.append("moveTo %s %s" % (x, y)) 19 | 20 | def lineTo(self, pt): 21 | x, y = pt 22 | self.data.append("lineTo %s %s" % (x, y)) 23 | 24 | def curveTo(self, *pts): 25 | self.data.append("curveTo %s" % " ".join(["%s %s" % (x, y) for x, y in pts])) 26 | 27 | def qCurveTo(self, *pts): 28 | self.data.append("qCurveTo %s" % " ".join(["%s %s" % (x, y) for x, y in pts])) 29 | 30 | def closePath(self): 31 | self.data.append("closePath") 32 | 33 | def endPath(self): 34 | self.data.append("endPath") 35 | 36 | def __repr__(self): 37 | return self.seperator.join(self.data) 38 | 39 | 40 | class PrintContext(BaseContext): 41 | 42 | fileExtensions = ["*"] 43 | validateSaveImageOptions = False 44 | 45 | def _newPage(self, width, height): 46 | print("newPage %s %s" % (width, height)) 47 | 48 | def _save(self): 49 | print("save") 50 | 51 | def _restore(self): 52 | print("restore") 53 | 54 | def _blendMode(self, operation): 55 | print("blendMode %s" % operation) 56 | 57 | def _drawPath(self): 58 | pen = StringPen() 59 | self._state.path.drawToPen(pen) 60 | print("drawPath %s" % pen) 61 | 62 | def _clipPath(self): 63 | pen = StringPen() 64 | self._state.path.drawToPen(pen) 65 | print("clipPath %s" % pen) 66 | 67 | def _transform(self, matrix): 68 | print("transform %s" % " ".join(["%s" % i for i in matrix])) 69 | 70 | def _textBox(self, txt, xywh, align): 71 | # XXX 72 | # should a formatted string be printed in parts??? 73 | x, y, w, h = xywh 74 | print("textBox %s %r %r %r %r %s" % (txt, x, y, w, h, align)) 75 | 76 | def _image(self, path, xy, alpha, pageNumber): 77 | x, y = xy 78 | if isinstance(path, AppKit.NSImage): 79 | path = "Image Object" 80 | print("image %s %s %s %s %s" % (path, x, y, alpha, pageNumber)) 81 | 82 | def _frameDuration(self, seconds): 83 | print("frameDuration %s" % seconds) 84 | 85 | def _reset(self, other=None): 86 | print("reset %s" % other) 87 | 88 | def _saveImage(self, path, options): 89 | print("saveImage %s %s" % (path, options)) 90 | 91 | def _printImage(self, pdf=None): 92 | print("printImage %s" % pdf) 93 | 94 | def _linkDestination(self, name, xy): 95 | x, y = xy 96 | print("linkDestination %s %s %s" % (name, x, y)) 97 | 98 | def _linkRect(self, name, xywh): 99 | x, y, w, h = xywh 100 | print("linkRect %s %s %s %s %s" % (name, x, y, w, h)) 101 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schriftgestalt/DrawBotGlyphsPlugin/ed0f9f104be6d76d2be06d1bf933181782597492/DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/tools/__init__.py -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/tools/gifTools.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import AppKit 4 | import shutil 5 | import os 6 | import tempfile 7 | 8 | from drawBot.misc import executeExternalProcess, getExternalToolPath 9 | 10 | 11 | def generateGif(sourcePaths, destPath, delays): 12 | gifsiclePath = getExternalToolPath(os.path.dirname(__file__), "gifsicle") 13 | assert gifsiclePath is not None 14 | cmds = [ 15 | # gifsicle path 16 | gifsiclePath, 17 | # optimize level 18 | # "-O3", 19 | # ignore warnings 20 | "-w", 21 | # force to 256 colors 22 | "--colors", "256", 23 | # make it loop 24 | "--loop", 25 | ] 26 | # add source paths with delay for each frame 27 | for i, inputPath in enumerate(sourcePaths): 28 | cmds += [ 29 | # add the frame duration 30 | "--delay", "%i" % delays[i], 31 | # add the input gif for each frame 32 | inputPath 33 | ] 34 | 35 | cmds += [ 36 | # output path 37 | "--output", 38 | destPath 39 | ] 40 | executeExternalProcess(cmds) 41 | # remove the temp input gifs 42 | for inputPath in sourcePaths: 43 | os.remove(inputPath) 44 | 45 | 46 | _explodedGifCache = {} 47 | 48 | 49 | def _explodeGif(path): 50 | gifsiclePath = getExternalToolPath(os.path.dirname(__file__), "gifsicle") 51 | if isinstance(path, AppKit.NSURL): 52 | path = path.path() 53 | destRoot = tempfile.mkdtemp() 54 | cmds = [ 55 | gifsiclePath, 56 | # explode 57 | "--explode", 58 | # source path 59 | path 60 | ] 61 | executeExternalProcess(cmds, cwd=destRoot) 62 | files = os.listdir(destRoot) 63 | _explodedGifCache[path] = dict( 64 | source=destRoot, 65 | fileNames=files, 66 | ) 67 | 68 | 69 | def clearExplodedGifCache(): 70 | for path, info in _explodedGifCache.items(): 71 | shutil.rmtree(info["source"]) 72 | _explodedGifCache.clear() 73 | 74 | 75 | def gifFrameCount(path): 76 | if isinstance(path, AppKit.NSURL): 77 | path = path.path() 78 | if path not in _explodedGifCache: 79 | _explodeGif(path) 80 | frameCount = len(_explodedGifCache[path]["fileNames"]) 81 | if frameCount == 0: 82 | return None 83 | return frameCount 84 | 85 | 86 | def gifFrameAtIndex(path, index): 87 | if isinstance(path, AppKit.NSURL): 88 | path = path.path() 89 | if path not in _explodedGifCache: 90 | _explodeGif(path) 91 | source = _explodedGifCache[path]["source"] 92 | fileNames = _explodedGifCache[path]["fileNames"] 93 | fileName = os.path.join(source, fileNames[index]) 94 | url = AppKit.NSURL.fileURLWithPath_(fileName) 95 | return AppKit.NSImage.alloc().initByReferencingURL_(url) 96 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/tools/gifsicleLicense: -------------------------------------------------------------------------------- 1 | Copyright/License 2 | 3 | All source code is Copyright (C) 1997-2013 Eddie Kohler. 4 | 5 | IF YOU PLAN TO USE GIFSICLE ONLY TO CREATE OR MODIFY GIF IMAGES, DON'T WORRY ABOUT THE REST OF THIS SECTION. Anyone can use Gifsicle however they wish; the license applies only to those who plan to copy, distribute, or alter its code. If you use Gifsicle for an organizational or commercial Web site, I would appreciate a link to the Gifsicle home page on any 'About This Server' page, but it's not required. 6 | 7 | This code is distributed under the GNU General Public License, Version 2 (and only Version 2). The GNU General Public License is available via the Web at http://www.gnu.org/licenses/gpl.html or in the 'COPYING' file in this directory. 8 | 9 | The following alternative license may be used at your discretion. 10 | 11 | Permission is granted to copy, distribute, or alter Gifsicle, whole or in part, as long as source code copyright notices are kept intact, with the following restriction: Developers or distributors who plan to use Gifsicle code, whole or in part, in a product whose source code will not be made available to the end user -- more precisely, in a context which would violate the GPL -- MUST contact the author and obtain permission before doing so. -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/tools/mp4Tools.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | 5 | from drawBot.misc import executeExternalProcess, getExternalToolPath 6 | 7 | 8 | def generateMP4(imageTemplate, mp4path, frameRate, codec="libx264"): 9 | ffmpegPath = getExternalToolPath(os.path.dirname(__file__), "ffmpeg") 10 | assert ffmpegPath is not None 11 | cmds = [ 12 | # ffmpeg path 13 | ffmpegPath, 14 | "-y", # overwrite existing files 15 | "-loglevel", "16", # 'error, 16' Show all errors, including ones which can be recovered from. 16 | "-r", str(frameRate), # frame rate 17 | "-i", imageTemplate, # input sequence 18 | "-c:v", codec, # codec 19 | "-crf", "20", # Constant Rate Factor 20 | "-pix_fmt", "yuv420p", # pixel format 21 | mp4path, # output path 22 | ] 23 | executeExternalProcess(cmds) 24 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/tools/openType.py: -------------------------------------------------------------------------------- 1 | import os 2 | import AppKit 3 | import CoreText 4 | 5 | from fontTools.ttLib import TTFont 6 | from fontTools.ttLib.ttCollection import TTCollection 7 | from fontTools.misc.macCreatorType import getMacCreatorAndType 8 | from fontTools.misc.macRes import ResourceReader 9 | 10 | from drawBot.misc import memoize 11 | from . import SFNTLayoutTypes 12 | 13 | 14 | def getFeatureTagsForFontAttributes(attributes): 15 | featureTags = dict() 16 | for attribute in attributes: 17 | tag = attribute.get("CTFeatureOpenTypeTag") 18 | if tag is not None: 19 | featureTags[tag] = attribute.get("CTFeatureOpenTypeValue", True) 20 | else: 21 | # Fallback for macOS < 10.13 22 | featureType = attribute.get("CTFeatureTypeIdentifier") 23 | featureSelector = attribute.get("CTFeatureSelectorIdentifier") 24 | tag = SFNTLayoutTypes.reversedFeatureMap[(featureType, featureSelector)] 25 | value = True 26 | if len(tag) == 8 and tag.endswith("_off"): 27 | value = False 28 | tag = tag[:4] 29 | featureTags[tag] = value 30 | return featureTags 31 | 32 | 33 | @memoize 34 | def getFeatureTagsForFontName(fontName): 35 | featureTags = [] 36 | font = AppKit.NSFont.fontWithName_size_(fontName, 12) 37 | if font is None: 38 | return featureTags 39 | fontDescriptor = font.fontDescriptor() 40 | url = CoreText.CTFontDescriptorCopyAttribute(fontDescriptor, CoreText.kCTFontURLAttribute) 41 | psFontName = CoreText.CTFontDescriptorCopyAttribute(fontDescriptor, CoreText.kCTFontNameAttribute) 42 | if url is None or psFontName is None: 43 | return featureTags 44 | path = url.path() 45 | ext = os.path.splitext(path)[1].lower() 46 | macType = getMacCreatorAndType(path)[1] 47 | if ext in (".ttc", ".otc"): 48 | ft = _getTTFontFromTTC(path, psFontName) 49 | elif ext in (".ttf", ".otf"): 50 | ft = TTFont(path, lazy=True) 51 | elif ext == ".dfont" or macType == "FFIL": 52 | ft = _getTTFontFromSuitcase(path, psFontName) 53 | if ft is None: 54 | return featureTags 55 | else: 56 | return featureTags 57 | featureTags = set() 58 | if "GPOS" in ft and ft["GPOS"].table.FeatureList is not None: 59 | for record in ft["GPOS"].table.FeatureList.FeatureRecord: 60 | featureTags.add(record.FeatureTag) 61 | if "GSUB" in ft and ft["GSUB"].table.FeatureList is not None: 62 | for record in ft["GSUB"].table.FeatureList.FeatureRecord: 63 | featureTags.add(record.FeatureTag) 64 | if "feat" in ft: 65 | for featureName in ft["feat"].table.FeatureNames.FeatureName: 66 | for featureSetting in featureName.Settings.Setting: 67 | featureTag = SFNTLayoutTypes.reversedFeatureMap.get((featureName.FeatureType, featureSetting.SettingValue)) 68 | if featureTag: 69 | featureTag = featureTag.replace("_off", "") 70 | featureTags.add(featureTag) 71 | ft.close() 72 | return list(sorted(featureTags)) 73 | 74 | 75 | def _getTTFontFromSuitcase(path, psFontName, searchOrder=((1, 0), (3, 1))): 76 | # Support for .dfont and especially "regular" suitcases is minimal, 77 | # and we will not raise an error when the requested font isn't found, 78 | # but will return None. 79 | rr = ResourceReader(path) 80 | if "sfnt" not in rr: 81 | return None 82 | for index in rr.getIndices("sfnt"): 83 | font = TTFont(path, lazy=True, res_name_or_index=index) 84 | for platID, platEncID in searchOrder: 85 | nameRecord = font["name"].getName(6, platID, platEncID) 86 | if nameRecord is not None and str(nameRecord) == psFontName: 87 | return font 88 | return None 89 | 90 | 91 | def _getTTFontFromTTC(path, psFontName, searchOrder=((1, 0), (3, 1))): 92 | ttc = TTCollection(path, lazy=True) 93 | for font in ttc: 94 | for platID, platEncID in searchOrder: 95 | nameRecord = font["name"].getName(6, platID, platEncID) 96 | if nameRecord is not None and str(nameRecord) == psFontName: 97 | return font 98 | raise IndexError("font %s not found" % psFontName) 99 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/context/tools/variation.py: -------------------------------------------------------------------------------- 1 | import CoreText 2 | from collections import OrderedDict 3 | 4 | from drawBot.misc import memoize 5 | 6 | """ 7 | https://developer.apple.com/documentation/coretext/ctfont/font_variation_axis_dictionary_keys?language=objc 8 | https://developer.apple.com/documentation/coretext/1508650-ctfontdescriptorcreatecopywithva?language=objc 9 | """ 10 | 11 | 12 | def convertIntToVariationTag(value): 13 | chars = [] 14 | for shift in range(4): 15 | chars.append(chr((value >> (shift * 8)) & 0xff)) 16 | return "".join(reversed(chars)) 17 | 18 | 19 | def convertVariationTagToInt(tag): 20 | assert len(tag) == 4 21 | i = 0 22 | for c in tag: 23 | i <<= 8 24 | i |= ord(c) 25 | return i 26 | 27 | 28 | @memoize 29 | def getVariationAxesForFontName(fontName): 30 | axes = OrderedDict() 31 | font = CoreText.CTFontCreateWithName(fontName, 12, None) 32 | variationAxesDescriptions = CoreText.CTFontCopyVariationAxes(font) 33 | if variationAxesDescriptions is None: 34 | # 'normal' fonts have no axes descriptions 35 | return axes 36 | for variationAxesDescription in variationAxesDescriptions: 37 | tag = convertIntToVariationTag(variationAxesDescription[CoreText.kCTFontVariationAxisIdentifierKey]) 38 | name = variationAxesDescription[CoreText.kCTFontVariationAxisNameKey] 39 | minValue = variationAxesDescription[CoreText.kCTFontVariationAxisMinimumValueKey] 40 | maxValue = variationAxesDescription[CoreText.kCTFontVariationAxisMaximumValueKey] 41 | defaultValue = variationAxesDescription[CoreText.kCTFontVariationAxisDefaultValueKey] 42 | data = dict(name=name, minValue=minValue, maxValue=maxValue, defaultValue=defaultValue) 43 | axes[tag] = data 44 | return axes 45 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/drawBotPageDrawingTools.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .drawBotDrawingTools import _drawBotDrawingTool, DrawBotDrawingTool 4 | 5 | 6 | class DummyDrawBotDrawingTool(DrawBotDrawingTool): 7 | 8 | def __init__(self, instructionSet): 9 | super(DummyDrawBotDrawingTool, self).__init__() 10 | # add the instruction set 11 | self._instructionsStack.append(instructionSet) 12 | # draw all instructions into it self 13 | # just to set all attributes into the dummycontext 14 | # this is important for the current state 15 | self._drawInContext(self) 16 | 17 | def _addInstruction(self, callback, *args, **kwargs): 18 | # dont add any instructions 19 | pass 20 | 21 | 22 | class DrawBotPage(object): 23 | 24 | def __init__(self, instructionSet): 25 | self._instructionSet = instructionSet 26 | 27 | def __enter__(self): 28 | # copy/save a state of the existing drawing tool 29 | self._originalTool = _drawBotDrawingTool._copy() 30 | # load the instructions 31 | pageTool = DummyDrawBotDrawingTool(self._instructionSet) 32 | # overwrite the globals newPage and size 33 | _drawBotDrawingTool._isSinglePage = True 34 | # reset the existing one, with the page tool 35 | _drawBotDrawingTool._reset(pageTool) 36 | return self 37 | 38 | def __exit__(self, type, value, traceback): 39 | # reset the main drawing tool with a saved state of the tool 40 | _drawBotDrawingTool._reset(self._originalTool) 41 | # reset the globals newPage and size 42 | _drawBotDrawingTool._isSinglePage = False 43 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/drawBotSettings.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.version_info[0] >= 3: 4 | appName = "DrawBotPy3" 5 | else: 6 | appName = "DrawBot" 7 | 8 | 9 | __version__ = "3.114" 10 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/macOSVersion.py: -------------------------------------------------------------------------------- 1 | from distutils.version import StrictVersion 2 | import platform 3 | 4 | # It is safe to compare osVersion to strings, as StrictVersion casts strings 5 | # to StrictVersion instances upon compare. 6 | macOSVersion = StrictVersion(platform.mac_ver("0.0.0")[0]) 7 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/ui/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schriftgestalt/DrawBotGlyphsPlugin/ed0f9f104be6d76d2be06d1bf933181782597492/DrawBot.glyphsPlugin/Contents/Resources/drawBot/ui/__init__.py -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/ui/debug.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from Foundation import NSLog 4 | from AppKit import NSPanel 5 | 6 | import sys 7 | 8 | from vanilla import * 9 | 10 | from .codeEditor import OutPutEditor 11 | 12 | 13 | class ShowHideNSPanel(NSPanel): 14 | 15 | def close(self): 16 | self.orderOut_(None) 17 | 18 | 19 | class ShowHideFloatingWindow(FloatingWindow): 20 | 21 | nsWindowClass = ShowHideNSPanel 22 | 23 | 24 | class DebugWindowController(object): 25 | 26 | """ 27 | Debugger catching all sys.stdout and sys.sterr outside a script. 28 | """ 29 | 30 | def __init__(self): 31 | self.w = ShowHideFloatingWindow((300, 500), "Debugger", 32 | minSize=(200, 300), 33 | autosaveName="DrawBotDebugWindow", 34 | initiallyVisible=False) 35 | 36 | self.w.debugText = OutPutEditor((0, 0, -0, -0), readOnly=True) 37 | 38 | self._savedStdout = sys.stdout 39 | self._savedStderr = sys.stderr 40 | 41 | sys.stdout = self 42 | sys.stderr = self 43 | 44 | self.w.open() 45 | 46 | def showHide(self): 47 | if self.w.isVisible(): 48 | self.w.hide() 49 | else: 50 | self.show() 51 | 52 | def show(self): 53 | self.w.show() 54 | self.w.select() 55 | 56 | def clear(self, sender=None): 57 | """ 58 | Clear all text in the output window. 59 | """ 60 | self.w.debugText.clear() 61 | 62 | def write(self, inputText): 63 | """ 64 | Write text in the output window. 65 | Duplicate the text also in the default logging system 66 | so it will appear in the console.app. 67 | """ 68 | NSLog(inputText) 69 | self.w.debugText.append(inputText) 70 | self.w.debugText.scrollToEnd() 71 | 72 | def flush(self): 73 | pass 74 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/ui/drawView.py: -------------------------------------------------------------------------------- 1 | from Foundation import NSURL 2 | from AppKit import NSDragOperationNone, NSBezelBorder 3 | from Quartz import PDFView, PDFThumbnailView, PDFDocument 4 | import traceback 5 | from vanilla import Group 6 | 7 | epsPasteBoardType = "CorePasteboardFlavorType 0x41494342" 8 | 9 | 10 | class DrawBotPDFThumbnailView(PDFThumbnailView): 11 | 12 | def draggingUpdated_(self, draggingInfo): 13 | return NSDragOperationNone 14 | 15 | 16 | class ThumbnailView(Group): 17 | 18 | nsViewClass = DrawBotPDFThumbnailView 19 | 20 | def setDrawView(self, view): 21 | self.getNSView().setPDFView_(view.getNSView()) 22 | 23 | def getSelection(self): 24 | try: 25 | # sometimes this goes weirdly wrong... 26 | selection = self.getNSView().selectedPages() 27 | except: 28 | return -1 29 | if selection: 30 | for page in selection: 31 | document = page.document() 32 | index = document.indexForPage_(page) 33 | return index 34 | return -1 35 | 36 | 37 | class DrawBotPDFView(PDFView): 38 | 39 | def performKeyEquivalent_(self, event): 40 | # catch a bug in PDFView 41 | # cmd + ` causes a traceback 42 | # DrawBot[15705]: -[__NSCFConstantString characterAtIndex:]: Range or index out of bounds 43 | try: 44 | return super(DrawBotPDFView, self).performKeyEquivalent_(event) 45 | except: 46 | return False 47 | 48 | 49 | class DrawView(Group): 50 | 51 | nsViewClass = DrawBotPDFView 52 | 53 | def __init__(self, posSize): 54 | super(DrawView, self).__init__(posSize) 55 | pdfView = self.getNSView() 56 | pdfView.setAutoScales_(True) 57 | view = pdfView.documentView() 58 | if view is not None: 59 | scrollview = view.enclosingScrollView() 60 | scrollview.setBorderType_(NSBezelBorder) 61 | 62 | def get(self): 63 | pdf = self.getNSView().document() 64 | if pdf is None: 65 | return None 66 | return pdf.dataRepresentation() 67 | 68 | def set(self, pdfData): 69 | pdf = PDFDocument.alloc().initWithData_(pdfData) 70 | self.setPDFDocument(pdf) 71 | 72 | def setPath(self, path): 73 | url = NSURL.fileURLWithPath_(path) 74 | document = PDFDocument.alloc().initWithURL_(url) 75 | self.setPDFDocument(document) 76 | 77 | def setPDFDocument(self, document): 78 | if document is None: 79 | document = PDFDocument.alloc().init() 80 | self.getNSView().setDocument_(document) 81 | 82 | def getPDFDocument(self): 83 | return self.getNSView().document() 84 | 85 | def setScale(self, scale): 86 | self.getNSView().setScaleFactor_(scale) 87 | 88 | def scale(self): 89 | return self.getNSView().scaleFactor() 90 | 91 | def scrollDown(self): 92 | document = self.getNSView().documentView() 93 | document.scrollPoint_((0, 0)) 94 | 95 | def scrollToPageIndex(self, index): 96 | pdf = self.getPDFDocument() 97 | if pdf is None: 98 | self.scrollDown() 99 | elif 0 <= index < pdf.pageCount(): 100 | try: 101 | # sometimes this goes weirdly wrong... 102 | page = pdf.pageAtIndex_(index) 103 | self.getNSView().goToPage_(page) 104 | except: 105 | self.scrollDown() 106 | else: 107 | self.scrollDown() 108 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/ui/lineNumberRulerView.py: -------------------------------------------------------------------------------- 1 | import objc 2 | LineNumberNSRulerView = objc.lookUpClass("GSLineNumberView") 3 | 4 | ''' 5 | 6 | from Foundation import NSInvocation, NSString, NSMakeRange, NSMaxRange, NSLocationInRange, NSNotFound, NSMakeRect, NSMinY, NSWidth, NSHeight 7 | from AppKit import NSRulerView, NSMiniControlSize, NSTextView, NSNotificationCenter, \ 8 | NSFontAttributeName, NSForegroundColorAttributeName, NSTextStorageDidProcessEditingNotification, \ 9 | NSFont, NSColor, NSBezierPath, NSRectFill 10 | import math 11 | from objc import super 12 | 13 | 14 | """ 15 | Based/translated from NoodleLineNumberView 16 | http://www.noodlesoft.com/blog/2008/10/05/displaying-line-numbers-with-nstextview/ 17 | """ 18 | 19 | 20 | class LineNumberNSRulerView(NSRulerView): 21 | 22 | DEFAULT_THICKNESS = 22. 23 | RULER_MARGIN = 5. 24 | 25 | def init(self): 26 | self = super(LineNumberNSRulerView, self).init() 27 | self._font = NSFont.labelFontOfSize_(NSFont.systemFontSizeForControlSize_(NSMiniControlSize)) 28 | self._textColor = NSColor.colorWithCalibratedWhite_alpha_(.42, 1) 29 | self._rulerBackgroundColor = None 30 | 31 | self._lineIndices = None 32 | return self 33 | 34 | def setFont_(self, font): 35 | self._font = font 36 | 37 | def font(self): 38 | return self._font 39 | 40 | def setTextColor_(self, color): 41 | self._textColor = color 42 | self.setNeedsDisplay_(True) 43 | 44 | def textColor(self): 45 | return self._textColor 46 | 47 | def textAttributes(self): 48 | return { 49 | NSFontAttributeName: self.font(), 50 | NSForegroundColorAttributeName: self.textColor() 51 | } 52 | 53 | def setRulerBackgroundColor_(self, color): 54 | self._rulerBackgroundColor = color 55 | self.setNeedsDisplay_(True) 56 | 57 | def rulerBackgroundColor(self): 58 | return self._rulerBackgroundColor 59 | 60 | def setClientView_(self, view): 61 | oldClientView = self.clientView() 62 | 63 | if oldClientView != view and isinstance(oldClientView, NSTextView): 64 | NSNotificationCenter.defaultCenter().removeObserver_name_object_(self, NSTextStorageDidProcessEditingNotification, oldClientView.textStorage()) 65 | 66 | super(LineNumberNSRulerView, self).setClientView_(view) 67 | 68 | if view is not None and isinstance(view, NSTextView): 69 | NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "textDidChange:", 70 | NSTextStorageDidProcessEditingNotification, 71 | view.textStorage()) 72 | 73 | def lineIndices(self): 74 | if self._lineIndices is None: 75 | self.calculateLines() 76 | return self._lineIndices 77 | 78 | def invalidateLineIndices(self): 79 | self._lineIndices = None 80 | 81 | def textDidChange_(self, sender): 82 | self.calculateLines() 83 | self.invalidateLineIndices() 84 | self.setNeedsDisplay_(True) 85 | 86 | def dealloc(self): 87 | # make sure we remove ourselves as an observer of the text storage 88 | view = self.clientView() 89 | if view is not None: 90 | NSNotificationCenter.defaultCenter().removeObserver_name_object_(self, NSTextStorageDidProcessEditingNotification, view.textStorage()) 91 | super(LineNumberNSRulerView, self).dealloc() 92 | 93 | def calculateLines(self): 94 | view = self.clientView() 95 | if not isinstance(view, NSTextView): 96 | return 97 | 98 | text = view.string() 99 | textLength = text.length() 100 | 101 | if not textLength: 102 | self._lineIndices = [1] 103 | return 104 | 105 | lineIndices = [] 106 | 107 | index = 0 108 | numberOfLines = 0 109 | while index < textLength: 110 | lineIndices.append(index) 111 | index = NSMaxRange(text.lineRangeForRange_(NSMakeRange(index, 0))) 112 | numberOfLines += 1 113 | 114 | lineStart, lineEnd, contentEnd = text.getLineStart_end_contentsEnd_forRange_(None, None, None, NSMakeRange(lineIndices[-1], 0)) 115 | 116 | if contentEnd < lineEnd: 117 | lineIndices.append(index) 118 | 119 | self._lineIndices = lineIndices 120 | 121 | oldThickness = self.ruleThickness() 122 | newThickness = self.requiredThickness() 123 | 124 | if abs(oldThickness - newThickness) > 0: 125 | invocation = NSInvocation.invocationWithMethodSignature_(self.methodSignatureForSelector_("setRuleThickness:")) 126 | invocation.setSelector_("setRuleThickness:") 127 | invocation.setTarget_(self) 128 | invocation.setArgument_atIndex_(newThickness, 2) 129 | invocation.performSelector_withObject_afterDelay_("invoke", None, 0) 130 | 131 | def requiredThickness(self): 132 | lineCount = len(self.lineIndices()) 133 | digits = int(math.log10(lineCount) + 1) 134 | 135 | sampleString = NSString.stringWithString_("8" * digits) 136 | stringSize = sampleString.sizeWithAttributes_(self.textAttributes()) 137 | return math.ceil(max([self.DEFAULT_THICKNESS, stringSize.width + self.RULER_MARGIN * 2])) 138 | 139 | def lineNumberForCharacterIndex_inText_(self, index, text): 140 | lines = self.lineIndices() 141 | 142 | left = 0 143 | right = len(lines) 144 | 145 | while (right - left) > 1: 146 | mid = (right + left) // 2 147 | lineStart = lines[mid] 148 | 149 | if index < lineStart: 150 | right = mid 151 | elif index > lineStart: 152 | left = mid 153 | else: 154 | return mid 155 | 156 | return left 157 | 158 | def drawHashMarksAndLabelsInRect_(self, rect): 159 | bounds = self.bounds() 160 | view = self.clientView() 161 | 162 | rulerBackgroundColor = self.rulerBackgroundColor() 163 | if rulerBackgroundColor is not None: 164 | rulerBackgroundColor.set() 165 | NSRectFill(bounds) 166 | 167 | if not isinstance(view, NSTextView): 168 | return 169 | 170 | layoutManager = view.layoutManager() 171 | container = view.textContainer() 172 | text = view.string() 173 | nullRange = NSMakeRange(NSNotFound, 0) 174 | yinset = view.textContainerInset().height 175 | visibleRect = self.scrollView().contentView().bounds() 176 | textAttributes = self.textAttributes() 177 | 178 | lines = self.lineIndices() 179 | 180 | glyphRange = layoutManager.glyphRangeForBoundingRect_inTextContainer_(visibleRect, container) 181 | _range = layoutManager.characterRangeForGlyphRange_actualGlyphRange_(glyphRange, None)[0] 182 | _range.length += 1 183 | 184 | count = len(lines) 185 | index = 0 186 | 187 | lineNumber = self.lineNumberForCharacterIndex_inText_(_range.location, text) 188 | 189 | for line in range(lineNumber, count): 190 | index = lines[line] 191 | if NSLocationInRange(index, _range): 192 | rects, rectCount = layoutManager.rectArrayForCharacterRange_withinSelectedCharacterRange_inTextContainer_rectCount_( 193 | NSMakeRange(index, 0), 194 | nullRange, 195 | container, 196 | None 197 | ) 198 | if rectCount > 0: 199 | ypos = yinset + NSMinY(rects[0]) - NSMinY(visibleRect) 200 | labelText = NSString.stringWithString_("%s" % (line + 1)) 201 | stringSize = labelText.sizeWithAttributes_(textAttributes) 202 | 203 | x = NSWidth(bounds) - stringSize.width - self.RULER_MARGIN 204 | y = ypos + (NSHeight(rects[0]) - stringSize.height) / 2.0 205 | w = NSWidth(bounds) - self.RULER_MARGIN * 2.0 206 | h = NSHeight(rects[0]) 207 | 208 | labelText.drawInRect_withAttributes_(NSMakeRect(x, y, w, h), textAttributes) 209 | 210 | if index > NSMaxRange(_range): 211 | break 212 | 213 | path = NSBezierPath.bezierPath() 214 | path.moveToPoint_((bounds.origin.x + bounds.size.width, bounds.origin.y)) 215 | path.lineToPoint_((bounds.origin.x + bounds.size.width, bounds.origin.y + bounds.size.height)) 216 | NSColor.grayColor().set() 217 | path.stroke() 218 | ''' -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/drawBot/ui/splitView.py: -------------------------------------------------------------------------------- 1 | from AppKit import NSSplitView, NSColor, NSBezierPath, \ 2 | NSSplitViewDividerStyleThick, NSSplitViewDividerStyleThin 3 | from objc import super 4 | 5 | from vanilla import * 6 | from vanilla.vanillaBase import VanillaBaseObject 7 | 8 | 9 | class SimpleNSSplitView(NSSplitView): 10 | 11 | def init(self): 12 | self = super(SimpleNSSplitView, self).init() 13 | self.__dividerThickness = 8 14 | self.__collapsableSubviews = [] 15 | return self 16 | 17 | def dealloc(self): 18 | del self.__collapsableSubviews 19 | super(SimpleNSSplitView, self).dealloc() 20 | 21 | def setDividerThickness_(self, value): 22 | self.__dividerThickness = value 23 | 24 | def dividerThickness(self): 25 | return self.__dividerThickness 26 | 27 | def setCollapsableSubviews_(self, subviews): 28 | self.__collapsableSubviews = subviews 29 | 30 | def addCollapsableSubview_(self, subview): 31 | self.__collapsableSubviews.append(subview) 32 | 33 | def collapsableSubViews(self): 34 | return self.__collapsableSubviews 35 | 36 | # draw divider 37 | 38 | def drawDividerInRect_(self, rect): 39 | if self.dividerThickness() > 2: 40 | super(SimpleNSSplitView, self).drawDividerInRect_(rect) 41 | else: 42 | NSColor.colorWithCalibratedWhite_alpha_(0, .42).set() 43 | NSBezierPath.bezierPathWithRect_(rect).fill() 44 | 45 | # delegate 46 | 47 | def splitView_canCollapseSubview_(self, splitView, subview): 48 | return subview in splitView.collapsableSubViews() 49 | 50 | def splitView_shouldCollapseSubview_forDoubleClickOnDividerAtIndex_(self, splitView, subview, dividerIndex): 51 | return True 52 | 53 | 54 | class SplitView(VanillaBaseObject): 55 | 56 | nsSplitView = SimpleNSSplitView 57 | 58 | dividerStyleDict = dict(thick=NSSplitViewDividerStyleThick, thin=NSSplitViewDividerStyleThin) 59 | 60 | def __init__(self, posSize, 61 | paneDescriptions=list(), 62 | isVertical=True, 63 | dividerStyle="thick", 64 | dividerThickness=8, 65 | autoSaveName=None): 66 | 67 | self._setupView(self.nsSplitView, posSize) 68 | self._nsObject.setVertical_(isVertical) 69 | self._nsObject.setDividerStyle_(self.dividerStyleDict.get(dividerStyle, "thick")) 70 | self._nsObject.setDividerThickness_(dividerThickness) 71 | 72 | self._nsObject.setDelegate_(self._nsObject) 73 | 74 | if autoSaveName is not None: 75 | self._nsObject.setAutosaveName_(autoSaveName) 76 | 77 | self._paneIndentifiers = dict() 78 | for index, paneDescription in enumerate(paneDescriptions): 79 | vanillaView = paneDescription.get("view") 80 | view = vanillaView._nsObject 81 | self._paneIndentifiers[paneDescription["identifier"]] = view 82 | self._nsObject.addSubview_(view) 83 | 84 | if paneDescription.get("canCollapse", True): 85 | self._nsObject.addCollapsableSubview_(view) 86 | 87 | def getNSSplitView(self): 88 | return self._nsObject 89 | 90 | def setDividerPosition(self, index, position): 91 | self._nsObject.setPosition_ofDividerAtIndex_(position, index) 92 | 93 | def isPaneVisible(self, identifier): 94 | view = self._paneIndentifiers[identifier] 95 | (x, y), (w, h) = view.frame() 96 | if w == 0 or h == 0: 97 | if self._nsObject.isVertical(): 98 | return w != 0 99 | return h != 0 100 | return not self._nsObject.isSubviewCollapsed_(view) 101 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/externalTools/ffmpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schriftgestalt/DrawBotGlyphsPlugin/ed0f9f104be6d76d2be06d1bf933181782597492/DrawBot.glyphsPlugin/Contents/Resources/externalTools/ffmpeg -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/externalTools/gifsicle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schriftgestalt/DrawBotGlyphsPlugin/ed0f9f104be6d76d2be06d1bf933181782597492/DrawBot.glyphsPlugin/Contents/Resources/externalTools/gifsicle -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/externalTools/mkbitmap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schriftgestalt/DrawBotGlyphsPlugin/ed0f9f104be6d76d2be06d1bf933181782597492/DrawBot.glyphsPlugin/Contents/Resources/externalTools/mkbitmap -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/externalTools/potrace: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schriftgestalt/DrawBotGlyphsPlugin/ed0f9f104be6d76d2be06d1bf933181782597492/DrawBot.glyphsPlugin/Contents/Resources/externalTools/potrace -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/lib/python2.7/config: -------------------------------------------------------------------------------- 1 | /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Pygments 4 | ~~~~~~~~ 5 | 6 | Pygments is a syntax highlighting package written in Python. 7 | 8 | It is a generic syntax highlighter for general use in all kinds of software 9 | such as forum systems, wikis or other applications that need to prettify 10 | source code. Highlights are: 11 | 12 | * a wide range of common languages and markup formats is supported 13 | * special attention is paid to details, increasing quality by a fair amount 14 | * support for new languages and formats are added easily 15 | * a number of output formats, presently HTML, LaTeX, RTF, SVG, all image 16 | formats that PIL supports, and ANSI sequences 17 | * it is usable as a command-line tool and as a library 18 | * ... and it highlights even Brainfuck! 19 | 20 | The `Pygments tip`_ is installable with ``easy_install Pygments==dev``. 21 | 22 | .. _Pygments tip: 23 | http://bitbucket.org/birkenfeld/pygments-main/get/tip.zip#egg=Pygments-dev 24 | 25 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 26 | :license: BSD, see LICENSE for details. 27 | """ 28 | 29 | __version__ = '2.0.2' 30 | __docformat__ = 'restructuredtext' 31 | 32 | __all__ = ['lex', 'format', 'highlight'] 33 | 34 | 35 | import sys 36 | 37 | from pygments.util import StringIO, BytesIO 38 | 39 | 40 | def lex(code, lexer): 41 | """ 42 | Lex ``code`` with ``lexer`` and return an iterable of tokens. 43 | """ 44 | try: 45 | return lexer.get_tokens(code) 46 | except TypeError as err: 47 | if isinstance(err.args[0], str) and \ 48 | ('unbound method get_tokens' in err.args[0] or 49 | 'missing 1 required positional argument' in err.args[0]): 50 | raise TypeError('lex() argument must be a lexer instance, ' 51 | 'not a class') 52 | raise 53 | 54 | 55 | def format(tokens, formatter, outfile=None): 56 | """ 57 | Format a tokenlist ``tokens`` with the formatter ``formatter``. 58 | 59 | If ``outfile`` is given and a valid file object (an object 60 | with a ``write`` method), the result will be written to it, otherwise 61 | it is returned as a string. 62 | """ 63 | try: 64 | if not outfile: 65 | realoutfile = getattr(formatter, 'encoding', None) and BytesIO() or StringIO() 66 | formatter.format(tokens, realoutfile) 67 | return realoutfile.getvalue() 68 | else: 69 | formatter.format(tokens, outfile) 70 | except TypeError as err: 71 | if isinstance(err.args[0], str) and \ 72 | ('unbound method format' in err.args[0] or 73 | 'missing 1 required positional argument' in err.args[0]): 74 | raise TypeError('format() argument must be a formatter instance, ' 75 | 'not a class') 76 | raise 77 | 78 | 79 | def highlight(code, lexer, formatter, outfile=None): 80 | """ 81 | Lex ``code`` with ``lexer`` and format it with the formatter ``formatter``. 82 | 83 | If ``outfile`` is given and a valid file object (an object 84 | with a ``write`` method), the result will be written to it, otherwise 85 | it is returned as a string. 86 | """ 87 | return format(lex(code, lexer), formatter, outfile) 88 | 89 | 90 | if __name__ == '__main__': # pragma: no cover 91 | from pygments.cmdline import main 92 | sys.exit(main(sys.argv)) 93 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/console.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.console 4 | ~~~~~~~~~~~~~~~~ 5 | 6 | Format colored console output. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | esc = "\x1b[" 13 | 14 | codes = {} 15 | codes[""] = "" 16 | codes["reset"] = esc + "39;49;00m" 17 | 18 | codes["bold"] = esc + "01m" 19 | codes["faint"] = esc + "02m" 20 | codes["standout"] = esc + "03m" 21 | codes["underline"] = esc + "04m" 22 | codes["blink"] = esc + "05m" 23 | codes["overline"] = esc + "06m" 24 | 25 | dark_colors = ["black", "darkred", "darkgreen", "brown", "darkblue", 26 | "purple", "teal", "lightgray"] 27 | light_colors = ["darkgray", "red", "green", "yellow", "blue", 28 | "fuchsia", "turquoise", "white"] 29 | 30 | x = 30 31 | for d, l in zip(dark_colors, light_colors): 32 | codes[d] = esc + "%im" % x 33 | codes[l] = esc + "%i;01m" % x 34 | x += 1 35 | 36 | del d, l, x 37 | 38 | codes["darkteal"] = codes["turquoise"] 39 | codes["darkyellow"] = codes["brown"] 40 | codes["fuscia"] = codes["fuchsia"] 41 | codes["white"] = codes["bold"] 42 | 43 | 44 | def reset_color(): 45 | return codes["reset"] 46 | 47 | 48 | def colorize(color_key, text): 49 | return codes[color_key] + text + codes["reset"] 50 | 51 | 52 | def ansiformat(attr, text): 53 | """ 54 | Format ``text`` with a color and/or some attributes:: 55 | 56 | color normal color 57 | *color* bold color 58 | _color_ underlined color 59 | +color+ blinking color 60 | """ 61 | result = [] 62 | if attr[:1] == attr[-1:] == '+': 63 | result.append(codes['blink']) 64 | attr = attr[1:-1] 65 | if attr[:1] == attr[-1:] == '*': 66 | result.append(codes['bold']) 67 | attr = attr[1:-1] 68 | if attr[:1] == attr[-1:] == '_': 69 | result.append(codes['underline']) 70 | attr = attr[1:-1] 71 | result.append(codes[attr]) 72 | result.append(text) 73 | result.append(codes['reset']) 74 | return ''.join(result) 75 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/filter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.filter 4 | ~~~~~~~~~~~~~~~ 5 | 6 | Module that implements the default filter. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | 13 | def apply_filters(stream, filters, lexer=None): 14 | """ 15 | Use this method to apply an iterable of filters to 16 | a stream. If lexer is given it's forwarded to the 17 | filter, otherwise the filter receives `None`. 18 | """ 19 | def _apply(filter_, stream): 20 | for token in filter_.filter(lexer, stream): 21 | yield token 22 | for filter_ in filters: 23 | stream = _apply(filter_, stream) 24 | return stream 25 | 26 | 27 | def simplefilter(f): 28 | """ 29 | Decorator that converts a function into a filter:: 30 | 31 | @simplefilter 32 | def lowercase(lexer, stream, options): 33 | for ttype, value in stream: 34 | yield ttype, value.lower() 35 | """ 36 | return type(f.__name__, (FunctionFilter,), { 37 | 'function': f, 38 | '__module__': getattr(f, '__module__'), 39 | '__doc__': f.__doc__ 40 | }) 41 | 42 | 43 | class Filter(object): 44 | """ 45 | Default filter. Subclass this class or use the `simplefilter` 46 | decorator to create own filters. 47 | """ 48 | 49 | def __init__(self, **options): 50 | self.options = options 51 | 52 | def filter(self, lexer, stream): 53 | raise NotImplementedError() 54 | 55 | 56 | class FunctionFilter(Filter): 57 | """ 58 | Abstract class used by `simplefilter` to create simple 59 | function filters on the fly. The `simplefilter` decorator 60 | automatically creates subclasses of this class for 61 | functions passed to it. 62 | """ 63 | function = None 64 | 65 | def __init__(self, **options): 66 | if not hasattr(self, 'function'): 67 | raise TypeError('%r used without bound function' % 68 | self.__class__.__name__) 69 | Filter.__init__(self, **options) 70 | 71 | def filter(self, lexer, stream): 72 | # pylint: disable-msg=E1102 73 | for ttype, value in self.function(lexer, stream, self.options): 74 | yield ttype, value 75 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/formatter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.formatter 4 | ~~~~~~~~~~~~~~~~~~ 5 | 6 | Base formatter class. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | import codecs 13 | 14 | from pygments.util import get_bool_opt, string_types 15 | from pygments.styles import get_style_by_name 16 | 17 | __all__ = ['Formatter'] 18 | 19 | 20 | def _lookup_style(style): 21 | if isinstance(style, string_types): 22 | return get_style_by_name(style) 23 | return style 24 | 25 | 26 | class Formatter(object): 27 | """ 28 | Converts a token stream to text. 29 | 30 | Options accepted: 31 | 32 | ``style`` 33 | The style to use, can be a string or a Style subclass 34 | (default: "default"). Not used by e.g. the 35 | TerminalFormatter. 36 | ``full`` 37 | Tells the formatter to output a "full" document, i.e. 38 | a complete self-contained document. This doesn't have 39 | any effect for some formatters (default: false). 40 | ``title`` 41 | If ``full`` is true, the title that should be used to 42 | caption the document (default: ''). 43 | ``encoding`` 44 | If given, must be an encoding name. This will be used to 45 | convert the Unicode token strings to byte strings in the 46 | output. If it is "" or None, Unicode strings will be written 47 | to the output file, which most file-like objects do not 48 | support (default: None). 49 | ``outencoding`` 50 | Overrides ``encoding`` if given. 51 | """ 52 | 53 | #: Name of the formatter 54 | name = None 55 | 56 | #: Shortcuts for the formatter 57 | aliases = [] 58 | 59 | #: fn match rules 60 | filenames = [] 61 | 62 | #: If True, this formatter outputs Unicode strings when no encoding 63 | #: option is given. 64 | unicodeoutput = True 65 | 66 | def __init__(self, **options): 67 | self.style = _lookup_style(options.get('style', 'default')) 68 | self.full = get_bool_opt(options, 'full', False) 69 | self.title = options.get('title', '') 70 | self.encoding = options.get('encoding', None) or None 71 | if self.encoding in ('guess', 'chardet'): 72 | # can happen for e.g. pygmentize -O encoding=guess 73 | self.encoding = 'utf-8' 74 | self.encoding = options.get('outencoding') or self.encoding 75 | self.options = options 76 | 77 | def get_style_defs(self, arg=''): 78 | """ 79 | Return the style definitions for the current style as a string. 80 | 81 | ``arg`` is an additional argument whose meaning depends on the 82 | formatter used. Note that ``arg`` can also be a list or tuple 83 | for some formatters like the html formatter. 84 | """ 85 | return '' 86 | 87 | def format(self, tokensource, outfile): 88 | """ 89 | Format ``tokensource``, an iterable of ``(tokentype, tokenstring)`` 90 | tuples and write it into ``outfile``. 91 | """ 92 | if self.encoding: 93 | # wrap the outfile in a StreamWriter 94 | outfile = codecs.lookup(self.encoding)[3](outfile) 95 | return self.format_unencoded(tokensource, outfile) 96 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/formatters/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.formatters 4 | ~~~~~~~~~~~~~~~~~~~ 5 | 6 | Pygments formatters. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | import re 13 | import sys 14 | import types 15 | import fnmatch 16 | from os.path import basename 17 | 18 | from pygments.formatters._mapping import FORMATTERS 19 | from pygments.plugin import find_plugin_formatters 20 | from pygments.util import ClassNotFound, itervalues 21 | 22 | __all__ = ['get_formatter_by_name', 'get_formatter_for_filename', 23 | 'get_all_formatters'] + list(FORMATTERS) 24 | 25 | _formatter_cache = {} # classes by name 26 | _pattern_cache = {} 27 | 28 | 29 | def _fn_matches(fn, glob): 30 | """Return whether the supplied file name fn matches pattern filename.""" 31 | if glob not in _pattern_cache: 32 | pattern = _pattern_cache[glob] = re.compile(fnmatch.translate(glob)) 33 | return pattern.match(fn) 34 | return _pattern_cache[glob].match(fn) 35 | 36 | 37 | def _load_formatters(module_name): 38 | """Load a formatter (and all others in the module too).""" 39 | mod = __import__(module_name, None, None, ['__all__']) 40 | for formatter_name in mod.__all__: 41 | cls = getattr(mod, formatter_name) 42 | _formatter_cache[cls.name] = cls 43 | 44 | 45 | def get_all_formatters(): 46 | """Return a generator for all formatter classes.""" 47 | # NB: this returns formatter classes, not info like get_all_lexers(). 48 | for info in itervalues(FORMATTERS): 49 | if info[1] not in _formatter_cache: 50 | _load_formatters(info[0]) 51 | yield _formatter_cache[info[1]] 52 | for _, formatter in find_plugin_formatters(): 53 | yield formatter 54 | 55 | 56 | def find_formatter_class(alias): 57 | """Lookup a formatter by alias. 58 | 59 | Returns None if not found. 60 | """ 61 | for module_name, name, aliases, _, _ in itervalues(FORMATTERS): 62 | if alias in aliases: 63 | if name not in _formatter_cache: 64 | _load_formatters(module_name) 65 | return _formatter_cache[name] 66 | for _, cls in find_plugin_formatters(): 67 | if alias in cls.aliases: 68 | return cls 69 | 70 | 71 | def get_formatter_by_name(_alias, **options): 72 | """Lookup and instantiate a formatter by alias. 73 | 74 | Raises ClassNotFound if not found. 75 | """ 76 | cls = find_formatter_class(_alias) 77 | if cls is None: 78 | raise ClassNotFound("no formatter found for name %r" % _alias) 79 | return cls(**options) 80 | 81 | 82 | def get_formatter_for_filename(fn, **options): 83 | """Lookup and instantiate a formatter by filename pattern. 84 | 85 | Raises ClassNotFound if not found. 86 | """ 87 | fn = basename(fn) 88 | for modname, name, _, filenames, _ in itervalues(FORMATTERS): 89 | for filename in filenames: 90 | if _fn_matches(fn, filename): 91 | if name not in _formatter_cache: 92 | _load_formatters(modname) 93 | return _formatter_cache[name](**options) 94 | for cls in find_plugin_formatters(): 95 | for filename in cls.filenames: 96 | if _fn_matches(fn, filename): 97 | return cls(**options) 98 | raise ClassNotFound("no formatter found for file name %r" % fn) 99 | 100 | 101 | class _automodule(types.ModuleType): 102 | """Automatically import formatters.""" 103 | 104 | def __getattr__(self, name): 105 | info = FORMATTERS.get(name) 106 | if info: 107 | _load_formatters(info[0]) 108 | cls = _formatter_cache[info[1]] 109 | setattr(self, name, cls) 110 | return cls 111 | raise AttributeError(name) 112 | 113 | 114 | oldmod = sys.modules[__name__] 115 | newmod = _automodule(__name__) 116 | newmod.__dict__.update(oldmod.__dict__) 117 | sys.modules[__name__] = newmod 118 | del newmod.newmod, newmod.oldmod, newmod.sys, newmod.types 119 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/formatters/_mapping.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.formatters._mapping 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Formatter mapping definitions. This file is generated by itself. Everytime 7 | you change something on a builtin formatter definition, run this script from 8 | the formatters folder to update it. 9 | 10 | Do not alter the FORMATTERS dictionary by hand. 11 | 12 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 13 | :license: BSD, see LICENSE for details. 14 | """ 15 | 16 | from __future__ import print_function 17 | 18 | FORMATTERS = { 19 | 'BBCodeFormatter': ('pygments.formatters.bbcode', 'BBCode', ('bbcode', 'bb'), (), 'Format tokens with BBcodes. These formatting codes are used by many bulletin boards, so you can highlight your sourcecode with pygments before posting it there.'), 20 | 'BmpImageFormatter': ('pygments.formatters.img', 'img_bmp', ('bmp', 'bitmap'), ('*.bmp',), 'Create a bitmap image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'), 21 | 'GifImageFormatter': ('pygments.formatters.img', 'img_gif', ('gif',), ('*.gif',), 'Create a GIF image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'), 22 | 'HtmlFormatter': ('pygments.formatters.html', 'HTML', ('html',), ('*.html', '*.htm'), "Format tokens as HTML 4 ```` tags within a ``
`` tag, wrapped in a ``
`` tag. The ``
``'s CSS class can be set by the `cssclass` option."), 23 | 'ImageFormatter': ('pygments.formatters.img', 'img', ('img', 'IMG', 'png'), ('*.png',), 'Create a PNG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'), 24 | 'JpgImageFormatter': ('pygments.formatters.img', 'img_jpg', ('jpg', 'jpeg'), ('*.jpg',), 'Create a JPEG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'), 25 | 'LatexFormatter': ('pygments.formatters.latex', 'LaTeX', ('latex', 'tex'), ('*.tex',), 'Format tokens as LaTeX code. This needs the `fancyvrb` and `color` standard packages.'), 26 | 'NullFormatter': ('pygments.formatters.other', 'Text only', ('text', 'null'), ('*.txt',), 'Output the text unchanged without any formatting.'), 27 | 'RawTokenFormatter': ('pygments.formatters.other', 'Raw tokens', ('raw', 'tokens'), ('*.raw',), 'Format tokens as a raw representation for storing token streams.'), 28 | 'RtfFormatter': ('pygments.formatters.rtf', 'RTF', ('rtf',), ('*.rtf',), 'Format tokens as RTF markup. This formatter automatically outputs full RTF documents with color information and other useful stuff. Perfect for Copy and Paste into Microsoft(R) Word(R) documents.'), 29 | 'SvgFormatter': ('pygments.formatters.svg', 'SVG', ('svg',), ('*.svg',), 'Format tokens as an SVG graphics file. This formatter is still experimental. Each line of code is a ```` element with explicit ``x`` and ``y`` coordinates containing ```` elements with the individual token styles.'), 30 | 'Terminal256Formatter': ('pygments.formatters.terminal256', 'Terminal256', ('terminal256', 'console256', '256'), (), 'Format tokens with ANSI color sequences, for output in a 256-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly.'), 31 | 'TerminalFormatter': ('pygments.formatters.terminal', 'Terminal', ('terminal', 'console'), (), 'Format tokens with ANSI color sequences, for output in a text console. Color sequences are terminated at newlines, so that paging the output works correctly.'), 32 | 'TestcaseFormatter': ('pygments.formatters.other', 'Testcase', ('testcase',), (), 'Format tokens as appropriate for a new testcase.') 33 | } 34 | 35 | 36 | if __name__ == '__main__': # pragma: no cover 37 | import sys 38 | import os 39 | 40 | # lookup formatters 41 | found_formatters = [] 42 | imports = [] 43 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) 44 | from pygments.util import docstring_headline 45 | 46 | for root, dirs, files in os.walk('.'): 47 | for filename in files: 48 | if filename.endswith('.py') and not filename.startswith('_'): 49 | module_name = 'pygments.formatters%s.%s' % ( 50 | root[1:].replace('/', '.'), filename[:-3]) 51 | print(module_name) 52 | module = __import__(module_name, None, None, ['']) 53 | for formatter_name in module.__all__: 54 | formatter = getattr(module, formatter_name) 55 | found_formatters.append( 56 | '%r: %r' % (formatter_name, 57 | (module_name, 58 | formatter.name, 59 | tuple(formatter.aliases), 60 | tuple(formatter.filenames), 61 | docstring_headline(formatter)))) 62 | # sort them to make the diff minimal 63 | found_formatters.sort() 64 | 65 | # extract useful sourcecode from this file 66 | with open(__file__) as fp: 67 | content = fp.read() 68 | header = content[:content.find('FORMATTERS = {')] 69 | footer = content[content.find("if __name__ == '__main__':"):] 70 | 71 | # write new file 72 | with open(__file__, 'w') as fp: 73 | fp.write(header) 74 | fp.write('FORMATTERS = {\n %s\n}\n\n' % ',\n '.join(found_formatters)) 75 | fp.write(footer) 76 | 77 | print ('=== %d formatters processed.' % len(found_formatters)) 78 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/formatters/bbcode.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.formatters.bbcode 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | BBcode formatter. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | 13 | from pygments.formatter import Formatter 14 | from pygments.util import get_bool_opt 15 | 16 | __all__ = ['BBCodeFormatter'] 17 | 18 | 19 | class BBCodeFormatter(Formatter): 20 | """ 21 | Format tokens with BBcodes. These formatting codes are used by many 22 | bulletin boards, so you can highlight your sourcecode with pygments before 23 | posting it there. 24 | 25 | This formatter has no support for background colors and borders, as there 26 | are no common BBcode tags for that. 27 | 28 | Some board systems (e.g. phpBB) don't support colors in their [code] tag, 29 | so you can't use the highlighting together with that tag. 30 | Text in a [code] tag usually is shown with a monospace font (which this 31 | formatter can do with the ``monofont`` option) and no spaces (which you 32 | need for indentation) are removed. 33 | 34 | Additional options accepted: 35 | 36 | `style` 37 | The style to use, can be a string or a Style subclass (default: 38 | ``'default'``). 39 | 40 | `codetag` 41 | If set to true, put the output into ``[code]`` tags (default: 42 | ``false``) 43 | 44 | `monofont` 45 | If set to true, add a tag to show the code with a monospace font 46 | (default: ``false``). 47 | """ 48 | name = 'BBCode' 49 | aliases = ['bbcode', 'bb'] 50 | filenames = [] 51 | 52 | def __init__(self, **options): 53 | Formatter.__init__(self, **options) 54 | self._code = get_bool_opt(options, 'codetag', False) 55 | self._mono = get_bool_opt(options, 'monofont', False) 56 | 57 | self.styles = {} 58 | self._make_styles() 59 | 60 | def _make_styles(self): 61 | for ttype, ndef in self.style: 62 | start = end = '' 63 | if ndef['color']: 64 | start += '[color=#%s]' % ndef['color'] 65 | end = '[/color]' + end 66 | if ndef['bold']: 67 | start += '[b]' 68 | end = '[/b]' + end 69 | if ndef['italic']: 70 | start += '[i]' 71 | end = '[/i]' + end 72 | if ndef['underline']: 73 | start += '[u]' 74 | end = '[/u]' + end 75 | # there are no common BBcodes for background-color and border 76 | 77 | self.styles[ttype] = start, end 78 | 79 | def format_unencoded(self, tokensource, outfile): 80 | if self._code: 81 | outfile.write('[code]') 82 | if self._mono: 83 | outfile.write('[font=monospace]') 84 | 85 | lastval = '' 86 | lasttype = None 87 | 88 | for ttype, value in tokensource: 89 | while ttype not in self.styles: 90 | ttype = ttype.parent 91 | if ttype == lasttype: 92 | lastval += value 93 | else: 94 | if lastval: 95 | start, end = self.styles[lasttype] 96 | outfile.write(''.join((start, lastval, end))) 97 | lastval = value 98 | lasttype = ttype 99 | 100 | if lastval: 101 | start, end = self.styles[lasttype] 102 | outfile.write(''.join((start, lastval, end))) 103 | 104 | if self._mono: 105 | outfile.write('[/font]') 106 | if self._code: 107 | outfile.write('[/code]') 108 | if self._code or self._mono: 109 | outfile.write('\n') 110 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/formatters/other.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.formatters.other 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Other formatters: NullFormatter, RawTokenFormatter. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.formatter import Formatter 13 | from pygments.util import OptionError, get_choice_opt 14 | from pygments.token import Token 15 | from pygments.console import colorize 16 | 17 | __all__ = ['NullFormatter', 'RawTokenFormatter', 'TestcaseFormatter'] 18 | 19 | 20 | class NullFormatter(Formatter): 21 | """ 22 | Output the text unchanged without any formatting. 23 | """ 24 | name = 'Text only' 25 | aliases = ['text', 'null'] 26 | filenames = ['*.txt'] 27 | 28 | def format(self, tokensource, outfile): 29 | enc = self.encoding 30 | for ttype, value in tokensource: 31 | if enc: 32 | outfile.write(value.encode(enc)) 33 | else: 34 | outfile.write(value) 35 | 36 | 37 | class RawTokenFormatter(Formatter): 38 | r""" 39 | Format tokens as a raw representation for storing token streams. 40 | 41 | The format is ``tokentyperepr(tokenstring)\n``. The output can later 42 | be converted to a token stream with the `RawTokenLexer`, described in the 43 | :doc:`lexer list `. 44 | 45 | Only two options are accepted: 46 | 47 | `compress` 48 | If set to ``'gz'`` or ``'bz2'``, compress the output with the given 49 | compression algorithm after encoding (default: ``''``). 50 | `error_color` 51 | If set to a color name, highlight error tokens using that color. If 52 | set but with no value, defaults to ``'red'``. 53 | 54 | .. versionadded:: 0.11 55 | 56 | """ 57 | name = 'Raw tokens' 58 | aliases = ['raw', 'tokens'] 59 | filenames = ['*.raw'] 60 | 61 | unicodeoutput = False 62 | 63 | def __init__(self, **options): 64 | Formatter.__init__(self, **options) 65 | # We ignore self.encoding if it is set, since it gets set for lexer 66 | # and formatter if given with -Oencoding on the command line. 67 | # The RawTokenFormatter outputs only ASCII. Override here. 68 | self.encoding = 'ascii' # let pygments.format() do the right thing 69 | self.compress = get_choice_opt(options, 'compress', 70 | ['', 'none', 'gz', 'bz2'], '') 71 | self.error_color = options.get('error_color', None) 72 | if self.error_color is True: 73 | self.error_color = 'red' 74 | if self.error_color is not None: 75 | try: 76 | colorize(self.error_color, '') 77 | except KeyError: 78 | raise ValueError("Invalid color %r specified" % 79 | self.error_color) 80 | 81 | def format(self, tokensource, outfile): 82 | try: 83 | outfile.write(b'') 84 | except TypeError: 85 | raise TypeError('The raw tokens formatter needs a binary ' 86 | 'output file') 87 | if self.compress == 'gz': 88 | import gzip 89 | outfile = gzip.GzipFile('', 'wb', 9, outfile) 90 | def write(text): 91 | outfile.write(text.encode()) 92 | flush = outfile.flush 93 | elif self.compress == 'bz2': 94 | import bz2 95 | compressor = bz2.BZ2Compressor(9) 96 | def write(text): 97 | outfile.write(compressor.compress(text.encode())) 98 | def flush(): 99 | outfile.write(compressor.flush()) 100 | outfile.flush() 101 | else: 102 | def write(text): 103 | outfile.write(text.encode()) 104 | flush = outfile.flush 105 | 106 | if self.error_color: 107 | for ttype, value in tokensource: 108 | line = "%s\t%r\n" % (ttype, value) 109 | if ttype is Token.Error: 110 | write(colorize(self.error_color, line)) 111 | else: 112 | write(line) 113 | else: 114 | for ttype, value in tokensource: 115 | write("%s\t%r\n" % (ttype, value)) 116 | flush() 117 | 118 | TESTCASE_BEFORE = u'''\ 119 | def testNeedsName(self): 120 | fragment = %r 121 | tokens = [ 122 | ''' 123 | TESTCASE_AFTER = u'''\ 124 | ] 125 | self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) 126 | ''' 127 | 128 | 129 | class TestcaseFormatter(Formatter): 130 | """ 131 | Format tokens as appropriate for a new testcase. 132 | 133 | .. versionadded:: 2.0 134 | """ 135 | name = 'Testcase' 136 | aliases = ['testcase'] 137 | 138 | def __init__(self, **options): 139 | Formatter.__init__(self, **options) 140 | if self.encoding is not None and self.encoding != 'utf-8': 141 | raise ValueError("Only None and utf-8 are allowed encodings.") 142 | 143 | def format(self, tokensource, outfile): 144 | indentation = ' ' * 12 145 | rawbuf = [] 146 | outbuf = [] 147 | for ttype, value in tokensource: 148 | rawbuf.append(value) 149 | outbuf.append('%s(%s, %r),\n' % (indentation, ttype, value)) 150 | 151 | before = TESTCASE_BEFORE % (u''.join(rawbuf),) 152 | during = u''.join(outbuf) 153 | after = TESTCASE_AFTER 154 | if self.encoding is None: 155 | outfile.write(before + during + after) 156 | else: 157 | outfile.write(before.encode('utf-8')) 158 | outfile.write(during.encode('utf-8')) 159 | outfile.write(after.encode('utf-8')) 160 | outfile.flush() 161 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/formatters/rtf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.formatters.rtf 4 | ~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | A formatter that generates RTF files. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.formatter import Formatter 13 | from pygments.util import get_int_opt, _surrogatepair 14 | 15 | 16 | __all__ = ['RtfFormatter'] 17 | 18 | 19 | class RtfFormatter(Formatter): 20 | """ 21 | Format tokens as RTF markup. This formatter automatically outputs full RTF 22 | documents with color information and other useful stuff. Perfect for Copy and 23 | Paste into Microsoft(R) Word(R) documents. 24 | 25 | Please note that ``encoding`` and ``outencoding`` options are ignored. 26 | The RTF format is ASCII natively, but handles unicode characters correctly 27 | thanks to escape sequences. 28 | 29 | .. versionadded:: 0.6 30 | 31 | Additional options accepted: 32 | 33 | `style` 34 | The style to use, can be a string or a Style subclass (default: 35 | ``'default'``). 36 | 37 | `fontface` 38 | The used font famliy, for example ``Bitstream Vera Sans``. Defaults to 39 | some generic font which is supposed to have fixed width. 40 | 41 | `fontsize` 42 | Size of the font used. Size is specified in half points. The 43 | default is 24 half-points, giving a size 12 font. 44 | 45 | .. versionadded:: 2.0 46 | """ 47 | name = 'RTF' 48 | aliases = ['rtf'] 49 | filenames = ['*.rtf'] 50 | 51 | def __init__(self, **options): 52 | r""" 53 | Additional options accepted: 54 | 55 | ``fontface`` 56 | Name of the font used. Could for example be ``'Courier New'`` 57 | to further specify the default which is ``'\fmodern'``. The RTF 58 | specification claims that ``\fmodern`` are "Fixed-pitch serif 59 | and sans serif fonts". Hope every RTF implementation thinks 60 | the same about modern... 61 | 62 | """ 63 | Formatter.__init__(self, **options) 64 | self.fontface = options.get('fontface') or '' 65 | self.fontsize = get_int_opt(options, 'fontsize', 0) 66 | 67 | def _escape(self, text): 68 | return text.replace(u'\\', u'\\\\') \ 69 | .replace(u'{', u'\\{') \ 70 | .replace(u'}', u'\\}') 71 | 72 | def _escape_text(self, text): 73 | # empty strings, should give a small performance improvment 74 | if not text: 75 | return u'' 76 | 77 | # escape text 78 | text = self._escape(text) 79 | 80 | buf = [] 81 | for c in text: 82 | cn = ord(c) 83 | if cn < (2**7): 84 | # ASCII character 85 | buf.append(str(c)) 86 | elif (2**7) <= cn < (2**16): 87 | # single unicode escape sequence 88 | buf.append(u'{\\u%d}' % cn) 89 | elif (2**16) <= cn: 90 | # RTF limits unicode to 16 bits. 91 | # Force surrogate pairs 92 | buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn)) 93 | 94 | return u''.join(buf).replace(u'\n', u'\\par\n') 95 | 96 | def format_unencoded(self, tokensource, outfile): 97 | # rtf 1.8 header 98 | outfile.write(u'{\\rtf1\\ansi\\uc0\\deff0' 99 | u'{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0%s;}}' 100 | u'{\\colortbl;' % (self.fontface and 101 | u' ' + self._escape(self.fontface) or 102 | u'')) 103 | 104 | # convert colors and save them in a mapping to access them later. 105 | color_mapping = {} 106 | offset = 1 107 | for _, style in self.style: 108 | for color in style['color'], style['bgcolor'], style['border']: 109 | if color and color not in color_mapping: 110 | color_mapping[color] = offset 111 | outfile.write(u'\\red%d\\green%d\\blue%d;' % ( 112 | int(color[0:2], 16), 113 | int(color[2:4], 16), 114 | int(color[4:6], 16) 115 | )) 116 | offset += 1 117 | outfile.write(u'}\\f0 ') 118 | if self.fontsize: 119 | outfile.write(u'\\fs%d' % (self.fontsize)) 120 | 121 | # highlight stream 122 | for ttype, value in tokensource: 123 | while not self.style.styles_token(ttype) and ttype.parent: 124 | ttype = ttype.parent 125 | style = self.style.style_for_token(ttype) 126 | buf = [] 127 | if style['bgcolor']: 128 | buf.append(u'\\cb%d' % color_mapping[style['bgcolor']]) 129 | if style['color']: 130 | buf.append(u'\\cf%d' % color_mapping[style['color']]) 131 | if style['bold']: 132 | buf.append(u'\\b') 133 | if style['italic']: 134 | buf.append(u'\\i') 135 | if style['underline']: 136 | buf.append(u'\\ul') 137 | if style['border']: 138 | buf.append(u'\\chbrdr\\chcfpat%d' % 139 | color_mapping[style['border']]) 140 | start = u''.join(buf) 141 | if start: 142 | outfile.write(u'{%s ' % start) 143 | outfile.write(self._escape_text(value)) 144 | if start: 145 | outfile.write(u'}') 146 | 147 | outfile.write(u'}') 148 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/formatters/svg.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.formatters.svg 4 | ~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Formatter for SVG output. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.formatter import Formatter 13 | from pygments.util import get_bool_opt, get_int_opt 14 | 15 | __all__ = ['SvgFormatter'] 16 | 17 | 18 | def escape_html(text): 19 | """Escape &, <, > as well as single and double quotes for HTML.""" 20 | return text.replace('&', '&'). \ 21 | replace('<', '<'). \ 22 | replace('>', '>'). \ 23 | replace('"', '"'). \ 24 | replace("'", ''') 25 | 26 | 27 | class2style = {} 28 | 29 | class SvgFormatter(Formatter): 30 | """ 31 | Format tokens as an SVG graphics file. This formatter is still experimental. 32 | Each line of code is a ```` element with explicit ``x`` and ``y`` 33 | coordinates containing ```` elements with the individual token styles. 34 | 35 | By default, this formatter outputs a full SVG document including doctype 36 | declaration and the ```` root element. 37 | 38 | .. versionadded:: 0.9 39 | 40 | Additional options accepted: 41 | 42 | `nowrap` 43 | Don't wrap the SVG ```` elements in ```` elements and 44 | don't add a XML declaration and a doctype. If true, the `fontfamily` 45 | and `fontsize` options are ignored. Defaults to ``False``. 46 | 47 | `fontfamily` 48 | The value to give the wrapping ```` element's ``font-family`` 49 | attribute, defaults to ``"monospace"``. 50 | 51 | `fontsize` 52 | The value to give the wrapping ```` element's ``font-size`` 53 | attribute, defaults to ``"14px"``. 54 | 55 | `xoffset` 56 | Starting offset in X direction, defaults to ``0``. 57 | 58 | `yoffset` 59 | Starting offset in Y direction, defaults to the font size if it is given 60 | in pixels, or ``20`` else. (This is necessary since text coordinates 61 | refer to the text baseline, not the top edge.) 62 | 63 | `ystep` 64 | Offset to add to the Y coordinate for each subsequent line. This should 65 | roughly be the text size plus 5. It defaults to that value if the text 66 | size is given in pixels, or ``25`` else. 67 | 68 | `spacehack` 69 | Convert spaces in the source to `` ``, which are non-breaking 70 | spaces. SVG provides the ``xml:space`` attribute to control how 71 | whitespace inside tags is handled, in theory, the ``preserve`` value 72 | could be used to keep all whitespace as-is. However, many current SVG 73 | viewers don't obey that rule, so this option is provided as a workaround 74 | and defaults to ``True``. 75 | """ 76 | name = 'SVG' 77 | aliases = ['svg'] 78 | filenames = ['*.svg'] 79 | 80 | def __init__(self, **options): 81 | Formatter.__init__(self, **options) 82 | self.nowrap = get_bool_opt(options, 'nowrap', False) 83 | self.fontfamily = options.get('fontfamily', 'monospace') 84 | self.fontsize = options.get('fontsize', '14px') 85 | self.xoffset = get_int_opt(options, 'xoffset', 0) 86 | fs = self.fontsize.strip() 87 | if fs.endswith('px'): fs = fs[:-2].strip() 88 | try: 89 | int_fs = int(fs) 90 | except: 91 | int_fs = 20 92 | self.yoffset = get_int_opt(options, 'yoffset', int_fs) 93 | self.ystep = get_int_opt(options, 'ystep', int_fs + 5) 94 | self.spacehack = get_bool_opt(options, 'spacehack', True) 95 | self._stylecache = {} 96 | 97 | def format_unencoded(self, tokensource, outfile): 98 | """ 99 | Format ``tokensource``, an iterable of ``(tokentype, tokenstring)`` 100 | tuples and write it into ``outfile``. 101 | 102 | For our implementation we put all lines in their own 'line group'. 103 | """ 104 | x = self.xoffset 105 | y = self.yoffset 106 | if not self.nowrap: 107 | if self.encoding: 108 | outfile.write('\n' % 109 | self.encoding) 110 | else: 111 | outfile.write('\n') 112 | outfile.write('\n') 115 | outfile.write('\n') 116 | outfile.write('\n' % 117 | (self.fontfamily, self.fontsize)) 118 | outfile.write('' % (x, y)) 119 | for ttype, value in tokensource: 120 | style = self._get_style(ttype) 121 | tspan = style and '' or '' 122 | tspanend = tspan and '' or '' 123 | value = escape_html(value) 124 | if self.spacehack: 125 | value = value.expandtabs().replace(' ', ' ') 126 | parts = value.split('\n') 127 | for part in parts[:-1]: 128 | outfile.write(tspan + part + tspanend) 129 | y += self.ystep 130 | outfile.write('\n' % (x, y)) 132 | outfile.write(tspan + parts[-1] + tspanend) 133 | outfile.write('') 134 | 135 | if not self.nowrap: 136 | outfile.write('\n') 137 | 138 | def _get_style(self, tokentype): 139 | if tokentype in self._stylecache: 140 | return self._stylecache[tokentype] 141 | otokentype = tokentype 142 | while not self.style.styles_token(tokentype): 143 | tokentype = tokentype.parent 144 | value = self.style.style_for_token(tokentype) 145 | result = '' 146 | if value['color']: 147 | result = ' fill="#' + value['color'] + '"' 148 | if value['bold']: 149 | result += ' font-weight="bold"' 150 | if value['italic']: 151 | result += ' font-style="italic"' 152 | self._stylecache[otokentype] = result 153 | return result 154 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/formatters/terminal.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.formatters.terminal 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Formatter for terminal output with ANSI sequences. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | import sys 13 | 14 | from pygments.formatter import Formatter 15 | from pygments.token import Keyword, Name, Comment, String, Error, \ 16 | Number, Operator, Generic, Token, Whitespace 17 | from pygments.console import ansiformat 18 | from pygments.util import get_choice_opt 19 | 20 | 21 | __all__ = ['TerminalFormatter'] 22 | 23 | 24 | #: Map token types to a tuple of color values for light and dark 25 | #: backgrounds. 26 | TERMINAL_COLORS = { 27 | Token: ('', ''), 28 | 29 | Whitespace: ('lightgray', 'darkgray'), 30 | Comment: ('lightgray', 'darkgray'), 31 | Comment.Preproc: ('teal', 'turquoise'), 32 | Keyword: ('darkblue', 'blue'), 33 | Keyword.Type: ('teal', 'turquoise'), 34 | Operator.Word: ('purple', 'fuchsia'), 35 | Name.Builtin: ('teal', 'turquoise'), 36 | Name.Function: ('darkgreen', 'green'), 37 | Name.Namespace: ('_teal_', '_turquoise_'), 38 | Name.Class: ('_darkgreen_', '_green_'), 39 | Name.Exception: ('teal', 'turquoise'), 40 | Name.Decorator: ('darkgray', 'lightgray'), 41 | Name.Variable: ('darkred', 'red'), 42 | Name.Constant: ('darkred', 'red'), 43 | Name.Attribute: ('teal', 'turquoise'), 44 | Name.Tag: ('blue', 'blue'), 45 | String: ('brown', 'brown'), 46 | Number: ('darkblue', 'blue'), 47 | 48 | Generic.Deleted: ('red', 'red'), 49 | Generic.Inserted: ('darkgreen', 'green'), 50 | Generic.Heading: ('**', '**'), 51 | Generic.Subheading: ('*purple*', '*fuchsia*'), 52 | Generic.Error: ('red', 'red'), 53 | 54 | Error: ('_red_', '_red_'), 55 | } 56 | 57 | 58 | class TerminalFormatter(Formatter): 59 | r""" 60 | Format tokens with ANSI color sequences, for output in a text console. 61 | Color sequences are terminated at newlines, so that paging the output 62 | works correctly. 63 | 64 | The `get_style_defs()` method doesn't do anything special since there is 65 | no support for common styles. 66 | 67 | Options accepted: 68 | 69 | `bg` 70 | Set to ``"light"`` or ``"dark"`` depending on the terminal's background 71 | (default: ``"light"``). 72 | 73 | `colorscheme` 74 | A dictionary mapping token types to (lightbg, darkbg) color names or 75 | ``None`` (default: ``None`` = use builtin colorscheme). 76 | 77 | `linenos` 78 | Set to ``True`` to have line numbers on the terminal output as well 79 | (default: ``False`` = no line numbers). 80 | """ 81 | name = 'Terminal' 82 | aliases = ['terminal', 'console'] 83 | filenames = [] 84 | 85 | def __init__(self, **options): 86 | Formatter.__init__(self, **options) 87 | self.darkbg = get_choice_opt(options, 'bg', 88 | ['light', 'dark'], 'light') == 'dark' 89 | self.colorscheme = options.get('colorscheme', None) or TERMINAL_COLORS 90 | self.linenos = options.get('linenos', False) 91 | self._lineno = 0 92 | 93 | def format(self, tokensource, outfile): 94 | # hack: if the output is a terminal and has an encoding set, 95 | # use that to avoid unicode encode problems 96 | if not self.encoding and hasattr(outfile, "encoding") and \ 97 | hasattr(outfile, "isatty") and outfile.isatty() and \ 98 | sys.version_info < (3,): 99 | self.encoding = outfile.encoding 100 | return Formatter.format(self, tokensource, outfile) 101 | 102 | def _write_lineno(self, outfile): 103 | self._lineno += 1 104 | outfile.write("\n%04d: " % self._lineno) 105 | 106 | def _format_unencoded_with_lineno(self, tokensource, outfile): 107 | self._write_lineno(outfile) 108 | 109 | for ttype, value in tokensource: 110 | if value.endswith("\n"): 111 | self._write_lineno(outfile) 112 | value = value[:-1] 113 | color = self.colorscheme.get(ttype) 114 | while color is None: 115 | ttype = ttype[:-1] 116 | color = self.colorscheme.get(ttype) 117 | if color: 118 | color = color[self.darkbg] 119 | spl = value.split('\n') 120 | for line in spl[:-1]: 121 | self._write_lineno(outfile) 122 | if line: 123 | outfile.write(ansiformat(color, line[:-1])) 124 | if spl[-1]: 125 | outfile.write(ansiformat(color, spl[-1])) 126 | else: 127 | outfile.write(value) 128 | 129 | outfile.write("\n") 130 | 131 | def format_unencoded(self, tokensource, outfile): 132 | if self.linenos: 133 | self._format_unencoded_with_lineno(tokensource, outfile) 134 | return 135 | 136 | for ttype, value in tokensource: 137 | color = self.colorscheme.get(ttype) 138 | while color is None: 139 | ttype = ttype[:-1] 140 | color = self.colorscheme.get(ttype) 141 | if color: 142 | color = color[self.darkbg] 143 | spl = value.split('\n') 144 | for line in spl[:-1]: 145 | if line: 146 | outfile.write(ansiformat(color, line)) 147 | outfile.write('\n') 148 | if spl[-1]: 149 | outfile.write(ansiformat(color, spl[-1])) 150 | else: 151 | outfile.write(value) 152 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/formatters/terminal256.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.formatters.terminal256 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Formatter for 256-color terminal output with ANSI sequences. 7 | 8 | RGB-to-XTERM color conversion routines adapted from xterm256-conv 9 | tool (http://frexx.de/xterm-256-notes/data/xterm256-conv2.tar.bz2) 10 | by Wolfgang Frisch. 11 | 12 | Formatter version 1. 13 | 14 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 15 | :license: BSD, see LICENSE for details. 16 | """ 17 | 18 | # TODO: 19 | # - Options to map style's bold/underline/italic/border attributes 20 | # to some ANSI attrbutes (something like 'italic=underline') 21 | # - An option to output "style RGB to xterm RGB/index" conversion table 22 | # - An option to indicate that we are running in "reverse background" 23 | # xterm. This means that default colors are white-on-black, not 24 | # black-on-while, so colors like "white background" need to be converted 25 | # to "white background, black foreground", etc... 26 | 27 | import sys 28 | 29 | from pygments.formatter import Formatter 30 | 31 | 32 | __all__ = ['Terminal256Formatter'] 33 | 34 | 35 | class EscapeSequence: 36 | def __init__(self, fg=None, bg=None, bold=False, underline=False): 37 | self.fg = fg 38 | self.bg = bg 39 | self.bold = bold 40 | self.underline = underline 41 | 42 | def escape(self, attrs): 43 | if len(attrs): 44 | return "\x1b[" + ";".join(attrs) + "m" 45 | return "" 46 | 47 | def color_string(self): 48 | attrs = [] 49 | if self.fg is not None: 50 | attrs.extend(("38", "5", "%i" % self.fg)) 51 | if self.bg is not None: 52 | attrs.extend(("48", "5", "%i" % self.bg)) 53 | if self.bold: 54 | attrs.append("01") 55 | if self.underline: 56 | attrs.append("04") 57 | return self.escape(attrs) 58 | 59 | def reset_string(self): 60 | attrs = [] 61 | if self.fg is not None: 62 | attrs.append("39") 63 | if self.bg is not None: 64 | attrs.append("49") 65 | if self.bold or self.underline: 66 | attrs.append("00") 67 | return self.escape(attrs) 68 | 69 | 70 | class Terminal256Formatter(Formatter): 71 | r""" 72 | Format tokens with ANSI color sequences, for output in a 256-color 73 | terminal or console. Like in `TerminalFormatter` color sequences 74 | are terminated at newlines, so that paging the output works correctly. 75 | 76 | The formatter takes colors from a style defined by the `style` option 77 | and converts them to nearest ANSI 256-color escape sequences. Bold and 78 | underline attributes from the style are preserved (and displayed). 79 | 80 | .. versionadded:: 0.9 81 | 82 | Options accepted: 83 | 84 | `style` 85 | The style to use, can be a string or a Style subclass (default: 86 | ``'default'``). 87 | """ 88 | name = 'Terminal256' 89 | aliases = ['terminal256', 'console256', '256'] 90 | filenames = [] 91 | 92 | def __init__(self, **options): 93 | Formatter.__init__(self, **options) 94 | 95 | self.xterm_colors = [] 96 | self.best_match = {} 97 | self.style_string = {} 98 | 99 | self.usebold = 'nobold' not in options 100 | self.useunderline = 'nounderline' not in options 101 | 102 | self._build_color_table() # build an RGB-to-256 color conversion table 103 | self._setup_styles() # convert selected style's colors to term. colors 104 | 105 | def _build_color_table(self): 106 | # colors 0..15: 16 basic colors 107 | 108 | self.xterm_colors.append((0x00, 0x00, 0x00)) # 0 109 | self.xterm_colors.append((0xcd, 0x00, 0x00)) # 1 110 | self.xterm_colors.append((0x00, 0xcd, 0x00)) # 2 111 | self.xterm_colors.append((0xcd, 0xcd, 0x00)) # 3 112 | self.xterm_colors.append((0x00, 0x00, 0xee)) # 4 113 | self.xterm_colors.append((0xcd, 0x00, 0xcd)) # 5 114 | self.xterm_colors.append((0x00, 0xcd, 0xcd)) # 6 115 | self.xterm_colors.append((0xe5, 0xe5, 0xe5)) # 7 116 | self.xterm_colors.append((0x7f, 0x7f, 0x7f)) # 8 117 | self.xterm_colors.append((0xff, 0x00, 0x00)) # 9 118 | self.xterm_colors.append((0x00, 0xff, 0x00)) # 10 119 | self.xterm_colors.append((0xff, 0xff, 0x00)) # 11 120 | self.xterm_colors.append((0x5c, 0x5c, 0xff)) # 12 121 | self.xterm_colors.append((0xff, 0x00, 0xff)) # 13 122 | self.xterm_colors.append((0x00, 0xff, 0xff)) # 14 123 | self.xterm_colors.append((0xff, 0xff, 0xff)) # 15 124 | 125 | # colors 16..232: the 6x6x6 color cube 126 | 127 | valuerange = (0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff) 128 | 129 | for i in range(217): 130 | r = valuerange[(i // 36) % 6] 131 | g = valuerange[(i // 6) % 6] 132 | b = valuerange[i % 6] 133 | self.xterm_colors.append((r, g, b)) 134 | 135 | # colors 233..253: grayscale 136 | 137 | for i in range(1, 22): 138 | v = 8 + i * 10 139 | self.xterm_colors.append((v, v, v)) 140 | 141 | def _closest_color(self, r, g, b): 142 | distance = 257*257*3 # "infinity" (>distance from #000000 to #ffffff) 143 | match = 0 144 | 145 | for i in range(0, 254): 146 | values = self.xterm_colors[i] 147 | 148 | rd = r - values[0] 149 | gd = g - values[1] 150 | bd = b - values[2] 151 | d = rd*rd + gd*gd + bd*bd 152 | 153 | if d < distance: 154 | match = i 155 | distance = d 156 | return match 157 | 158 | def _color_index(self, color): 159 | index = self.best_match.get(color, None) 160 | if index is None: 161 | try: 162 | rgb = int(str(color), 16) 163 | except ValueError: 164 | rgb = 0 165 | 166 | r = (rgb >> 16) & 0xff 167 | g = (rgb >> 8) & 0xff 168 | b = rgb & 0xff 169 | index = self._closest_color(r, g, b) 170 | self.best_match[color] = index 171 | return index 172 | 173 | def _setup_styles(self): 174 | for ttype, ndef in self.style: 175 | escape = EscapeSequence() 176 | if ndef['color']: 177 | escape.fg = self._color_index(ndef['color']) 178 | if ndef['bgcolor']: 179 | escape.bg = self._color_index(ndef['bgcolor']) 180 | if self.usebold and ndef['bold']: 181 | escape.bold = True 182 | if self.useunderline and ndef['underline']: 183 | escape.underline = True 184 | self.style_string[str(ttype)] = (escape.color_string(), 185 | escape.reset_string()) 186 | 187 | def format(self, tokensource, outfile): 188 | # hack: if the output is a terminal and has an encoding set, 189 | # use that to avoid unicode encode problems 190 | if not self.encoding and hasattr(outfile, "encoding") and \ 191 | hasattr(outfile, "isatty") and outfile.isatty() and \ 192 | sys.version_info < (3,): 193 | self.encoding = outfile.encoding 194 | return Formatter.format(self, tokensource, outfile) 195 | 196 | def format_unencoded(self, tokensource, outfile): 197 | for ttype, value in tokensource: 198 | not_found = True 199 | while ttype and not_found: 200 | try: 201 | # outfile.write( "<" + str(ttype) + ">" ) 202 | on, off = self.style_string[str(ttype)] 203 | 204 | # Like TerminalFormatter, add "reset colors" escape sequence 205 | # on newline. 206 | spl = value.split('\n') 207 | for line in spl[:-1]: 208 | if line: 209 | outfile.write(on + line + off) 210 | outfile.write('\n') 211 | if spl[-1]: 212 | outfile.write(on + spl[-1] + off) 213 | 214 | not_found = False 215 | # outfile.write( '#' + str(ttype) + '#' ) 216 | 217 | except KeyError: 218 | # ottype = ttype 219 | ttype = ttype[:-1] 220 | # outfile.write( '!' + str(ottype) + '->' + str(ttype) + '!' ) 221 | 222 | if not_found: 223 | outfile.write(value) 224 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/lexers/_mapping.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.lexers._mapping 4 | ~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Lexer mapping definitions. This file is generated by itself. Everytime 7 | you change something on a builtin lexer definition, run this script from 8 | the lexers folder to update it. 9 | 10 | Do not alter the LEXERS dictionary by hand. 11 | 12 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 13 | :license: BSD, see LICENSE for details. 14 | """ 15 | 16 | from __future__ import print_function 17 | 18 | LEXERS = { 19 | 'PythonLexer': ('pygments.lexers.python', 'Python', ('python', 'py', 'sage'), ('*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac', '*.sage'), ('text/x-python', 'application/x-python')), 20 | } 21 | 22 | if __name__ == '__main__': # pragma: no cover 23 | import sys 24 | import os 25 | 26 | # lookup lexers 27 | found_lexers = [] 28 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) 29 | for root, dirs, files in os.walk('.'): 30 | for filename in files: 31 | if filename.endswith('.py') and not filename.startswith('_'): 32 | module_name = 'pygments.lexers%s.%s' % ( 33 | root[1:].replace('/', '.'), filename[:-3]) 34 | print(module_name) 35 | module = __import__(module_name, None, None, ['']) 36 | for lexer_name in module.__all__: 37 | lexer = getattr(module, lexer_name) 38 | found_lexers.append( 39 | '%r: %r' % (lexer_name, 40 | (module_name, 41 | lexer.name, 42 | tuple(lexer.aliases), 43 | tuple(lexer.filenames), 44 | tuple(lexer.mimetypes)))) 45 | # sort them to make the diff minimal 46 | found_lexers.sort() 47 | 48 | # extract useful sourcecode from this file 49 | with open(__file__) as fp: 50 | content = fp.read() 51 | header = content[:content.find('LEXERS = {')] 52 | footer = content[content.find("if __name__ == '__main__':"):] 53 | 54 | # write new file 55 | with open(__file__, 'w') as fp: 56 | fp.write(header) 57 | fp.write('LEXERS = {\n %s,\n}\n\n' % ',\n '.join(found_lexers)) 58 | fp.write(footer) 59 | 60 | print ('=== %d lexers processed.' % len(found_lexers)) 61 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/modeline.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.modeline 4 | ~~~~~~~~~~~~~~~~~ 5 | 6 | A simple modeline parser (based on pymodeline). 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | import re 13 | 14 | __all__ = ['get_filetype_from_buffer'] 15 | 16 | modeline_re = re.compile(r''' 17 | (?: vi | vim | ex ) (?: [<=>]? \d* )? : 18 | .* (?: ft | filetype | syn | syntax ) = ( [^:\s]+ ) 19 | ''', re.VERBOSE) 20 | 21 | def get_filetype_from_line(l): 22 | m = modeline_re.search(l) 23 | if m: 24 | return m.group(1) 25 | 26 | def get_filetype_from_buffer(buf, max_lines=5): 27 | """ 28 | Scan the buffer for modelines and return filetype if one is found. 29 | """ 30 | lines = buf.splitlines() 31 | for l in lines[-1:-max_lines-1:-1]: 32 | ret = get_filetype_from_line(l) 33 | if ret: 34 | return ret 35 | for l in lines[max_lines:0:-1]: 36 | ret = get_filetype_from_line(l) 37 | if ret: 38 | return ret 39 | 40 | return None 41 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/plugin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.plugin 4 | ~~~~~~~~~~~~~~~ 5 | 6 | Pygments setuptools plugin interface. The methods defined 7 | here also work if setuptools isn't installed but they just 8 | return nothing. 9 | 10 | lexer plugins:: 11 | 12 | [pygments.lexers] 13 | yourlexer = yourmodule:YourLexer 14 | 15 | formatter plugins:: 16 | 17 | [pygments.formatters] 18 | yourformatter = yourformatter:YourFormatter 19 | /.ext = yourformatter:YourFormatter 20 | 21 | As you can see, you can define extensions for the formatter 22 | with a leading slash. 23 | 24 | syntax plugins:: 25 | 26 | [pygments.styles] 27 | yourstyle = yourstyle:YourStyle 28 | 29 | filter plugin:: 30 | 31 | [pygments.filter] 32 | yourfilter = yourfilter:YourFilter 33 | 34 | 35 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 36 | :license: BSD, see LICENSE for details. 37 | """ 38 | try: 39 | import pkg_resources 40 | except ImportError: 41 | pkg_resources = None 42 | 43 | LEXER_ENTRY_POINT = 'pygments.lexers' 44 | FORMATTER_ENTRY_POINT = 'pygments.formatters' 45 | STYLE_ENTRY_POINT = 'pygments.styles' 46 | FILTER_ENTRY_POINT = 'pygments.filters' 47 | 48 | 49 | def find_plugin_lexers(): 50 | if pkg_resources is None: 51 | return 52 | for entrypoint in pkg_resources.iter_entry_points(LEXER_ENTRY_POINT): 53 | yield entrypoint.load() 54 | 55 | 56 | def find_plugin_formatters(): 57 | if pkg_resources is None: 58 | return 59 | for entrypoint in pkg_resources.iter_entry_points(FORMATTER_ENTRY_POINT): 60 | yield entrypoint.name, entrypoint.load() 61 | 62 | 63 | def find_plugin_styles(): 64 | if pkg_resources is None: 65 | return 66 | for entrypoint in pkg_resources.iter_entry_points(STYLE_ENTRY_POINT): 67 | yield entrypoint.name, entrypoint.load() 68 | 69 | 70 | def find_plugin_filters(): 71 | if pkg_resources is None: 72 | return 73 | for entrypoint in pkg_resources.iter_entry_points(FILTER_ENTRY_POINT): 74 | yield entrypoint.name, entrypoint.load() 75 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/regexopt.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.regexopt 4 | ~~~~~~~~~~~~~~~~~ 5 | 6 | An algorithm that generates optimized regexes for matching long lists of 7 | literal strings. 8 | 9 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 10 | :license: BSD, see LICENSE for details. 11 | """ 12 | 13 | import re 14 | from re import escape 15 | from os.path import commonprefix 16 | from itertools import groupby 17 | from operator import itemgetter 18 | 19 | CS_ESCAPE = re.compile(r'[\^\\\-\]]') 20 | FIRST_ELEMENT = itemgetter(0) 21 | 22 | 23 | def make_charset(letters): 24 | return '[' + CS_ESCAPE.sub(lambda m: '\\' + m.group(), ''.join(letters)) + ']' 25 | 26 | 27 | def regex_opt_inner(strings, open_paren): 28 | """Return a regex that matches any string in the sorted list of strings.""" 29 | close_paren = open_paren and ')' or '' 30 | # print strings, repr(open_paren) 31 | if not strings: 32 | # print '-> nothing left' 33 | return '' 34 | first = strings[0] 35 | if len(strings) == 1: 36 | # print '-> only 1 string' 37 | return open_paren + escape(first) + close_paren 38 | if not first: 39 | # print '-> first string empty' 40 | return open_paren + regex_opt_inner(strings[1:], '(?:') \ 41 | + '?' + close_paren 42 | if len(first) == 1: 43 | # multiple one-char strings? make a charset 44 | oneletter = [] 45 | rest = [] 46 | for s in strings: 47 | if len(s) == 1: 48 | oneletter.append(s) 49 | else: 50 | rest.append(s) 51 | if len(oneletter) > 1: # do we have more than one oneletter string? 52 | if rest: 53 | # print '-> 1-character + rest' 54 | return open_paren + regex_opt_inner(rest, '') + '|' \ 55 | + make_charset(oneletter) + close_paren 56 | # print '-> only 1-character' 57 | return make_charset(oneletter) 58 | prefix = commonprefix(strings) 59 | if prefix: 60 | plen = len(prefix) 61 | # we have a prefix for all strings 62 | # print '-> prefix:', prefix 63 | return open_paren + escape(prefix) \ 64 | + regex_opt_inner([s[plen:] for s in strings], '(?:') \ 65 | + close_paren 66 | # is there a suffix? 67 | strings_rev = [s[::-1] for s in strings] 68 | suffix = commonprefix(strings_rev) 69 | if suffix: 70 | slen = len(suffix) 71 | # print '-> suffix:', suffix[::-1] 72 | return open_paren \ 73 | + regex_opt_inner(sorted(s[:-slen] for s in strings), '(?:') \ 74 | + escape(suffix[::-1]) + close_paren 75 | # recurse on common 1-string prefixes 76 | # print '-> last resort' 77 | return open_paren + \ 78 | '|'.join(regex_opt_inner(list(group[1]), '') 79 | for group in groupby(strings, lambda s: s[0] == first[0])) \ 80 | + close_paren 81 | 82 | 83 | def regex_opt(strings, prefix='', suffix=''): 84 | """Return a compiled regex that matches any string in the given list. 85 | 86 | The strings to match must be literal strings, not regexes. They will be 87 | regex-escaped. 88 | 89 | *prefix* and *suffix* are pre- and appended to the final regex. 90 | """ 91 | strings = sorted(strings) 92 | return prefix + regex_opt_inner(strings, '(') + suffix 93 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/scanner.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.scanner 4 | ~~~~~~~~~~~~~~~~ 5 | 6 | This library implements a regex based scanner. Some languages 7 | like Pascal are easy to parse but have some keywords that 8 | depend on the context. Because of this it's impossible to lex 9 | that just by using a regular expression lexer like the 10 | `RegexLexer`. 11 | 12 | Have a look at the `DelphiLexer` to get an idea of how to use 13 | this scanner. 14 | 15 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 16 | :license: BSD, see LICENSE for details. 17 | """ 18 | import re 19 | 20 | 21 | class EndOfText(RuntimeError): 22 | """ 23 | Raise if end of text is reached and the user 24 | tried to call a match function. 25 | """ 26 | 27 | 28 | class Scanner(object): 29 | """ 30 | Simple scanner 31 | 32 | All method patterns are regular expression strings (not 33 | compiled expressions!) 34 | """ 35 | 36 | def __init__(self, text, flags=0): 37 | """ 38 | :param text: The text which should be scanned 39 | :param flags: default regular expression flags 40 | """ 41 | self.data = text 42 | self.data_length = len(text) 43 | self.start_pos = 0 44 | self.pos = 0 45 | self.flags = flags 46 | self.last = None 47 | self.match = None 48 | self._re_cache = {} 49 | 50 | def eos(self): 51 | """`True` if the scanner reached the end of text.""" 52 | return self.pos >= self.data_length 53 | eos = property(eos, eos.__doc__) 54 | 55 | def check(self, pattern): 56 | """ 57 | Apply `pattern` on the current position and return 58 | the match object. (Doesn't touch pos). Use this for 59 | lookahead. 60 | """ 61 | if self.eos: 62 | raise EndOfText() 63 | if pattern not in self._re_cache: 64 | self._re_cache[pattern] = re.compile(pattern, self.flags) 65 | return self._re_cache[pattern].match(self.data, self.pos) 66 | 67 | def test(self, pattern): 68 | """Apply a pattern on the current position and check 69 | if it patches. Doesn't touch pos.""" 70 | return self.check(pattern) is not None 71 | 72 | def scan(self, pattern): 73 | """ 74 | Scan the text for the given pattern and update pos/match 75 | and related fields. The return value is a boolen that 76 | indicates if the pattern matched. The matched value is 77 | stored on the instance as ``match``, the last value is 78 | stored as ``last``. ``start_pos`` is the position of the 79 | pointer before the pattern was matched, ``pos`` is the 80 | end position. 81 | """ 82 | if self.eos: 83 | raise EndOfText() 84 | if pattern not in self._re_cache: 85 | self._re_cache[pattern] = re.compile(pattern, self.flags) 86 | self.last = self.match 87 | m = self._re_cache[pattern].match(self.data, self.pos) 88 | if m is None: 89 | return False 90 | self.start_pos = m.start() 91 | self.pos = m.end() 92 | self.match = m.group() 93 | return True 94 | 95 | def get_char(self): 96 | """Scan exactly one char.""" 97 | self.scan('.') 98 | 99 | def __repr__(self): 100 | return '<%s %d/%d>' % ( 101 | self.__class__.__name__, 102 | self.pos, 103 | self.data_length 104 | ) 105 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/sphinxext.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.sphinxext 4 | ~~~~~~~~~~~~~~~~~~ 5 | 6 | Sphinx extension to generate automatic documentation of lexers, 7 | formatters and filters. 8 | 9 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 10 | :license: BSD, see LICENSE for details. 11 | """ 12 | 13 | from __future__ import print_function 14 | 15 | import sys 16 | 17 | from docutils import nodes 18 | from docutils.statemachine import ViewList 19 | from sphinx.util.compat import Directive 20 | from sphinx.util.nodes import nested_parse_with_titles 21 | 22 | 23 | MODULEDOC = ''' 24 | .. module:: %s 25 | 26 | %s 27 | %s 28 | ''' 29 | 30 | LEXERDOC = ''' 31 | .. class:: %s 32 | 33 | :Short names: %s 34 | :Filenames: %s 35 | :MIME types: %s 36 | 37 | %s 38 | 39 | ''' 40 | 41 | FMTERDOC = ''' 42 | .. class:: %s 43 | 44 | :Short names: %s 45 | :Filenames: %s 46 | 47 | %s 48 | 49 | ''' 50 | 51 | FILTERDOC = ''' 52 | .. class:: %s 53 | 54 | :Name: %s 55 | 56 | %s 57 | 58 | ''' 59 | 60 | class PygmentsDoc(Directive): 61 | """ 62 | A directive to collect all lexers/formatters/filters and generate 63 | autoclass directives for them. 64 | """ 65 | has_content = False 66 | required_arguments = 1 67 | optional_arguments = 0 68 | final_argument_whitespace = False 69 | option_spec = {} 70 | 71 | def run(self): 72 | self.filenames = set() 73 | if self.arguments[0] == 'lexers': 74 | out = self.document_lexers() 75 | elif self.arguments[0] == 'formatters': 76 | out = self.document_formatters() 77 | elif self.arguments[0] == 'filters': 78 | out = self.document_filters() 79 | else: 80 | raise Exception('invalid argument for "pygmentsdoc" directive') 81 | node = nodes.compound() 82 | vl = ViewList(out.split('\n'), source='') 83 | nested_parse_with_titles(self.state, vl, node) 84 | for fn in self.filenames: 85 | self.state.document.settings.record_dependencies.add(fn) 86 | return node.children 87 | 88 | def document_lexers(self): 89 | from pygments.lexers._mapping import LEXERS 90 | out = [] 91 | modules = {} 92 | moduledocstrings = {} 93 | for classname, data in sorted(LEXERS.items(), key=lambda x: x[0]): 94 | module = data[0] 95 | mod = __import__(module, None, None, [classname]) 96 | self.filenames.add(mod.__file__) 97 | cls = getattr(mod, classname) 98 | if not cls.__doc__: 99 | print("Warning: %s does not have a docstring." % classname) 100 | docstring = cls.__doc__ 101 | if isinstance(docstring, bytes): 102 | docstring = docstring.decode('utf8') 103 | modules.setdefault(module, []).append(( 104 | classname, 105 | ', '.join(data[2]) or 'None', 106 | ', '.join(data[3]).replace('*', '\\*').replace('_', '\\') or 'None', 107 | ', '.join(data[4]) or 'None', 108 | docstring)) 109 | if module not in moduledocstrings: 110 | moddoc = mod.__doc__ 111 | if isinstance(moddoc, bytes): 112 | moddoc = moddoc.decode('utf8') 113 | moduledocstrings[module] = moddoc 114 | 115 | for module, lexers in sorted(modules.items(), key=lambda x: x[0]): 116 | heading = moduledocstrings[module].splitlines()[4].strip().rstrip('.') 117 | out.append(MODULEDOC % (module, heading, '-'*len(heading))) 118 | for data in lexers: 119 | out.append(LEXERDOC % data) 120 | 121 | return ''.join(out) 122 | 123 | def document_formatters(self): 124 | from pygments.formatters import FORMATTERS 125 | 126 | out = [] 127 | for classname, data in sorted(FORMATTERS.items(), key=lambda x: x[0]): 128 | module = data[0] 129 | mod = __import__(module, None, None, [classname]) 130 | self.filenames.add(mod.__file__) 131 | cls = getattr(mod, classname) 132 | docstring = cls.__doc__ 133 | if isinstance(docstring, bytes): 134 | docstring = docstring.decode('utf8') 135 | heading = cls.__name__ 136 | out.append(FMTERDOC % (heading, ', '.join(data[1]) or 'None', 137 | ', '.join(data[2]).replace('*', '\\*') or 'None', 138 | docstring)) 139 | return ''.join(out) 140 | 141 | def document_filters(self): 142 | from pygments.filters import FILTERS 143 | 144 | out = [] 145 | for name, cls in FILTERS.items(): 146 | self.filenames.add(sys.modules[cls.__module__].__file__) 147 | docstring = cls.__doc__ 148 | if isinstance(docstring, bytes): 149 | docstring = docstring.decode('utf8') 150 | out.append(FILTERDOC % (cls.__name__, name, docstring)) 151 | return ''.join(out) 152 | 153 | 154 | def setup(app): 155 | app.add_directive('pygmentsdoc', PygmentsDoc) 156 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/style.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.style 4 | ~~~~~~~~~~~~~~ 5 | 6 | Basic style object. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.token import Token, STANDARD_TYPES 13 | from pygments.util import add_metaclass 14 | 15 | 16 | class StyleMeta(type): 17 | 18 | def __new__(mcs, name, bases, dct): 19 | obj = type.__new__(mcs, name, bases, dct) 20 | for token in STANDARD_TYPES: 21 | if token not in obj.styles: 22 | obj.styles[token] = '' 23 | 24 | def colorformat(text): 25 | if text[0:1] == '#': 26 | col = text[1:] 27 | if len(col) == 6: 28 | return col 29 | elif len(col) == 3: 30 | return col[0]*2 + col[1]*2 + col[2]*2 31 | elif text == '': 32 | return '' 33 | assert False, "wrong color format %r" % text 34 | 35 | _styles = obj._styles = {} 36 | 37 | for ttype in obj.styles: 38 | for token in ttype.split(): 39 | if token in _styles: 40 | continue 41 | ndef = _styles.get(token.parent, None) 42 | styledefs = obj.styles.get(token, '').split() 43 | if not ndef or token is None: 44 | ndef = ['', 0, 0, 0, '', '', 0, 0, 0] 45 | elif 'noinherit' in styledefs and token is not Token: 46 | ndef = _styles[Token][:] 47 | else: 48 | ndef = ndef[:] 49 | _styles[token] = ndef 50 | for styledef in obj.styles.get(token, '').split(): 51 | if styledef == 'noinherit': 52 | pass 53 | elif styledef == 'bold': 54 | ndef[1] = 1 55 | elif styledef == 'nobold': 56 | ndef[1] = 0 57 | elif styledef == 'italic': 58 | ndef[2] = 1 59 | elif styledef == 'noitalic': 60 | ndef[2] = 0 61 | elif styledef == 'underline': 62 | ndef[3] = 1 63 | elif styledef == 'nounderline': 64 | ndef[3] = 0 65 | elif styledef[:3] == 'bg:': 66 | ndef[4] = colorformat(styledef[3:]) 67 | elif styledef[:7] == 'border:': 68 | ndef[5] = colorformat(styledef[7:]) 69 | elif styledef == 'roman': 70 | ndef[6] = 1 71 | elif styledef == 'sans': 72 | ndef[7] = 1 73 | elif styledef == 'mono': 74 | ndef[8] = 1 75 | else: 76 | ndef[0] = colorformat(styledef) 77 | 78 | return obj 79 | 80 | def style_for_token(cls, token): 81 | t = cls._styles[token] 82 | return { 83 | 'color': t[0] or None, 84 | 'bold': bool(t[1]), 85 | 'italic': bool(t[2]), 86 | 'underline': bool(t[3]), 87 | 'bgcolor': t[4] or None, 88 | 'border': t[5] or None, 89 | 'roman': bool(t[6]) or None, 90 | 'sans': bool(t[7]) or None, 91 | 'mono': bool(t[8]) or None, 92 | } 93 | 94 | def list_styles(cls): 95 | return list(cls) 96 | 97 | def styles_token(cls, ttype): 98 | return ttype in cls._styles 99 | 100 | def __iter__(cls): 101 | for token in cls._styles: 102 | yield token, cls.style_for_token(token) 103 | 104 | def __len__(cls): 105 | return len(cls._styles) 106 | 107 | 108 | @add_metaclass(StyleMeta) 109 | class Style(object): 110 | 111 | #: overall background color (``None`` means transparent) 112 | background_color = '#ffffff' 113 | 114 | #: highlight background color 115 | highlight_color = '#ffffcc' 116 | 117 | #: Style definitions for individual token types. 118 | styles = {} 119 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles 4 | ~~~~~~~~~~~~~~~ 5 | 6 | Contains built-in styles. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.plugin import find_plugin_styles 13 | from pygments.util import ClassNotFound 14 | 15 | 16 | #: Maps style names to 'submodule::classname'. 17 | STYLE_MAP = { 18 | 'default': 'default::DefaultStyle', 19 | 'emacs': 'emacs::EmacsStyle', 20 | 'friendly': 'friendly::FriendlyStyle', 21 | 'colorful': 'colorful::ColorfulStyle', 22 | 'autumn': 'autumn::AutumnStyle', 23 | 'murphy': 'murphy::MurphyStyle', 24 | 'manni': 'manni::ManniStyle', 25 | 'monokai': 'monokai::MonokaiStyle', 26 | 'perldoc': 'perldoc::PerldocStyle', 27 | 'pastie': 'pastie::PastieStyle', 28 | 'borland': 'borland::BorlandStyle', 29 | 'trac': 'trac::TracStyle', 30 | 'native': 'native::NativeStyle', 31 | 'fruity': 'fruity::FruityStyle', 32 | 'bw': 'bw::BlackWhiteStyle', 33 | 'vim': 'vim::VimStyle', 34 | 'vs': 'vs::VisualStudioStyle', 35 | 'tango': 'tango::TangoStyle', 36 | 'rrt': 'rrt::RrtStyle', 37 | 'xcode': 'xcode::XcodeStyle', 38 | 'igor': 'igor::IgorStyle', 39 | 'paraiso-light': 'paraiso_light::ParaisoLightStyle', 40 | 'paraiso-dark': 'paraiso_dark::ParaisoDarkStyle', 41 | } 42 | 43 | 44 | def get_style_by_name(name): 45 | if name in STYLE_MAP: 46 | mod, cls = STYLE_MAP[name].split('::') 47 | builtin = "yes" 48 | else: 49 | for found_name, style in find_plugin_styles(): 50 | if name == found_name: 51 | return style 52 | # perhaps it got dropped into our styles package 53 | builtin = "" 54 | mod = name 55 | cls = name.title() + "Style" 56 | 57 | try: 58 | mod = __import__('pygments.styles.' + mod, None, None, [cls]) 59 | except ImportError: 60 | raise ClassNotFound("Could not find style module %r" % mod + 61 | (builtin and ", though it should be builtin") + ".") 62 | try: 63 | return getattr(mod, cls) 64 | except AttributeError: 65 | raise ClassNotFound("Could not find style class %r in style module." % cls) 66 | 67 | 68 | def get_all_styles(): 69 | """Return an generator for all styles by name, 70 | both builtin and plugin.""" 71 | for name in STYLE_MAP: 72 | yield name 73 | for name, _ in find_plugin_styles(): 74 | yield name 75 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/autumn.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.autumn 4 | ~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | A colorful style, inspired by the terminal highlighting style. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Whitespace 15 | 16 | 17 | class AutumnStyle(Style): 18 | """ 19 | A colorful style, inspired by the terminal highlighting style. 20 | """ 21 | 22 | default_style = "" 23 | 24 | styles = { 25 | Whitespace: '#bbbbbb', 26 | 27 | Comment: 'italic #aaaaaa', 28 | Comment.Preproc: 'noitalic #4c8317', 29 | Comment.Special: 'italic #0000aa', 30 | 31 | Keyword: '#0000aa', 32 | Keyword.Type: '#00aaaa', 33 | 34 | Operator.Word: '#0000aa', 35 | 36 | Name.Builtin: '#00aaaa', 37 | Name.Function: '#00aa00', 38 | Name.Class: 'underline #00aa00', 39 | Name.Namespace: 'underline #00aaaa', 40 | Name.Variable: '#aa0000', 41 | Name.Constant: '#aa0000', 42 | Name.Entity: 'bold #800', 43 | Name.Attribute: '#1e90ff', 44 | Name.Tag: 'bold #1e90ff', 45 | Name.Decorator: '#888888', 46 | 47 | String: '#aa5500', 48 | String.Symbol: '#0000aa', 49 | String.Regex: '#009999', 50 | 51 | Number: '#009999', 52 | 53 | Generic.Heading: 'bold #000080', 54 | Generic.Subheading: 'bold #800080', 55 | Generic.Deleted: '#aa0000', 56 | Generic.Inserted: '#00aa00', 57 | Generic.Error: '#aa0000', 58 | Generic.Emph: 'italic', 59 | Generic.Strong: 'bold', 60 | Generic.Prompt: '#555555', 61 | Generic.Output: '#888888', 62 | Generic.Traceback: '#aa0000', 63 | 64 | Error: '#F00 bg:#FAA' 65 | } 66 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/borland.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.borland 4 | ~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Style similar to the style used in the Borland IDEs. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Whitespace 15 | 16 | 17 | class BorlandStyle(Style): 18 | """ 19 | Style similar to the style used in the borland IDEs. 20 | """ 21 | 22 | default_style = '' 23 | 24 | styles = { 25 | Whitespace: '#bbbbbb', 26 | 27 | Comment: 'italic #008800', 28 | Comment.Preproc: 'noitalic #008080', 29 | Comment.Special: 'noitalic bold', 30 | 31 | String: '#0000FF', 32 | String.Char: '#800080', 33 | Number: '#0000FF', 34 | Keyword: 'bold #000080', 35 | Operator.Word: 'bold', 36 | Name.Tag: 'bold #000080', 37 | Name.Attribute: '#FF0000', 38 | 39 | Generic.Heading: '#999999', 40 | Generic.Subheading: '#aaaaaa', 41 | Generic.Deleted: 'bg:#ffdddd #000000', 42 | Generic.Inserted: 'bg:#ddffdd #000000', 43 | Generic.Error: '#aa0000', 44 | Generic.Emph: 'italic', 45 | Generic.Strong: 'bold', 46 | Generic.Prompt: '#555555', 47 | Generic.Output: '#888888', 48 | Generic.Traceback: '#aa0000', 49 | 50 | Error: 'bg:#e3d2d2 #a61717' 51 | } 52 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/bw.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.bw 4 | ~~~~~~~~~~~~~~~~~~ 5 | 6 | Simple black/white only style. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Operator, Generic 15 | 16 | 17 | class BlackWhiteStyle(Style): 18 | 19 | background_color = "#ffffff" 20 | default_style = "" 21 | 22 | styles = { 23 | Comment: "italic", 24 | Comment.Preproc: "noitalic", 25 | 26 | Keyword: "bold", 27 | Keyword.Pseudo: "nobold", 28 | Keyword.Type: "nobold", 29 | 30 | Operator.Word: "bold", 31 | 32 | Name.Class: "bold", 33 | Name.Namespace: "bold", 34 | Name.Exception: "bold", 35 | Name.Entity: "bold", 36 | Name.Tag: "bold", 37 | 38 | String: "italic", 39 | String.Interpol: "bold", 40 | String.Escape: "bold", 41 | 42 | Generic.Heading: "bold", 43 | Generic.Subheading: "bold", 44 | Generic.Emph: "italic", 45 | Generic.Strong: "bold", 46 | Generic.Prompt: "bold", 47 | 48 | Error: "border:#FF0000" 49 | } 50 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/colorful.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.colorful 4 | ~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | A colorful style, inspired by CodeRay. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Whitespace 15 | 16 | 17 | class ColorfulStyle(Style): 18 | """ 19 | A colorful style, inspired by CodeRay. 20 | """ 21 | 22 | default_style = "" 23 | 24 | styles = { 25 | Whitespace: "#bbbbbb", 26 | 27 | Comment: "#888", 28 | Comment.Preproc: "#579", 29 | Comment.Special: "bold #cc0000", 30 | 31 | Keyword: "bold #080", 32 | Keyword.Pseudo: "#038", 33 | Keyword.Type: "#339", 34 | 35 | Operator: "#333", 36 | Operator.Word: "bold #000", 37 | 38 | Name.Builtin: "#007020", 39 | Name.Function: "bold #06B", 40 | Name.Class: "bold #B06", 41 | Name.Namespace: "bold #0e84b5", 42 | Name.Exception: "bold #F00", 43 | Name.Variable: "#963", 44 | Name.Variable.Instance: "#33B", 45 | Name.Variable.Class: "#369", 46 | Name.Variable.Global: "bold #d70", 47 | Name.Constant: "bold #036", 48 | Name.Label: "bold #970", 49 | Name.Entity: "bold #800", 50 | Name.Attribute: "#00C", 51 | Name.Tag: "#070", 52 | Name.Decorator: "bold #555", 53 | 54 | String: "bg:#fff0f0", 55 | String.Char: "#04D bg:", 56 | String.Doc: "#D42 bg:", 57 | String.Interpol: "bg:#eee", 58 | String.Escape: "bold #666", 59 | String.Regex: "bg:#fff0ff #000", 60 | String.Symbol: "#A60 bg:", 61 | String.Other: "#D20", 62 | 63 | Number: "bold #60E", 64 | Number.Integer: "bold #00D", 65 | Number.Float: "bold #60E", 66 | Number.Hex: "bold #058", 67 | Number.Oct: "bold #40E", 68 | 69 | Generic.Heading: "bold #000080", 70 | Generic.Subheading: "bold #800080", 71 | Generic.Deleted: "#A00000", 72 | Generic.Inserted: "#00A000", 73 | Generic.Error: "#FF0000", 74 | Generic.Emph: "italic", 75 | Generic.Strong: "bold", 76 | Generic.Prompt: "bold #c65d09", 77 | Generic.Output: "#888", 78 | Generic.Traceback: "#04D", 79 | 80 | Error: "#F00 bg:#FAA" 81 | } 82 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/default.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.default 4 | ~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | The default highlighting style. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Whitespace 15 | 16 | 17 | class DefaultStyle(Style): 18 | """ 19 | The default style (inspired by Emacs 22). 20 | """ 21 | 22 | background_color = "#f8f8f8" 23 | default_style = "" 24 | 25 | styles = { 26 | Whitespace: "#bbbbbb", 27 | Comment: "italic #408080", 28 | Comment.Preproc: "noitalic #BC7A00", 29 | 30 | #Keyword: "bold #AA22FF", 31 | Keyword: "bold #008000", 32 | Keyword.Pseudo: "nobold", 33 | Keyword.Type: "nobold #B00040", 34 | 35 | Operator: "#666666", 36 | Operator.Word: "bold #AA22FF", 37 | 38 | Name.Builtin: "#008000", 39 | Name.Function: "#0000FF", 40 | Name.Class: "bold #0000FF", 41 | Name.Namespace: "bold #0000FF", 42 | Name.Exception: "bold #D2413A", 43 | Name.Variable: "#19177C", 44 | Name.Constant: "#880000", 45 | Name.Label: "#A0A000", 46 | Name.Entity: "bold #999999", 47 | Name.Attribute: "#7D9029", 48 | Name.Tag: "bold #008000", 49 | Name.Decorator: "#AA22FF", 50 | 51 | String: "#BA2121", 52 | String.Doc: "italic", 53 | String.Interpol: "bold #BB6688", 54 | String.Escape: "bold #BB6622", 55 | String.Regex: "#BB6688", 56 | #String.Symbol: "#B8860B", 57 | String.Symbol: "#19177C", 58 | String.Other: "#008000", 59 | Number: "#666666", 60 | 61 | Generic.Heading: "bold #000080", 62 | Generic.Subheading: "bold #800080", 63 | Generic.Deleted: "#A00000", 64 | Generic.Inserted: "#00A000", 65 | Generic.Error: "#FF0000", 66 | Generic.Emph: "italic", 67 | Generic.Strong: "bold", 68 | Generic.Prompt: "bold #000080", 69 | Generic.Output: "#888", 70 | Generic.Traceback: "#04D", 71 | 72 | Error: "border:#FF0000" 73 | } 74 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/emacs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.emacs 4 | ~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | A highlighting style for Pygments, inspired by Emacs. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Whitespace 15 | 16 | 17 | class EmacsStyle(Style): 18 | """ 19 | The default style (inspired by Emacs 22). 20 | """ 21 | 22 | background_color = "#f8f8f8" 23 | default_style = "" 24 | 25 | styles = { 26 | Whitespace: "#bbbbbb", 27 | Comment: "italic #008800", 28 | Comment.Preproc: "noitalic", 29 | Comment.Special: "noitalic bold", 30 | 31 | Keyword: "bold #AA22FF", 32 | Keyword.Pseudo: "nobold", 33 | Keyword.Type: "bold #00BB00", 34 | 35 | Operator: "#666666", 36 | Operator.Word: "bold #AA22FF", 37 | 38 | Name.Builtin: "#AA22FF", 39 | Name.Function: "#00A000", 40 | Name.Class: "#0000FF", 41 | Name.Namespace: "bold #0000FF", 42 | Name.Exception: "bold #D2413A", 43 | Name.Variable: "#B8860B", 44 | Name.Constant: "#880000", 45 | Name.Label: "#A0A000", 46 | Name.Entity: "bold #999999", 47 | Name.Attribute: "#BB4444", 48 | Name.Tag: "bold #008000", 49 | Name.Decorator: "#AA22FF", 50 | 51 | String: "#BB4444", 52 | String.Doc: "italic", 53 | String.Interpol: "bold #BB6688", 54 | String.Escape: "bold #BB6622", 55 | String.Regex: "#BB6688", 56 | String.Symbol: "#B8860B", 57 | String.Other: "#008000", 58 | Number: "#666666", 59 | 60 | Generic.Heading: "bold #000080", 61 | Generic.Subheading: "bold #800080", 62 | Generic.Deleted: "#A00000", 63 | Generic.Inserted: "#00A000", 64 | Generic.Error: "#FF0000", 65 | Generic.Emph: "italic", 66 | Generic.Strong: "bold", 67 | Generic.Prompt: "bold #000080", 68 | Generic.Output: "#888", 69 | Generic.Traceback: "#04D", 70 | 71 | Error: "border:#FF0000" 72 | } 73 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/friendly.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.friendly 4 | ~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | A modern style based on the VIM pyte theme. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Whitespace 15 | 16 | 17 | class FriendlyStyle(Style): 18 | """ 19 | A modern style based on the VIM pyte theme. 20 | """ 21 | 22 | background_color = "#f0f0f0" 23 | default_style = "" 24 | 25 | styles = { 26 | Whitespace: "#bbbbbb", 27 | Comment: "italic #60a0b0", 28 | Comment.Preproc: "noitalic #007020", 29 | Comment.Special: "noitalic bg:#fff0f0", 30 | 31 | Keyword: "bold #007020", 32 | Keyword.Pseudo: "nobold", 33 | Keyword.Type: "nobold #902000", 34 | 35 | Operator: "#666666", 36 | Operator.Word: "bold #007020", 37 | 38 | Name.Builtin: "#007020", 39 | Name.Function: "#06287e", 40 | Name.Class: "bold #0e84b5", 41 | Name.Namespace: "bold #0e84b5", 42 | Name.Exception: "#007020", 43 | Name.Variable: "#bb60d5", 44 | Name.Constant: "#60add5", 45 | Name.Label: "bold #002070", 46 | Name.Entity: "bold #d55537", 47 | Name.Attribute: "#4070a0", 48 | Name.Tag: "bold #062873", 49 | Name.Decorator: "bold #555555", 50 | 51 | String: "#4070a0", 52 | String.Doc: "italic", 53 | String.Interpol: "italic #70a0d0", 54 | String.Escape: "bold #4070a0", 55 | String.Regex: "#235388", 56 | String.Symbol: "#517918", 57 | String.Other: "#c65d09", 58 | Number: "#40a070", 59 | 60 | Generic.Heading: "bold #000080", 61 | Generic.Subheading: "bold #800080", 62 | Generic.Deleted: "#A00000", 63 | Generic.Inserted: "#00A000", 64 | Generic.Error: "#FF0000", 65 | Generic.Emph: "italic", 66 | Generic.Strong: "bold", 67 | Generic.Prompt: "bold #c65d09", 68 | Generic.Output: "#888", 69 | Generic.Traceback: "#04D", 70 | 71 | Error: "border:#FF0000" 72 | } 73 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/fruity.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.fruity 4 | ~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | pygments version of my "fruity" vim theme. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Token, Comment, Name, Keyword, \ 14 | Generic, Number, String, Whitespace 15 | 16 | class FruityStyle(Style): 17 | """ 18 | Pygments version of the "native" vim theme. 19 | """ 20 | 21 | background_color = '#111111' 22 | highlight_color = '#333333' 23 | 24 | styles = { 25 | Whitespace: '#888888', 26 | Token: '#ffffff', 27 | Generic.Output: '#444444 bg:#222222', 28 | Keyword: '#fb660a bold', 29 | Keyword.Pseudo: 'nobold', 30 | Number: '#0086f7 bold', 31 | Name.Tag: '#fb660a bold', 32 | Name.Variable: '#fb660a', 33 | Comment: '#008800 bg:#0f140f italic', 34 | Name.Attribute: '#ff0086 bold', 35 | String: '#0086d2', 36 | Name.Function: '#ff0086 bold', 37 | Generic.Heading: '#ffffff bold', 38 | Keyword.Type: '#cdcaa9 bold', 39 | Generic.Subheading: '#ffffff bold', 40 | Name.Constant: '#0086d2', 41 | Comment.Preproc: '#ff0007 bold' 42 | } 43 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/igor.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.igor 4 | ~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Igor Pro default style. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String 14 | 15 | 16 | class IgorStyle(Style): 17 | """ 18 | Pygments version of the official colors for Igor Pro procedures. 19 | """ 20 | default_style = "" 21 | 22 | styles = { 23 | Comment: 'italic #FF0000', 24 | Keyword: '#0000FF', 25 | Name.Function: '#C34E00', 26 | Name.Decorator: '#CC00A3', 27 | Name.Class: '#007575', 28 | String: '#009C00' 29 | } 30 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/manni.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.manni 4 | ~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | A colorful style, inspired by the terminal highlighting style. 7 | 8 | This is a port of the style used in the `php port`_ of pygments 9 | by Manni. The style is called 'default' there. 10 | 11 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 12 | :license: BSD, see LICENSE for details. 13 | """ 14 | 15 | from pygments.style import Style 16 | from pygments.token import Keyword, Name, Comment, String, Error, \ 17 | Number, Operator, Generic, Whitespace 18 | 19 | 20 | class ManniStyle(Style): 21 | """ 22 | A colorful style, inspired by the terminal highlighting style. 23 | """ 24 | 25 | background_color = '#f0f3f3' 26 | 27 | styles = { 28 | Whitespace: '#bbbbbb', 29 | Comment: 'italic #0099FF', 30 | Comment.Preproc: 'noitalic #009999', 31 | Comment.Special: 'bold', 32 | 33 | Keyword: 'bold #006699', 34 | Keyword.Pseudo: 'nobold', 35 | Keyword.Type: '#007788', 36 | 37 | Operator: '#555555', 38 | Operator.Word: 'bold #000000', 39 | 40 | Name.Builtin: '#336666', 41 | Name.Function: '#CC00FF', 42 | Name.Class: 'bold #00AA88', 43 | Name.Namespace: 'bold #00CCFF', 44 | Name.Exception: 'bold #CC0000', 45 | Name.Variable: '#003333', 46 | Name.Constant: '#336600', 47 | Name.Label: '#9999FF', 48 | Name.Entity: 'bold #999999', 49 | Name.Attribute: '#330099', 50 | Name.Tag: 'bold #330099', 51 | Name.Decorator: '#9999FF', 52 | 53 | String: '#CC3300', 54 | String.Doc: 'italic', 55 | String.Interpol: '#AA0000', 56 | String.Escape: 'bold #CC3300', 57 | String.Regex: '#33AAAA', 58 | String.Symbol: '#FFCC33', 59 | String.Other: '#CC3300', 60 | 61 | Number: '#FF6600', 62 | 63 | Generic.Heading: 'bold #003300', 64 | Generic.Subheading: 'bold #003300', 65 | Generic.Deleted: 'border:#CC0000 bg:#FFCCCC', 66 | Generic.Inserted: 'border:#00CC00 bg:#CCFFCC', 67 | Generic.Error: '#FF0000', 68 | Generic.Emph: 'italic', 69 | Generic.Strong: 'bold', 70 | Generic.Prompt: 'bold #000099', 71 | Generic.Output: '#AAAAAA', 72 | Generic.Traceback: '#99CC66', 73 | 74 | Error: 'bg:#FFAAAA #AA0000' 75 | } 76 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/monokai.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.monokai 4 | ~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Mimic the Monokai color scheme. Based on tango.py. 7 | 8 | http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/ 9 | 10 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 11 | :license: BSD, see LICENSE for details. 12 | """ 13 | 14 | from pygments.style import Style 15 | from pygments.token import Keyword, Name, Comment, String, Error, Text, \ 16 | Number, Operator, Generic, Whitespace, Punctuation, Other, Literal 17 | 18 | class MonokaiStyle(Style): 19 | """ 20 | This style mimics the Monokai color scheme. 21 | """ 22 | 23 | background_color = "#272822" 24 | highlight_color = "#49483e" 25 | 26 | styles = { 27 | # No corresponding class for the following: 28 | Text: "#f8f8f2", # class: '' 29 | Whitespace: "", # class: 'w' 30 | Error: "#960050 bg:#1e0010", # class: 'err' 31 | Other: "", # class 'x' 32 | 33 | Comment: "#75715e", # class: 'c' 34 | Comment.Multiline: "", # class: 'cm' 35 | Comment.Preproc: "", # class: 'cp' 36 | Comment.Single: "", # class: 'c1' 37 | Comment.Special: "", # class: 'cs' 38 | 39 | Keyword: "#66d9ef", # class: 'k' 40 | Keyword.Constant: "", # class: 'kc' 41 | Keyword.Declaration: "", # class: 'kd' 42 | Keyword.Namespace: "#f92672", # class: 'kn' 43 | Keyword.Pseudo: "", # class: 'kp' 44 | Keyword.Reserved: "", # class: 'kr' 45 | Keyword.Type: "", # class: 'kt' 46 | 47 | Operator: "#f92672", # class: 'o' 48 | Operator.Word: "", # class: 'ow' - like keywords 49 | 50 | Punctuation: "#f8f8f2", # class: 'p' 51 | 52 | Name: "#f8f8f2", # class: 'n' 53 | Name.Attribute: "#a6e22e", # class: 'na' - to be revised 54 | Name.Builtin: "", # class: 'nb' 55 | Name.Builtin.Pseudo: "", # class: 'bp' 56 | Name.Class: "#a6e22e", # class: 'nc' - to be revised 57 | Name.Constant: "#66d9ef", # class: 'no' - to be revised 58 | Name.Decorator: "#a6e22e", # class: 'nd' - to be revised 59 | Name.Entity: "", # class: 'ni' 60 | Name.Exception: "#a6e22e", # class: 'ne' 61 | Name.Function: "#a6e22e", # class: 'nf' 62 | Name.Property: "", # class: 'py' 63 | Name.Label: "", # class: 'nl' 64 | Name.Namespace: "", # class: 'nn' - to be revised 65 | Name.Other: "#a6e22e", # class: 'nx' 66 | Name.Tag: "#f92672", # class: 'nt' - like a keyword 67 | Name.Variable: "", # class: 'nv' - to be revised 68 | Name.Variable.Class: "", # class: 'vc' - to be revised 69 | Name.Variable.Global: "", # class: 'vg' - to be revised 70 | Name.Variable.Instance: "", # class: 'vi' - to be revised 71 | 72 | Number: "#ae81ff", # class: 'm' 73 | Number.Float: "", # class: 'mf' 74 | Number.Hex: "", # class: 'mh' 75 | Number.Integer: "", # class: 'mi' 76 | Number.Integer.Long: "", # class: 'il' 77 | Number.Oct: "", # class: 'mo' 78 | 79 | Literal: "#ae81ff", # class: 'l' 80 | Literal.Date: "#e6db74", # class: 'ld' 81 | 82 | String: "#e6db74", # class: 's' 83 | String.Backtick: "", # class: 'sb' 84 | String.Char: "", # class: 'sc' 85 | String.Doc: "", # class: 'sd' - like a comment 86 | String.Double: "", # class: 's2' 87 | String.Escape: "#ae81ff", # class: 'se' 88 | String.Heredoc: "", # class: 'sh' 89 | String.Interpol: "", # class: 'si' 90 | String.Other: "", # class: 'sx' 91 | String.Regex: "", # class: 'sr' 92 | String.Single: "", # class: 's1' 93 | String.Symbol: "", # class: 'ss' 94 | 95 | Generic: "", # class: 'g' 96 | Generic.Deleted: "#f92672", # class: 'gd', 97 | Generic.Emph: "italic", # class: 'ge' 98 | Generic.Error: "", # class: 'gr' 99 | Generic.Heading: "", # class: 'gh' 100 | Generic.Inserted: "#a6e22e", # class: 'gi' 101 | Generic.Output: "", # class: 'go' 102 | Generic.Prompt: "", # class: 'gp' 103 | Generic.Strong: "bold", # class: 'gs' 104 | Generic.Subheading: "#75715e", # class: 'gu' 105 | Generic.Traceback: "", # class: 'gt' 106 | } 107 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/murphy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.murphy 4 | ~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Murphy's style from CodeRay. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Whitespace 15 | 16 | 17 | class MurphyStyle(Style): 18 | """ 19 | Murphy's style from CodeRay. 20 | """ 21 | 22 | default_style = "" 23 | 24 | styles = { 25 | Whitespace: "#bbbbbb", 26 | Comment: "#666 italic", 27 | Comment.Preproc: "#579 noitalic", 28 | Comment.Special: "#c00 bold", 29 | 30 | Keyword: "bold #289", 31 | Keyword.Pseudo: "#08f", 32 | Keyword.Type: "#66f", 33 | 34 | Operator: "#333", 35 | Operator.Word: "bold #000", 36 | 37 | Name.Builtin: "#072", 38 | Name.Function: "bold #5ed", 39 | Name.Class: "bold #e9e", 40 | Name.Namespace: "bold #0e84b5", 41 | Name.Exception: "bold #F00", 42 | Name.Variable: "#036", 43 | Name.Variable.Instance: "#aaf", 44 | Name.Variable.Class: "#ccf", 45 | Name.Variable.Global: "#f84", 46 | Name.Constant: "bold #5ed", 47 | Name.Label: "bold #970", 48 | Name.Entity: "#800", 49 | Name.Attribute: "#007", 50 | Name.Tag: "#070", 51 | Name.Decorator: "bold #555", 52 | 53 | String: "bg:#e0e0ff", 54 | String.Char: "#88F bg:", 55 | String.Doc: "#D42 bg:", 56 | String.Interpol: "bg:#eee", 57 | String.Escape: "bold #666", 58 | String.Regex: "bg:#e0e0ff #000", 59 | String.Symbol: "#fc8 bg:", 60 | String.Other: "#f88", 61 | 62 | Number: "bold #60E", 63 | Number.Integer: "bold #66f", 64 | Number.Float: "bold #60E", 65 | Number.Hex: "bold #058", 66 | Number.Oct: "bold #40E", 67 | 68 | Generic.Heading: "bold #000080", 69 | Generic.Subheading: "bold #800080", 70 | Generic.Deleted: "#A00000", 71 | Generic.Inserted: "#00A000", 72 | Generic.Error: "#FF0000", 73 | Generic.Emph: "italic", 74 | Generic.Strong: "bold", 75 | Generic.Prompt: "bold #c65d09", 76 | Generic.Output: "#888", 77 | Generic.Traceback: "#04D", 78 | 79 | Error: "#F00 bg:#FAA" 80 | } 81 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/native.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.native 4 | ~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | pygments version of my "native" vim theme. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Token, Whitespace 15 | 16 | 17 | class NativeStyle(Style): 18 | """ 19 | Pygments version of the "native" vim theme. 20 | """ 21 | 22 | background_color = '#202020' 23 | highlight_color = '#404040' 24 | 25 | styles = { 26 | Token: '#d0d0d0', 27 | Whitespace: '#666666', 28 | 29 | Comment: 'italic #999999', 30 | Comment.Preproc: 'noitalic bold #cd2828', 31 | Comment.Special: 'noitalic bold #e50808 bg:#520000', 32 | 33 | Keyword: 'bold #6ab825', 34 | Keyword.Pseudo: 'nobold', 35 | Operator.Word: 'bold #6ab825', 36 | 37 | String: '#ed9d13', 38 | String.Other: '#ffa500', 39 | 40 | Number: '#3677a9', 41 | 42 | Name.Builtin: '#24909d', 43 | Name.Variable: '#40ffff', 44 | Name.Constant: '#40ffff', 45 | Name.Class: 'underline #447fcf', 46 | Name.Function: '#447fcf', 47 | Name.Namespace: 'underline #447fcf', 48 | Name.Exception: '#bbbbbb', 49 | Name.Tag: 'bold #6ab825', 50 | Name.Attribute: '#bbbbbb', 51 | Name.Decorator: '#ffa500', 52 | 53 | Generic.Heading: 'bold #ffffff', 54 | Generic.Subheading: 'underline #ffffff', 55 | Generic.Deleted: '#d22323', 56 | Generic.Inserted: '#589819', 57 | Generic.Error: '#d22323', 58 | Generic.Emph: 'italic', 59 | Generic.Strong: 'bold', 60 | Generic.Prompt: '#aaaaaa', 61 | Generic.Output: '#cccccc', 62 | Generic.Traceback: '#d22323', 63 | 64 | Error: 'bg:#e3d2d2 #a61717' 65 | } 66 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/paraiso_dark.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.paraiso_dark 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Paraíso (Dark) by Jan T. Sott 7 | 8 | Pygments template by Jan T. Sott (https://github.com/idleberg) 9 | Created with Base16 Builder by Chris Kempson 10 | (https://github.com/chriskempson/base16-builder). 11 | 12 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 13 | :license: BSD, see LICENSE for details. 14 | """ 15 | 16 | from pygments.style import Style 17 | from pygments.token import Keyword, Name, Comment, String, Error, Text, \ 18 | Number, Operator, Generic, Whitespace, Punctuation, Other, Literal 19 | 20 | 21 | BACKGROUND = "#2f1e2e" 22 | CURRENT_LINE = "#41323f" 23 | SELECTION = "#4f424c" 24 | FOREGROUND = "#e7e9db" 25 | COMMENT = "#776e71" 26 | RED = "#ef6155" 27 | ORANGE = "#f99b15" 28 | YELLOW = "#fec418" 29 | GREEN = "#48b685" 30 | AQUA = "#5bc4bf" 31 | BLUE = "#06b6ef" 32 | PURPLE = "#815ba4" 33 | 34 | 35 | class ParaisoDarkStyle(Style): 36 | 37 | default_style = '' 38 | 39 | background_color = BACKGROUND 40 | highlight_color = SELECTION 41 | 42 | background_color = BACKGROUND 43 | highlight_color = SELECTION 44 | 45 | styles = { 46 | # No corresponding class for the following: 47 | Text: FOREGROUND, # class: '' 48 | Whitespace: "", # class: 'w' 49 | Error: RED, # class: 'err' 50 | Other: "", # class 'x' 51 | 52 | Comment: COMMENT, # class: 'c' 53 | Comment.Multiline: "", # class: 'cm' 54 | Comment.Preproc: "", # class: 'cp' 55 | Comment.Single: "", # class: 'c1' 56 | Comment.Special: "", # class: 'cs' 57 | 58 | Keyword: PURPLE, # class: 'k' 59 | Keyword.Constant: "", # class: 'kc' 60 | Keyword.Declaration: "", # class: 'kd' 61 | Keyword.Namespace: AQUA, # class: 'kn' 62 | Keyword.Pseudo: "", # class: 'kp' 63 | Keyword.Reserved: "", # class: 'kr' 64 | Keyword.Type: YELLOW, # class: 'kt' 65 | 66 | Operator: AQUA, # class: 'o' 67 | Operator.Word: "", # class: 'ow' - like keywords 68 | 69 | Punctuation: FOREGROUND, # class: 'p' 70 | 71 | Name: FOREGROUND, # class: 'n' 72 | Name.Attribute: BLUE, # class: 'na' - to be revised 73 | Name.Builtin: "", # class: 'nb' 74 | Name.Builtin.Pseudo: "", # class: 'bp' 75 | Name.Class: YELLOW, # class: 'nc' - to be revised 76 | Name.Constant: RED, # class: 'no' - to be revised 77 | Name.Decorator: AQUA, # class: 'nd' - to be revised 78 | Name.Entity: "", # class: 'ni' 79 | Name.Exception: RED, # class: 'ne' 80 | Name.Function: BLUE, # class: 'nf' 81 | Name.Property: "", # class: 'py' 82 | Name.Label: "", # class: 'nl' 83 | Name.Namespace: YELLOW, # class: 'nn' - to be revised 84 | Name.Other: BLUE, # class: 'nx' 85 | Name.Tag: AQUA, # class: 'nt' - like a keyword 86 | Name.Variable: RED, # class: 'nv' - to be revised 87 | Name.Variable.Class: "", # class: 'vc' - to be revised 88 | Name.Variable.Global: "", # class: 'vg' - to be revised 89 | Name.Variable.Instance: "", # class: 'vi' - to be revised 90 | 91 | Number: ORANGE, # class: 'm' 92 | Number.Float: "", # class: 'mf' 93 | Number.Hex: "", # class: 'mh' 94 | Number.Integer: "", # class: 'mi' 95 | Number.Integer.Long: "", # class: 'il' 96 | Number.Oct: "", # class: 'mo' 97 | 98 | Literal: ORANGE, # class: 'l' 99 | Literal.Date: GREEN, # class: 'ld' 100 | 101 | String: GREEN, # class: 's' 102 | String.Backtick: "", # class: 'sb' 103 | String.Char: FOREGROUND, # class: 'sc' 104 | String.Doc: COMMENT, # class: 'sd' - like a comment 105 | String.Double: "", # class: 's2' 106 | String.Escape: ORANGE, # class: 'se' 107 | String.Heredoc: "", # class: 'sh' 108 | String.Interpol: ORANGE, # class: 'si' 109 | String.Other: "", # class: 'sx' 110 | String.Regex: "", # class: 'sr' 111 | String.Single: "", # class: 's1' 112 | String.Symbol: "", # class: 'ss' 113 | 114 | Generic: "", # class: 'g' 115 | Generic.Deleted: RED, # class: 'gd', 116 | Generic.Emph: "italic", # class: 'ge' 117 | Generic.Error: "", # class: 'gr' 118 | Generic.Heading: "bold " + FOREGROUND, # class: 'gh' 119 | Generic.Inserted: GREEN, # class: 'gi' 120 | Generic.Output: "", # class: 'go' 121 | Generic.Prompt: "bold " + COMMENT, # class: 'gp' 122 | Generic.Strong: "bold", # class: 'gs' 123 | Generic.Subheading: "bold " + AQUA, # class: 'gu' 124 | Generic.Traceback: "", # class: 'gt' 125 | } 126 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/paraiso_light.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.paraiso_light 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Paraíso (Light) by Jan T. Sott 7 | 8 | Pygments template by Jan T. Sott (https://github.com/idleberg) 9 | Created with Base16 Builder by Chris Kempson 10 | (https://github.com/chriskempson/base16-builder). 11 | 12 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 13 | :license: BSD, see LICENSE for details. 14 | """ 15 | 16 | from pygments.style import Style 17 | from pygments.token import Keyword, Name, Comment, String, Error, Text, \ 18 | Number, Operator, Generic, Whitespace, Punctuation, Other, Literal 19 | 20 | 21 | BACKGROUND = "#e7e9db" 22 | CURRENT_LINE = "#b9b6b0" 23 | SELECTION = "#a39e9b" 24 | FOREGROUND = "#2f1e2e" 25 | COMMENT = "#8d8687" 26 | RED = "#ef6155" 27 | ORANGE = "#f99b15" 28 | YELLOW = "#fec418" 29 | GREEN = "#48b685" 30 | AQUA = "#5bc4bf" 31 | BLUE = "#06b6ef" 32 | PURPLE = "#815ba4" 33 | 34 | 35 | class ParaisoLightStyle(Style): 36 | 37 | default_style = '' 38 | 39 | background_color = BACKGROUND 40 | highlight_color = SELECTION 41 | 42 | background_color = BACKGROUND 43 | highlight_color = SELECTION 44 | 45 | styles = { 46 | # No corresponding class for the following: 47 | Text: FOREGROUND, # class: '' 48 | Whitespace: "", # class: 'w' 49 | Error: RED, # class: 'err' 50 | Other: "", # class 'x' 51 | 52 | Comment: COMMENT, # class: 'c' 53 | Comment.Multiline: "", # class: 'cm' 54 | Comment.Preproc: "", # class: 'cp' 55 | Comment.Single: "", # class: 'c1' 56 | Comment.Special: "", # class: 'cs' 57 | 58 | Keyword: PURPLE, # class: 'k' 59 | Keyword.Constant: "", # class: 'kc' 60 | Keyword.Declaration: "", # class: 'kd' 61 | Keyword.Namespace: AQUA, # class: 'kn' 62 | Keyword.Pseudo: "", # class: 'kp' 63 | Keyword.Reserved: "", # class: 'kr' 64 | Keyword.Type: YELLOW, # class: 'kt' 65 | 66 | Operator: AQUA, # class: 'o' 67 | Operator.Word: "", # class: 'ow' - like keywords 68 | 69 | Punctuation: FOREGROUND, # class: 'p' 70 | 71 | Name: FOREGROUND, # class: 'n' 72 | Name.Attribute: BLUE, # class: 'na' - to be revised 73 | Name.Builtin: "", # class: 'nb' 74 | Name.Builtin.Pseudo: "", # class: 'bp' 75 | Name.Class: YELLOW, # class: 'nc' - to be revised 76 | Name.Constant: RED, # class: 'no' - to be revised 77 | Name.Decorator: AQUA, # class: 'nd' - to be revised 78 | Name.Entity: "", # class: 'ni' 79 | Name.Exception: RED, # class: 'ne' 80 | Name.Function: BLUE, # class: 'nf' 81 | Name.Property: "", # class: 'py' 82 | Name.Label: "", # class: 'nl' 83 | Name.Namespace: YELLOW, # class: 'nn' - to be revised 84 | Name.Other: BLUE, # class: 'nx' 85 | Name.Tag: AQUA, # class: 'nt' - like a keyword 86 | Name.Variable: RED, # class: 'nv' - to be revised 87 | Name.Variable.Class: "", # class: 'vc' - to be revised 88 | Name.Variable.Global: "", # class: 'vg' - to be revised 89 | Name.Variable.Instance: "", # class: 'vi' - to be revised 90 | 91 | Number: ORANGE, # class: 'm' 92 | Number.Float: "", # class: 'mf' 93 | Number.Hex: "", # class: 'mh' 94 | Number.Integer: "", # class: 'mi' 95 | Number.Integer.Long: "", # class: 'il' 96 | Number.Oct: "", # class: 'mo' 97 | 98 | Literal: ORANGE, # class: 'l' 99 | Literal.Date: GREEN, # class: 'ld' 100 | 101 | String: GREEN, # class: 's' 102 | String.Backtick: "", # class: 'sb' 103 | String.Char: FOREGROUND, # class: 'sc' 104 | String.Doc: COMMENT, # class: 'sd' - like a comment 105 | String.Double: "", # class: 's2' 106 | String.Escape: ORANGE, # class: 'se' 107 | String.Heredoc: "", # class: 'sh' 108 | String.Interpol: ORANGE, # class: 'si' 109 | String.Other: "", # class: 'sx' 110 | String.Regex: "", # class: 'sr' 111 | String.Single: "", # class: 's1' 112 | String.Symbol: "", # class: 'ss' 113 | 114 | Generic: "", # class: 'g' 115 | Generic.Deleted: RED, # class: 'gd', 116 | Generic.Emph: "italic", # class: 'ge' 117 | Generic.Error: "", # class: 'gr' 118 | Generic.Heading: "bold " + FOREGROUND, # class: 'gh' 119 | Generic.Inserted: GREEN, # class: 'gi' 120 | Generic.Output: "", # class: 'go' 121 | Generic.Prompt: "bold " + COMMENT, # class: 'gp' 122 | Generic.Strong: "bold", # class: 'gs' 123 | Generic.Subheading: "bold " + AQUA, # class: 'gu' 124 | Generic.Traceback: "", # class: 'gt' 125 | } 126 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/pastie.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.pastie 4 | ~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Style similar to the `pastie`_ default style. 7 | 8 | .. _pastie: http://pastie.caboo.se/ 9 | 10 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 11 | :license: BSD, see LICENSE for details. 12 | """ 13 | 14 | from pygments.style import Style 15 | from pygments.token import Keyword, Name, Comment, String, Error, \ 16 | Number, Operator, Generic, Whitespace 17 | 18 | 19 | class PastieStyle(Style): 20 | """ 21 | Style similar to the pastie default style. 22 | """ 23 | 24 | default_style = '' 25 | 26 | styles = { 27 | Whitespace: '#bbbbbb', 28 | Comment: '#888888', 29 | Comment.Preproc: 'bold #cc0000', 30 | Comment.Special: 'bg:#fff0f0 bold #cc0000', 31 | 32 | String: 'bg:#fff0f0 #dd2200', 33 | String.Regex: 'bg:#fff0ff #008800', 34 | String.Other: 'bg:#f0fff0 #22bb22', 35 | String.Symbol: '#aa6600', 36 | String.Interpol: '#3333bb', 37 | String.Escape: '#0044dd', 38 | 39 | Operator.Word: '#008800', 40 | 41 | Keyword: 'bold #008800', 42 | Keyword.Pseudo: 'nobold', 43 | Keyword.Type: '#888888', 44 | 45 | Name.Class: 'bold #bb0066', 46 | Name.Exception: 'bold #bb0066', 47 | Name.Function: 'bold #0066bb', 48 | Name.Property: 'bold #336699', 49 | Name.Namespace: 'bold #bb0066', 50 | Name.Builtin: '#003388', 51 | Name.Variable: '#336699', 52 | Name.Variable.Class: '#336699', 53 | Name.Variable.Instance: '#3333bb', 54 | Name.Variable.Global: '#dd7700', 55 | Name.Constant: 'bold #003366', 56 | Name.Tag: 'bold #bb0066', 57 | Name.Attribute: '#336699', 58 | Name.Decorator: '#555555', 59 | Name.Label: 'italic #336699', 60 | 61 | Number: 'bold #0000DD', 62 | 63 | Generic.Heading: '#333', 64 | Generic.Subheading: '#666', 65 | Generic.Deleted: 'bg:#ffdddd #000000', 66 | Generic.Inserted: 'bg:#ddffdd #000000', 67 | Generic.Error: '#aa0000', 68 | Generic.Emph: 'italic', 69 | Generic.Strong: 'bold', 70 | Generic.Prompt: '#555555', 71 | Generic.Output: '#888888', 72 | Generic.Traceback: '#aa0000', 73 | 74 | Error: 'bg:#e3d2d2 #a61717' 75 | } 76 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/perldoc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.perldoc 4 | ~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Style similar to the style used in the `perldoc`_ code blocks. 7 | 8 | .. _perldoc: http://perldoc.perl.org/ 9 | 10 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 11 | :license: BSD, see LICENSE for details. 12 | """ 13 | 14 | from pygments.style import Style 15 | from pygments.token import Keyword, Name, Comment, String, Error, \ 16 | Number, Operator, Generic, Whitespace 17 | 18 | 19 | class PerldocStyle(Style): 20 | """ 21 | Style similar to the style used in the perldoc code blocks. 22 | """ 23 | 24 | background_color = '#eeeedd' 25 | default_style = '' 26 | 27 | styles = { 28 | Whitespace: '#bbbbbb', 29 | Comment: '#228B22', 30 | Comment.Preproc: '#1e889b', 31 | Comment.Special: '#8B008B bold', 32 | 33 | String: '#CD5555', 34 | String.Heredoc: '#1c7e71 italic', 35 | String.Regex: '#B452CD', 36 | String.Other: '#cb6c20', 37 | String.Regex: '#1c7e71', 38 | 39 | Number: '#B452CD', 40 | 41 | Operator.Word: '#8B008B', 42 | 43 | Keyword: '#8B008B bold', 44 | Keyword.Type: '#a7a7a7', 45 | 46 | Name.Class: '#008b45 bold', 47 | Name.Exception: '#008b45 bold', 48 | Name.Function: '#008b45', 49 | Name.Namespace: '#008b45 underline', 50 | Name.Variable: '#00688B', 51 | Name.Constant: '#00688B', 52 | Name.Decorator: '#707a7c', 53 | Name.Tag: '#8B008B bold', 54 | Name.Attribute: '#658b00', 55 | Name.Builtin: '#658b00', 56 | 57 | Generic.Heading: 'bold #000080', 58 | Generic.Subheading: 'bold #800080', 59 | Generic.Deleted: '#aa0000', 60 | Generic.Inserted: '#00aa00', 61 | Generic.Error: '#aa0000', 62 | Generic.Emph: 'italic', 63 | Generic.Strong: 'bold', 64 | Generic.Prompt: '#555555', 65 | Generic.Output: '#888888', 66 | Generic.Traceback: '#aa0000', 67 | 68 | Error: 'bg:#e3d2d2 #a61717' 69 | } 70 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/rrt.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.rrt 4 | ~~~~~~~~~~~~~~~~~~~ 5 | 6 | pygments "rrt" theme, based on Zap and Emacs defaults. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Comment, Name, Keyword, String 14 | 15 | 16 | class RrtStyle(Style): 17 | """ 18 | Minimalistic "rrt" theme, based on Zap and Emacs defaults. 19 | """ 20 | 21 | background_color = '#000000' 22 | highlight_color = '#0000ff' 23 | 24 | styles = { 25 | Comment: '#00ff00', 26 | Name.Function: '#ffff00', 27 | Name.Variable: '#eedd82', 28 | Name.Constant: '#7fffd4', 29 | Keyword: '#ff0000', 30 | Comment.Preproc: '#e5e5e5', 31 | String: '#87ceeb', 32 | Keyword.Type: '#ee82ee', 33 | } 34 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/tango.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.tango 4 | ~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | The Crunchy default Style inspired from the color palette from 7 | the Tango Icon Theme Guidelines. 8 | 9 | http://tango.freedesktop.org/Tango_Icon_Theme_Guidelines 10 | 11 | Butter: #fce94f #edd400 #c4a000 12 | Orange: #fcaf3e #f57900 #ce5c00 13 | Chocolate: #e9b96e #c17d11 #8f5902 14 | Chameleon: #8ae234 #73d216 #4e9a06 15 | Sky Blue: #729fcf #3465a4 #204a87 16 | Plum: #ad7fa8 #75507b #5c35cc 17 | Scarlet Red:#ef2929 #cc0000 #a40000 18 | Aluminium: #eeeeec #d3d7cf #babdb6 19 | #888a85 #555753 #2e3436 20 | 21 | Not all of the above colors are used; other colors added: 22 | very light grey: #f8f8f8 (for background) 23 | 24 | This style can be used as a template as it includes all the known 25 | Token types, unlike most (if not all) of the styles included in the 26 | Pygments distribution. 27 | 28 | However, since Crunchy is intended to be used by beginners, we have strived 29 | to create a style that gloss over subtle distinctions between different 30 | categories. 31 | 32 | Taking Python for example, comments (Comment.*) and docstrings (String.Doc) 33 | have been chosen to have the same style. Similarly, keywords (Keyword.*), 34 | and Operator.Word (and, or, in) have been assigned the same style. 35 | 36 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 37 | :license: BSD, see LICENSE for details. 38 | """ 39 | 40 | from pygments.style import Style 41 | from pygments.token import Keyword, Name, Comment, String, Error, \ 42 | Number, Operator, Generic, Whitespace, Punctuation, Other, Literal 43 | 44 | 45 | class TangoStyle(Style): 46 | """ 47 | The Crunchy default Style inspired from the color palette from 48 | the Tango Icon Theme Guidelines. 49 | """ 50 | 51 | # work in progress... 52 | 53 | background_color = "#f8f8f8" 54 | default_style = "" 55 | 56 | styles = { 57 | # No corresponding class for the following: 58 | #Text: "", # class: '' 59 | Whitespace: "underline #f8f8f8", # class: 'w' 60 | Error: "#a40000 border:#ef2929", # class: 'err' 61 | Other: "#000000", # class 'x' 62 | 63 | Comment: "italic #8f5902", # class: 'c' 64 | Comment.Multiline: "italic #8f5902", # class: 'cm' 65 | Comment.Preproc: "italic #8f5902", # class: 'cp' 66 | Comment.Single: "italic #8f5902", # class: 'c1' 67 | Comment.Special: "italic #8f5902", # class: 'cs' 68 | 69 | Keyword: "bold #204a87", # class: 'k' 70 | Keyword.Constant: "bold #204a87", # class: 'kc' 71 | Keyword.Declaration: "bold #204a87", # class: 'kd' 72 | Keyword.Namespace: "bold #204a87", # class: 'kn' 73 | Keyword.Pseudo: "bold #204a87", # class: 'kp' 74 | Keyword.Reserved: "bold #204a87", # class: 'kr' 75 | Keyword.Type: "bold #204a87", # class: 'kt' 76 | 77 | Operator: "bold #ce5c00", # class: 'o' 78 | Operator.Word: "bold #204a87", # class: 'ow' - like keywords 79 | 80 | Punctuation: "bold #000000", # class: 'p' 81 | 82 | # because special names such as Name.Class, Name.Function, etc. 83 | # are not recognized as such later in the parsing, we choose them 84 | # to look the same as ordinary variables. 85 | Name: "#000000", # class: 'n' 86 | Name.Attribute: "#c4a000", # class: 'na' - to be revised 87 | Name.Builtin: "#204a87", # class: 'nb' 88 | Name.Builtin.Pseudo: "#3465a4", # class: 'bp' 89 | Name.Class: "#000000", # class: 'nc' - to be revised 90 | Name.Constant: "#000000", # class: 'no' - to be revised 91 | Name.Decorator: "bold #5c35cc", # class: 'nd' - to be revised 92 | Name.Entity: "#ce5c00", # class: 'ni' 93 | Name.Exception: "bold #cc0000", # class: 'ne' 94 | Name.Function: "#000000", # class: 'nf' 95 | Name.Property: "#000000", # class: 'py' 96 | Name.Label: "#f57900", # class: 'nl' 97 | Name.Namespace: "#000000", # class: 'nn' - to be revised 98 | Name.Other: "#000000", # class: 'nx' 99 | Name.Tag: "bold #204a87", # class: 'nt' - like a keyword 100 | Name.Variable: "#000000", # class: 'nv' - to be revised 101 | Name.Variable.Class: "#000000", # class: 'vc' - to be revised 102 | Name.Variable.Global: "#000000", # class: 'vg' - to be revised 103 | Name.Variable.Instance: "#000000", # class: 'vi' - to be revised 104 | 105 | # since the tango light blue does not show up well in text, we choose 106 | # a pure blue instead. 107 | Number: "bold #0000cf", # class: 'm' 108 | Number.Float: "bold #0000cf", # class: 'mf' 109 | Number.Hex: "bold #0000cf", # class: 'mh' 110 | Number.Integer: "bold #0000cf", # class: 'mi' 111 | Number.Integer.Long: "bold #0000cf", # class: 'il' 112 | Number.Oct: "bold #0000cf", # class: 'mo' 113 | 114 | Literal: "#000000", # class: 'l' 115 | Literal.Date: "#000000", # class: 'ld' 116 | 117 | String: "#4e9a06", # class: 's' 118 | String.Backtick: "#4e9a06", # class: 'sb' 119 | String.Char: "#4e9a06", # class: 'sc' 120 | String.Doc: "italic #8f5902", # class: 'sd' - like a comment 121 | String.Double: "#4e9a06", # class: 's2' 122 | String.Escape: "#4e9a06", # class: 'se' 123 | String.Heredoc: "#4e9a06", # class: 'sh' 124 | String.Interpol: "#4e9a06", # class: 'si' 125 | String.Other: "#4e9a06", # class: 'sx' 126 | String.Regex: "#4e9a06", # class: 'sr' 127 | String.Single: "#4e9a06", # class: 's1' 128 | String.Symbol: "#4e9a06", # class: 'ss' 129 | 130 | Generic: "#000000", # class: 'g' 131 | Generic.Deleted: "#a40000", # class: 'gd' 132 | Generic.Emph: "italic #000000", # class: 'ge' 133 | Generic.Error: "#ef2929", # class: 'gr' 134 | Generic.Heading: "bold #000080", # class: 'gh' 135 | Generic.Inserted: "#00A000", # class: 'gi' 136 | Generic.Output: "italic #000000", # class: 'go' 137 | Generic.Prompt: "#8f5902", # class: 'gp' 138 | Generic.Strong: "bold #000000", # class: 'gs' 139 | Generic.Subheading: "bold #800080", # class: 'gu' 140 | Generic.Traceback: "bold #a40000", # class: 'gt' 141 | } 142 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/trac.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.trac 4 | ~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Port of the default trac highlighter design. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Whitespace 15 | 16 | 17 | class TracStyle(Style): 18 | """ 19 | Port of the default trac highlighter design. 20 | """ 21 | 22 | default_style = '' 23 | 24 | styles = { 25 | Whitespace: '#bbbbbb', 26 | Comment: 'italic #999988', 27 | Comment.Preproc: 'bold noitalic #999999', 28 | Comment.Special: 'bold #999999', 29 | 30 | Operator: 'bold', 31 | 32 | String: '#bb8844', 33 | String.Regex: '#808000', 34 | 35 | Number: '#009999', 36 | 37 | Keyword: 'bold', 38 | Keyword.Type: '#445588', 39 | 40 | Name.Builtin: '#999999', 41 | Name.Function: 'bold #990000', 42 | Name.Class: 'bold #445588', 43 | Name.Exception: 'bold #990000', 44 | Name.Namespace: '#555555', 45 | Name.Variable: '#008080', 46 | Name.Constant: '#008080', 47 | Name.Tag: '#000080', 48 | Name.Attribute: '#008080', 49 | Name.Entity: '#800080', 50 | 51 | Generic.Heading: '#999999', 52 | Generic.Subheading: '#aaaaaa', 53 | Generic.Deleted: 'bg:#ffdddd #000000', 54 | Generic.Inserted: 'bg:#ddffdd #000000', 55 | Generic.Error: '#aa0000', 56 | Generic.Emph: 'italic', 57 | Generic.Strong: 'bold', 58 | Generic.Prompt: '#555555', 59 | Generic.Output: '#888888', 60 | Generic.Traceback: '#aa0000', 61 | 62 | Error: 'bg:#e3d2d2 #a61717' 63 | } 64 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/vim.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.vim 4 | ~~~~~~~~~~~~~~~~~~~ 5 | 6 | A highlighting style for Pygments, inspired by vim. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Generic, Whitespace, Token 15 | 16 | 17 | class VimStyle(Style): 18 | """ 19 | Styles somewhat like vim 7.0 20 | """ 21 | 22 | background_color = "#000000" 23 | highlight_color = "#222222" 24 | default_style = "#cccccc" 25 | 26 | styles = { 27 | Token: "#cccccc", 28 | Whitespace: "", 29 | Comment: "#000080", 30 | Comment.Preproc: "", 31 | Comment.Special: "bold #cd0000", 32 | 33 | Keyword: "#cdcd00", 34 | Keyword.Declaration: "#00cd00", 35 | Keyword.Namespace: "#cd00cd", 36 | Keyword.Pseudo: "", 37 | Keyword.Type: "#00cd00", 38 | 39 | Operator: "#3399cc", 40 | Operator.Word: "#cdcd00", 41 | 42 | Name: "", 43 | Name.Class: "#00cdcd", 44 | Name.Builtin: "#cd00cd", 45 | Name.Exception: "bold #666699", 46 | Name.Variable: "#00cdcd", 47 | 48 | String: "#cd0000", 49 | Number: "#cd00cd", 50 | 51 | Generic.Heading: "bold #000080", 52 | Generic.Subheading: "bold #800080", 53 | Generic.Deleted: "#cd0000", 54 | Generic.Inserted: "#00cd00", 55 | Generic.Error: "#FF0000", 56 | Generic.Emph: "italic", 57 | Generic.Strong: "bold", 58 | Generic.Prompt: "bold #000080", 59 | Generic.Output: "#888", 60 | Generic.Traceback: "#04D", 61 | 62 | Error: "border:#FF0000" 63 | } 64 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/vs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.vs 4 | ~~~~~~~~~~~~~~~~~~ 5 | 6 | Simple style with MS Visual Studio colors. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Operator, Generic 15 | 16 | 17 | class VisualStudioStyle(Style): 18 | 19 | background_color = "#ffffff" 20 | default_style = "" 21 | 22 | styles = { 23 | Comment: "#008000", 24 | Comment.Preproc: "#0000ff", 25 | Keyword: "#0000ff", 26 | Operator.Word: "#0000ff", 27 | Keyword.Type: "#2b91af", 28 | Name.Class: "#2b91af", 29 | String: "#a31515", 30 | 31 | Generic.Heading: "bold", 32 | Generic.Subheading: "bold", 33 | Generic.Emph: "italic", 34 | Generic.Strong: "bold", 35 | Generic.Prompt: "bold", 36 | 37 | Error: "border:#FF0000" 38 | } 39 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/styles/xcode.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.xcode 4 | ~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Style similar to the `Xcode` default theme. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Number, Operator, Literal 15 | 16 | 17 | class XcodeStyle(Style): 18 | """ 19 | Style similar to the Xcode default colouring theme. 20 | """ 21 | 22 | default_style = '' 23 | 24 | styles = { 25 | Comment: '#177500', 26 | Comment.Preproc: '#633820', 27 | 28 | String: '#C41A16', 29 | String.Char: '#2300CE', 30 | 31 | Operator: '#000000', 32 | 33 | Keyword: '#A90D91', 34 | 35 | Name: '#000000', 36 | Name.Attribute: '#836C28', 37 | Name.Class: '#3F6E75', 38 | Name.Function: '#000000', 39 | Name.Builtin: '#A90D91', 40 | # In Obj-C code this token is used to colour Cocoa types 41 | Name.Builtin.Pseudo: '#5B269A', 42 | Name.Variable: '#000000', 43 | Name.Tag: '#000000', 44 | Name.Decorator: '#000000', 45 | # Workaround for a BUG here: lexer treats multiline method signatres as labels 46 | Name.Label: '#000000', 47 | 48 | Literal: '#1C01CE', 49 | Number: '#1C01CE', 50 | Error: '#000000', 51 | } 52 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/pygments/token.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.token 4 | ~~~~~~~~~~~~~~ 5 | 6 | Basic token types and the standard tokens. 7 | 8 | :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | class _TokenType(tuple): 13 | parent = None 14 | 15 | def split(self): 16 | buf = [] 17 | node = self 18 | while node is not None: 19 | buf.append(node) 20 | node = node.parent 21 | buf.reverse() 22 | return buf 23 | 24 | def __init__(self, *args): 25 | # no need to call super.__init__ 26 | self.subtypes = set() 27 | 28 | def __contains__(self, val): 29 | return self is val or ( 30 | type(val) is self.__class__ and 31 | val[:len(self)] == self 32 | ) 33 | 34 | def __getattr__(self, val): 35 | if not val or not val[0].isupper(): 36 | return tuple.__getattribute__(self, val) 37 | new = _TokenType(self + (val,)) 38 | setattr(self, val, new) 39 | self.subtypes.add(new) 40 | new.parent = self 41 | return new 42 | 43 | def __repr__(self): 44 | return 'Token' + (self and '.' or '') + '.'.join(self) 45 | 46 | 47 | Token = _TokenType() 48 | 49 | # Special token types 50 | Text = Token.Text 51 | Whitespace = Text.Whitespace 52 | Escape = Token.Escape 53 | Error = Token.Error 54 | # Text that doesn't belong to this lexer (e.g. HTML in PHP) 55 | Other = Token.Other 56 | 57 | # Common token types for source code 58 | Keyword = Token.Keyword 59 | Name = Token.Name 60 | Literal = Token.Literal 61 | String = Literal.String 62 | Number = Literal.Number 63 | Punctuation = Token.Punctuation 64 | Operator = Token.Operator 65 | Comment = Token.Comment 66 | 67 | # Generic types for non-source code 68 | Generic = Token.Generic 69 | 70 | # String and some others are not direct childs of Token. 71 | # alias them: 72 | Token.Token = Token 73 | Token.String = String 74 | Token.Number = Number 75 | 76 | 77 | def is_token_subtype(ttype, other): 78 | """ 79 | Return True if ``ttype`` is a subtype of ``other``. 80 | 81 | exists for backwards compatibility. use ``ttype in other`` now. 82 | """ 83 | return ttype in other 84 | 85 | 86 | def string_to_tokentype(s): 87 | """ 88 | Convert a string into a token type:: 89 | 90 | >>> string_to_token('String.Double') 91 | Token.Literal.String.Double 92 | >>> string_to_token('Token.Literal.Number') 93 | Token.Literal.Number 94 | >>> string_to_token('') 95 | Token 96 | 97 | Tokens that are already tokens are returned unchanged: 98 | 99 | >>> string_to_token(String) 100 | Token.Literal.String 101 | """ 102 | if isinstance(s, _TokenType): 103 | return s 104 | if not s: 105 | return Token 106 | node = Token 107 | for item in s.split('.'): 108 | node = getattr(node, item) 109 | return node 110 | 111 | 112 | # Map standard token types to short names, used in CSS class naming. 113 | # If you add a new item, please be sure to run this file to perform 114 | # a consistency check for duplicate values. 115 | STANDARD_TYPES = { 116 | Token: '', 117 | 118 | Text: '', 119 | Whitespace: 'w', 120 | Escape: 'esc', 121 | Error: 'err', 122 | Other: 'x', 123 | 124 | Keyword: 'k', 125 | Keyword.Constant: 'kc', 126 | Keyword.Declaration: 'kd', 127 | Keyword.Namespace: 'kn', 128 | Keyword.Pseudo: 'kp', 129 | Keyword.Reserved: 'kr', 130 | Keyword.Type: 'kt', 131 | 132 | Name: 'n', 133 | Name.Attribute: 'na', 134 | Name.Builtin: 'nb', 135 | Name.Builtin.Pseudo: 'bp', 136 | Name.Class: 'nc', 137 | Name.Constant: 'no', 138 | Name.Decorator: 'nd', 139 | Name.Entity: 'ni', 140 | Name.Exception: 'ne', 141 | Name.Function: 'nf', 142 | Name.Property: 'py', 143 | Name.Label: 'nl', 144 | Name.Namespace: 'nn', 145 | Name.Other: 'nx', 146 | Name.Tag: 'nt', 147 | Name.Variable: 'nv', 148 | Name.Variable.Class: 'vc', 149 | Name.Variable.Global: 'vg', 150 | Name.Variable.Instance: 'vi', 151 | 152 | Literal: 'l', 153 | Literal.Date: 'ld', 154 | 155 | String: 's', 156 | String.Backtick: 'sb', 157 | String.Char: 'sc', 158 | String.Doc: 'sd', 159 | String.Double: 's2', 160 | String.Escape: 'se', 161 | String.Heredoc: 'sh', 162 | String.Interpol: 'si', 163 | String.Other: 'sx', 164 | String.Regex: 'sr', 165 | String.Single: 's1', 166 | String.Symbol: 'ss', 167 | 168 | Number: 'm', 169 | Number.Bin: 'mb', 170 | Number.Float: 'mf', 171 | Number.Hex: 'mh', 172 | Number.Integer: 'mi', 173 | Number.Integer.Long: 'il', 174 | Number.Oct: 'mo', 175 | 176 | Operator: 'o', 177 | Operator.Word: 'ow', 178 | 179 | Punctuation: 'p', 180 | 181 | Comment: 'c', 182 | Comment.Multiline: 'cm', 183 | Comment.Preproc: 'cp', 184 | Comment.Single: 'c1', 185 | Comment.Special: 'cs', 186 | 187 | Generic: 'g', 188 | Generic.Deleted: 'gd', 189 | Generic.Emph: 'ge', 190 | Generic.Error: 'gr', 191 | Generic.Heading: 'gh', 192 | Generic.Inserted: 'gi', 193 | Generic.Output: 'go', 194 | Generic.Prompt: 'gp', 195 | Generic.Strong: 'gs', 196 | Generic.Subheading: 'gu', 197 | Generic.Traceback: 'gt', 198 | } 199 | -------------------------------------------------------------------------------- /DrawBot.glyphsPlugin/Contents/Resources/xmlWriter.py: -------------------------------------------------------------------------------- 1 | """xmlWriter.py -- Simple XML authoring class""" 2 | 3 | import string 4 | import struct 5 | import os 6 | 7 | INDENT = " " 8 | 9 | 10 | class XMLWriter: 11 | 12 | def __init__(self, fileOrPath, indentwhite=INDENT, idlefunc=None, encoding="ISO-8859-1"): 13 | if not hasattr(fileOrPath, "write"): 14 | self.file = open(fileOrPath, "w") 15 | else: 16 | # assume writable file object 17 | self.file = fileOrPath 18 | self.indentwhite = indentwhite 19 | self.indentlevel = 0 20 | self.stack = [] 21 | self.needindent = 1 22 | self.idlefunc = idlefunc 23 | self.idlecounter = 0 24 | if encoding: 25 | self.writeraw('' % encoding) 26 | else: 27 | self.writeraw('') 28 | self.newline() 29 | 30 | def close(self): 31 | self.file.close() 32 | 33 | def write(self, data): 34 | self.writeraw(escape(data)) 35 | 36 | def write_noindent(self, data): 37 | self.file.write(escape(data)) 38 | 39 | def write8bit(self, data): 40 | self.writeraw(escape8bit(data)) 41 | 42 | def write16bit(self, data): 43 | self.writeraw(escape16bit(data)) 44 | 45 | def writeraw(self, data): 46 | if self.needindent: 47 | self.file.write(self.indentlevel * self.indentwhite) 48 | self.needindent = 0 49 | self.file.write(data) 50 | 51 | def newline(self): 52 | self.file.write("\n") 53 | self.needindent = 1 54 | idlecounter = self.idlecounter 55 | if not idlecounter % 100 and self.idlefunc is not None: 56 | self.idlefunc() 57 | self.idlecounter = idlecounter + 1 58 | 59 | def comment(self, data): 60 | data = escape(data) 61 | lines = string.split(data, "\n") 62 | self.writeraw("") 67 | 68 | def simpletag(self, _TAG_, *args, **kwargs): 69 | attrdata = apply(self.stringifyattrs, args, kwargs) 70 | data = "<%s%s/>" % (_TAG_, attrdata) 71 | self.writeraw(data) 72 | 73 | def begintag(self, _TAG_, *args, **kwargs): 74 | attrdata = apply(self.stringifyattrs, args, kwargs) 75 | data = "<%s%s>" % (_TAG_, attrdata) 76 | self.writeraw(data) 77 | self.stack.append(_TAG_) 78 | self.indent() 79 | 80 | def endtag(self, _TAG_): 81 | assert self.stack and self.stack[-1] == _TAG_, "nonmatching endtag" 82 | del self.stack[-1] 83 | self.dedent() 84 | data = "" % _TAG_ 85 | self.writeraw(data) 86 | 87 | def dumphex(self, data): 88 | linelength = 16 89 | hexlinelength = linelength * 2 90 | chunksize = 8 91 | for i in range(0, len(data), linelength): 92 | hexline = hexStr(data[i:i+linelength]) 93 | line = "" 94 | white = "" 95 | for j in range(0, hexlinelength, chunksize): 96 | line = line + white + hexline[j:j+chunksize] 97 | white = " " 98 | self.writeraw(line) 99 | self.newline() 100 | 101 | def indent(self): 102 | self.indentlevel = self.indentlevel + 1 103 | 104 | def dedent(self): 105 | assert self.indentlevel > 0 106 | self.indentlevel = self.indentlevel - 1 107 | 108 | def stringifyattrs(self, *args, **kwargs): 109 | if kwargs: 110 | assert not args 111 | attributes = kwargs.items() 112 | attributes.sort() 113 | elif args: 114 | assert len(args) == 1 115 | attributes = args[0] 116 | else: 117 | return "" 118 | data = "" 119 | for attr, value in attributes: 120 | data = data + ' %s="%s"' % (attr, escapeattr(str(value))) 121 | return data 122 | 123 | 124 | def escape(data): 125 | data = string.replace(data, "&", "&") 126 | data = string.replace(data, "<", "<") 127 | return data 128 | 129 | def escapeattr(data): 130 | data = string.replace(data, "&", "&") 131 | data = string.replace(data, "<", "<") 132 | data = string.replace(data, '"', """) 133 | return data 134 | 135 | def escape8bit(data): 136 | def escapechar(c): 137 | n = ord(c) 138 | if c in "<&": 139 | if c == "&": 140 | return "&" 141 | else: 142 | return "<" 143 | elif 32 <= n <= 127: 144 | return c 145 | else: 146 | return "&#" + `n` + ";" 147 | return string.join(map(escapechar, data), "") 148 | 149 | needswap = struct.pack("h", 1) == "\001\000" 150 | 151 | def escape16bit(data): 152 | import array 153 | a = array.array("H") 154 | a.fromstring(data) 155 | if needswap: 156 | a.byteswap() 157 | def escapenum(n, amp=ord("&"), lt=ord("<")): 158 | if n == amp: 159 | return "&" 160 | elif n == lt: 161 | return "<" 162 | elif 32 <= n <= 127: 163 | return chr(n) 164 | else: 165 | return "&#" + `n` + ";" 166 | return string.join(map(escapenum, a), "") 167 | 168 | 169 | def hexStr(s): 170 | h = string.hexdigits 171 | r = '' 172 | for c in s: 173 | i = ord(c) 174 | r = r + h[(i >> 4) & 0xF] + h[i & 0xF] 175 | return r 176 | 177 | -------------------------------------------------------------------------------- /GlyphsLogoDrawBot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schriftgestalt/DrawBotGlyphsPlugin/ed0f9f104be6d76d2be06d1bf933181782597492/GlyphsLogoDrawBot.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DrawBot Glyphs Plugin 2 | 3 | [DrawBot](http://drawbot.readthedocs.org/) inside [Glyphs](http://glyphsapp.com). 4 | 5 | ![GlyphsLogoDrawBot](GlyphsLogoDrawBot.png) 6 | 7 | Make a new drawBot from the File menu > New DrawBot, or open a file with cmd+O. Save or Save As as usual. Run the script by hitting the Run button (or pressing cmd+⏎). Clean the output area by pressing cmd+K. 8 | 9 | To save a drawing as pdf, hit cmd+E (or File > Export..) 10 | 11 | ## Installation and requirements 12 | 13 | To install, double click the `DrawBot.glyphsPlugin` file. It requires at least Glyphs 2.1.1 (777). 14 | 15 | The plugin needs these packages. They can be installed from within Glyphs in Preferences > Addons. 16 | * [vanilla](https://github.com/typesupply/vanilla) 17 | * [robofab](https://github.com/robofab-developers/robofab) 18 | * [fontTools](http://sourceforge.net/projects/fonttools/) 19 | 20 | ### Includes 21 | * [DrawBot](http://drawbot.readthedocs.org/) 22 | * [pygments](http://pygments.org) 23 | 24 | ## Many thanks to: 25 | - Just van Rossum, Erik van Blokland, Frederik Berlaen for making DrawBot. 26 | - [Jens Kutilek](http://www.kutilek.de) for helping with implementing the plugin. 27 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | The BSD License 2 | 3 | For the Plugin 4 | Copyright (c) 2015 Georg Seifert, Jens Kutilek 5 | 6 | For DrawBot 7 | Copyright (c) 2003-2015 Just van Rossum, Erik van Blokland, Frederik Berlaen 8 | 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 12 | 13 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 14 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------