def _addGlyphName(self, sender):
     glyphName = sender.get()
     if glyphName in RamsayStData.keys():
         index = 0
         for item in self.w.dataList:
             if glyphName == item.glyphName():
                 break
             index += 1
         self.w.dataList.setSelection([index])
         return
     self.w.dataList.append(RamsayStData.newItem(glyphName))
 def _addGlyphName(self, sender):
     glyphName = sender.get()
     if glyphName in RamsayStData.keys():
         index = 0
         for item in self.w.dataList:
             if glyphName == item.glyphName():
                 break
             index += 1
         self.w.dataList.setSelection([index])
         return
     self.w.dataList.append(RamsayStData.newItem(glyphName))
 def _exportGlyphNames(self, path):
     if path is None:
         return
         
     output = [
         "# Ramsay St. Glyph List",
         "# <glyphName> <leftGlyphName> <rightGlyphGlyphName>"
         ]
     for glyphName in sorted(RamsayStData.keys()):
         value = RamsayStData.get(glyphName, None)
         if value is not None:
             output.append("%s %s %s" % (glyphName, value[0], value[1]))
             
     f = open(path, "w")
     f.write("\n".join(output))
     f.close()
    def _drawNeighborsGlyphs(self, glyph, stroke=True, scale=1):
        if glyph is None:
            return
        font = glyph.getParent()
        baseName = self.getBaseGlyph(glyph.name)
        left, right = RamsayStData.get(baseName, ("n", "n"))

        if left in font:
            leftGlyph = font[left]
            save()
            # translate back the width of the glyph
            translate(-leftGlyph.width, 0)
            # performance tricks, the naked attr will return the defcon object
            # and get the cached bezier path to draw
            path = leftGlyph.naked().getRepresentation("defconAppKit.NSBezierPath")
            # fill the path
            path.fill()
            if stroke:
                path.setLineWidth_(scale)
                strokePixelPath(path)
            restore()

        # do the same for the other glyph
        if right in font:
            rightGlyph = font[right]
            save()
            # translate forward the width of the current glyph
            translate(glyph.width, 0)
            path = rightGlyph.naked().getRepresentation("defconAppKit.NSBezierPath")
            path.fill()
            if stroke:
                path.setLineWidth_(scale)
                strokePixelPath(path)
            restore()
    def __init__(self):
        self.w = vanilla.FloatingWindow((250, 300), "Ramsay St. Settings", minSize=(250, 250), maxSize=(400, 700))
        
        self.w.showPreview = vanilla.CheckBox((10, 10, -10, 22), "Show Preview", value=RamsayStData.showPreview, callback=self.showPreviewCallback)

        self.w.fillColorText = vanilla.TextBox((10, 40, 110, 22), "Fill Color:")
        self.w.fillColor = vanilla.ColorWell((10, 60, 110, 40), color=RamsayStData.fillColor, callback=self.fillColorCallback)
        
        self.w.strokeColorText = vanilla.TextBox((130, 40, -10, 22), "Stroke Color:")
        self.w.strokeColor = vanilla.ColorWell((130, 60, -10, 40), color=RamsayStData.strokeColor, callback=self.strokeColorCallback)
        
        items = RamsayStData.getItems()
        columnDescriptions = [
                              dict(title="Glyph Name", key="glyphName"), 
                              dict(title="Left", key="left"), 
                              dict(title="Right", key="right"),
                              ]
        
        self.w.dataList = vanilla.List((10, 110, -10, -40), items, columnDescriptions=columnDescriptions, editCallback=self.dataListEditCallback)
        
        
        segmentDescriptions = [dict(title="+"), dict(title="-")]    
        self.w.addDel = vanilla.SegmentedButton((12, -30, 60, 20), segmentDescriptions, selectionStyle="momentary", callback=self.addDelCallback)
        self.w.addDel.getNSSegmentedButton().setSegmentStyle_(NSSegmentStyleSmallSquare)
        
        self.w.okButton = vanilla.Button((-70, -30, -15, 20), "Apply", callback=self.okCallback, sizeStyle="small")
        
        self.w.setDefaultButton(self.w.okButton)
        
        self.w.closeButton = vanilla.Button((-140, -30, -80, 20), "Cancel", callback=self.closeCallback, sizeStyle="small")
        self.w.closeButton.bind(".", ["command"])
        self.w.closeButton.bind(unichr(27), [])
        
        self.w.open()
    def _exportGlyphNames(self, path):
        if path is None:
            return

        output = [
            "# Ramsay St. Glyph List",
            "# <glyphName> <leftGlyphName> <rightGlyphGlyphName>"
        ]
        for glyphName in sorted(RamsayStData.keys()):
            value = RamsayStData.get(glyphName, None)
            if value is not None:
                output.append("%s %s %s" % (glyphName, value[0], value[1]))

        f = open(path, "w")
        f.write("\n".join(output))
        f.close()
Ejemplo n.º 7
0
    def _drawNeighborsGlyphs(self, glyph, stroke=True, scale=1):
        if glyph is None:
            return
        font = glyph.font
        baseName = self.getBaseGlyph(glyph.name)
        left, right = RamsayStData.get(baseName, ("n", "n"))

        if left in font:
            leftGlyph = font[left]
            save()
            # translate back the width of the glyph
            translate(-leftGlyph.width, 0)
            # performance tricks, the naked attr will return the defcon object
            # and get the cached bezier path to draw
            path = leftGlyph.naked().getRepresentation("defconAppKit.NSBezierPath")
            # fill the path
            path.fill()
            if stroke:
                path.setLineWidth_(scale)
                strokePixelPath(path)
            restore()

        # do the same for the other glyph
        if right in font:
            rightGlyph = font[right]
            save()
            # translate forward the width of the current glyph
            translate(glyph.width, 0)
            path = rightGlyph.naked().getRepresentation("defconAppKit.NSBezierPath")
            path.fill()
            if stroke:
                path.setLineWidth_(scale)
                strokePixelPath(path)
            restore()
    def __init__(self):
        self.w = vanilla.FloatingWindow((250, 300),
                                        "Ramsay St. Settings",
                                        minSize=(250, 250),
                                        maxSize=(400, 700))

        self.w.showPreview = vanilla.CheckBox(
            (10, 10, -10, 22),
            "Show Preview",
            value=RamsayStData.showPreview,
            callback=self.showPreviewCallback)

        self.w.fillColorText = vanilla.TextBox((10, 40, 110, 22),
                                               "Fill Color:")
        self.w.fillColor = vanilla.ColorWell((10, 60, 110, 40),
                                             color=RamsayStData.fillColor,
                                             callback=self.fillColorCallback)

        self.w.strokeColorText = vanilla.TextBox((130, 40, -10, 22),
                                                 "Stroke Color:")
        self.w.strokeColor = vanilla.ColorWell(
            (130, 60, -10, 40),
            color=RamsayStData.strokeColor,
            callback=self.strokeColorCallback)

        items = RamsayStData.getItems()
        columnDescriptions = [
            dict(title="Glyph Name", key="glyphName"),
            dict(title="Left", key="left"),
            dict(title="Right", key="right"),
        ]

        self.w.dataList = vanilla.List((10, 110, -10, -40),
                                       items,
                                       columnDescriptions=columnDescriptions,
                                       editCallback=self.dataListEditCallback)

        segmentDescriptions = [dict(title="+"), dict(title="-")]
        self.w.addDel = vanilla.SegmentedButton((12, -30, 60, 20),
                                                segmentDescriptions,
                                                selectionStyle="momentary",
                                                callback=self.addDelCallback)
        self.w.addDel.getNSSegmentedButton().setSegmentStyle_(
            NSSegmentStyleSmallSquare)

        self.w.okButton = vanilla.Button((-70, -30, -15, 20),
                                         "Apply",
                                         callback=self.okCallback,
                                         sizeStyle="small")

        self.w.setDefaultButton(self.w.okButton)

        self.w.closeButton = vanilla.Button((-140, -30, -80, 20),
                                            "Cancel",
                                            callback=self.closeCallback,
                                            sizeStyle="small")
        self.w.closeButton.bind(".", ["command"])
        self.w.closeButton.bind(unichr(27), [])

        self.w.open()
 def _importGlyphNames(self, path):
     if path:
         path = path[0]
         f = open(path, "r")
         lines = f.readlines()
         f.close()
         
         data = dict()
         for line in lines:
             if line.startswith("#"):
                 continue
             items = line.split()
             if len(items) != 3:
                 continue                
             glyphName, leftGlyphName, rightGlyphName = items
             data[glyphName] = leftGlyphName, rightGlyphName
         
         RamsayStData.clear()
         RamsayStData.update(data)
         self.w.dataList.set(RamsayStData.getItems())
         self.updateView()
    def _importGlyphNames(self, path):
        if path:
            path = path[0]
            f = open(path, "r")
            lines = f.readlines()
            f.close()

            data = dict()
            for line in lines:
                if line.startswith("#"):
                    continue
                items = line.split()
                if len(items) != 3:
                    continue
                leftGlyphName, glyphName, rightGlyphName = items
                data[glyphName] = leftGlyphName, rightGlyphName

            RamsayStData.clear()
            RamsayStData.update(data)
            self.w.dataList.set(RamsayStData.getItems())
            self.updateView()
Ejemplo n.º 11
0
 def mouseDown(self, info):
     glyph = info["glyph"]
     event = info["event"]
     if event.clickCount() == 3:
         x, y = info["point"]
         font = glyph.getParent()
         baseName = self.getBaseGlyph(glyph.name)
         left, right = RamsayStData.get(baseName, ("n", "n"))
         
         if left in font:
             leftGlyph = font[left]
             path = leftGlyph.naked().getRepresentation("defconAppKit.NSBezierPath")
             if path.containsPoint_((x+leftGlyph.width, y)):
                 SetCurrentGlyphByName(left)
                 return
         if right in font:
             rightGlyph = font[right]
             path = rightGlyph.naked().getRepresentation("defconAppKit.NSBezierPath")
             if path.containsPoint_((x-glyph.width, y)):
                 SetCurrentGlyphByName(right)
                 return
Ejemplo n.º 12
0
    def mouseDown(self, info):
        if not RamsayStData.showPreview:
            return
        glyph = info["glyph"]
        event = info["event"]
        if event.clickCount() == 3:
            x, y = info["point"]
            font = glyph.font
            baseName = self.getBaseGlyph(glyph.name)
            left, right = RamsayStData.get(baseName, ("n", "n"))

            if left in font:
                leftGlyph = font[left]
                path = leftGlyph.naked().getRepresentation("defconAppKit.NSBezierPath")
                if path.containsPoint_((x + leftGlyph.width, y)):
                    SetCurrentGlyphByName(left)
                    return
            if right in font:
                rightGlyph = font[right]
                path = rightGlyph.naked().getRepresentation("defconAppKit.NSBezierPath")
                if path.containsPoint_((x - glyph.width, y)):
                    SetCurrentGlyphByName(right)
                    return
 def dataListEditCallback(self, sender):
     sel = sender.getSelection()
     for i in sel:
         item = sender[i]
         RamsayStData.set(item)
 def okCallback(self, sender):
     RamsayStData.setItems(self.w.dataList)
     RamsayStData.save()
     self.updateView()
 def okCallback(self, sender):
     RamsayStData.setItems(self.w.dataList)
     RamsayStData.save()
     self.updateView()
 def dataListEditCallback(self, sender):
     sel = sender.getSelection()
     for i in sel:
         item = sender[i]
         RamsayStData.set(item)
 def strokeColorCallback(self, sender):
     RamsayStData.strokeColor = sender.get()
     RamsayStData.save()
     self.updateView()
 def showPreviewCallback(self, sender):
     RamsayStData.showPreview = sender.get()
     RamsayStData.save()
     self.updateView()
 def showPreviewCallback(self, sender):
     RamsayStData.showPreview = sender.get()
     RamsayStData.save()
     self.updateView()
 def strokeColorCallback(self, sender):
     RamsayStData.strokeColor = sender.get()
     RamsayStData.save()
     self.updateView()