Esempio n. 1
0
 def shadow(self, clip=None, radius=10, alpha=0.3, color=Color.from_rgb(0,0,0,1)):
     if clip:
         cp = DATPen(fill=None).rect(clip)
         bp = db.BezierPath()
         cp.replay(bp)
         db.clipPath(bp)
     #elif self.rect:
     #    cp = DATPen(fill=None).rect(self.rect).xor(self.dat)
     #    bp = db.BezierPath()
     #    cp.replay(bp)
     #    db.clipPath(bp)
     db.shadow((0, 0), radius*3, list(color.with_alpha(alpha)))
Esempio n. 2
0
    def scalePenToStyle(self, glyph, in_pen):
        s = self.scale()
        t = Transform()
        try:
            bs = self.style.baselineShift[idx]
        except:
            bs = self.style.baselineShift

        if callable(bs):
            t = t.translate(0, bs(idx))
        else:
            try:
                t = t.translate(0, bs[idx])
            except:
                try:
                    t = t.translate(0, bs)
                except:
                    pass
        t = t.scale(s)
        t = t.translate(glyph.frame.x / self.scale(),
                        glyph.frame.y / self.scale())
        #t = t.translate(0, bs)
        out_pen = DATPen()
        tp = TransformPen(out_pen, (t[0], t[1], t[2], t[3], t[4], t[5]))
        ip = DATPen().record(in_pen)
        if self.style.mods and glyph.name in self.style.mods:
            w, mod = self.style.mods[glyph.name]
            mod(-1, ip)
        ip.replay(tp)
        if self.style.rotate:
            out_pen.rotate(self.style.rotate)

        # TODO this shouldn't be necessary
        if True:
            valid_values = []
            for (move, pts) in out_pen.value:
                if move != "addComponent":
                    valid_values.append((move, pts))
            out_pen.value = valid_values

        return out_pen