def registerAllFactories(): for name, factory in _factories.items(): addRepresentationFactory(name, factory)
from ufoLib.glifLib import writeGlyphToString, readGlyphFromString else: from robofab.glifLib import writeGlyphToString, readGlyphFromString from defcon.objects.glyph import addRepresentationFactory from lib.scripting.codeEditor import CodeEditor from mojo.roboFont import CurrentGlyph, OpenWindow, RGlyph def PlistFactory(glyph, font): return writeGlyphToString(glyph.name, glyph, glyph.drawPoints) addRepresentationFactory("com.typemytype.GlyphXMLViewer", PlistFactory) class GlyphXMLViewer(BaseWindowController): def __init__(self): self.currentGlyph = None self.w = vanilla.Window((500, 500), "Plist Viewer", minSize=(100, 100)) self.w.xml = CodeEditor((0, 0, -0, -30), "", lexer="xml") self.w.applyButton = vanilla.Button((-70, -25, -20, 22), "Apply", callback=self.applyCallback, sizeStyle="small") addObserver(self, "currentGlyphChanged", "currentGlyphChanged") self.setUpBaseWindowBehavior()
def AddPixelToolRepresentationFactory(): addRepresentationFactory("com.typemytype.pixelImageFactory", imageFactory)
if font is None: font = NSFont.fontWithName_size_("Monaco", 10) attr = { NSParagraphStyleAttributeName : para, NSFontAttributeName : font, NSLigatureAttributeName : 0, } return attr def PlistFactory(glyph, font): return writeGlyphToString(glyph.name, glyph, glyph.drawPoints) addRepresentationFactory("com.typemytype.GlyphXMLViewer", PlistFactory) class GlyphXMLViewer(BaseWindowController): def __init__(self): self.currentGlyph = None self.w = vanilla.Window((500, 500), "Plist Viewer", minSize=(100, 100)) self.w.xml = vanilla.TextEditor((0, 0, -0, -30), "") nsTextView = self.w.xml.getNSTextView() nsTextView.setTypingAttributes_(getXMLTextAttributes()) nsTextView.setRichText_(False) nsTextView.setAllowsUndo_(True) try: nsTextView.setUsesFindBar_(True) except: nsTextView.setUsesFindPanel_(True)
dest = RGlyph() pen.drawPoints(dest.getPointPen()) setGoldGradient(minx, miny, maxx, maxy, 4) drawBot.drawGlyph(dest) pdf = drawBot.pdfImage() page = pdf.pageAtIndex_(0) image = NSImage.alloc().initWithData_(page.dataRepresentation()) return image, (minx-margin, miny-margin) if version >= "3.0": registerRepresentationFactory(Glyph, "money.money.money", GoldFactory) else: addRepresentationFactory("money.money.money", GoldFactory) class GoldMaker(object): def __init__(self): text = "Every thing you space will be gold!" message = "To disable this Goldener extension, simply uninstall it from the preferences and restart." dontShowAgainMessage(text, message, dontShowAgainKey="Goldener.warning") addObserver(self, "goldie", "drawPreview") addObserver(self, "goldie", "spaceCenterDraw") def goldie(self, notification): g = notification["glyph"] result = g.getRepresentation("money.money.money") if result: