def __init__(self, drawer, text, colour, font_family, font_size, font_shadow, wrap=True, markup=False): self.drawer, self.colour = drawer, colour layout = drawer.ctx.create_layout() layout.set_alignment(pangocffi.ALIGN_CENTER) if not wrap: # pango wraps by default layout.set_ellipsize(pangocffi.ELLIPSIZE_END) desc = pangocffi.FontDescription.from_string(font_family) desc.set_absolute_size(pangocffi.units_from_double(float(font_size))) layout.set_font_description(desc) self.font_shadow = font_shadow self.layout = layout self.markup = markup self.text = text self._width = None
def width(self, value): self._width = value self.layout.set_width(pangocffi.units_from_double(value))
def font_size(self, size): d = self.fontdescription() d.set_size(size) d.set_absolute_size(pangocffi.units_from_double(size)) self.layout.set_font_description(d)