Example #1
0
File: caw.py Project: Roger/caw
    def draw_text(self, text, fg=None, x=None, width=None, align=0, ellipsize=3):
        if fg is None:
            fg = self.fg

        r,g,b = self.rgb(fg)

        cawc.cairo_set_source_rgb(self.cairo_c, r, g, b);

        y = (self.height - self._font_height)/2 + self.font_yoffset
        if x is None:
            x = self._pangox
        else:
            self._pangox = x

        cawc.cairo_move_to(self.cairo_c, x, y)

        if width is not None and width > 0:
            cawc.pango_layout_set_text(self.layout_c, text, width, align, ellipsize)
        else:
            cawc.pango_layout_set_text(self.layout_c, text)

        cawc.pango_cairo_update_show_layout(self.cairo_c, self.layout_c)
        self._pangox += self.text_width(text)
Example #2
0
File: caw.py Project: Roger/caw
 def text_width(self, text):
     cawc.pango_layout_set_text(self.layout_c, text)
     width, _ = cawc.pango_layout_get_pixel_size(self.layout_c)
     return width