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()
예제 #2
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 _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 _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()
예제 #5
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
예제 #6
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