>>>>> "Jean-Baptiste" == Jean-Baptiste Cazier <[EMAIL PROTECTED]> writes:

    Jean-Baptiste> About a year ago John Hunter proposed a routine to
    Jean-Baptiste> rotate pango text ( draw= _text_rotated)

FYI, there is an updated version of that routine, which I'll post
here.  Not an answer to your question, I know...


    def draw_text_rotated(self, x=50, y=100):
        """
        Draw the text rotated 90 degrees
        """

        gc = self.drawable.new_gc()

        inkRect, logicalRect = self.layout.get_pixel_extents()
        rect = inkRect
        l, b, w, h = rect

        # save the background
        imageBack = self.drawable.get_image(x, y, w, h)
        imageVert = self.drawable.get_image(x, y, h, w)

        # transform the vertical image, write it onto the renderer,
        # and draw the layout onto it
        imageFlip = gtk.gdk.Image(type=gtk.gdk.IMAGE_NORMAL,
                                  visual=self.drawable.get_visual(),
                                  width=w, height=h)
        if imageFlip is None or imageBack is None or imageVert is None:
            print >> sys.stderr, "Could not renderer vertical text", s
            return
        imageFlip.set_colormap(self.drawable.get_colormap())
        for i in range(w):
            for j in range(h):
                imageFlip.put_pixel(i, j, imageVert.get_pixel(j,w-i-1) )

        self.drawable.draw_image(gc, imageFlip, 0, 0, x, y, w, h)
        self.drawable.draw_layout(gc, x, y-b, self.layout)

        # now get that image and flip it vertical
        imageIn = self.drawable.get_image(x, y, w, h)
        imageOut = gtk.gdk.Image(type=gtk.gdk.IMAGE_NORMAL,
                                 visual=self.drawable.get_visual(),
                                 width=h, height=w)
        imageOut.set_colormap(self.drawable.get_colormap())
        for i in range(w):
            for j in range(h):
                imageOut.put_pixel(j, i, imageIn.get_pixel(w-i-1,j) )

        # draw the old background and the flipped text
        self.drawable.draw_image(gc, imageBack, 0, 0, x, y, w, h)
        self.drawable.draw_image(gc, imageOut, 0, 0, x, y, h, w)

        return True
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to