(self, wrap=False)
Draws the text in the current bounding box of the drawer.

        Since the class itself is an instance of `AbstractCairoDrawer`, it
        has an attribute named ``bbox`` which will be used as a bounding
        box.

        @param wrap: whether to allow re-wrapping of the text if it does not
            fit within the bounding box horizontally.
Draws the text in the current bounding box of the drawer.
Draws the text in the current bounding box of the drawer .
def draw(self, wrap=False):
        """Draws the text in the current bounding box of the drawer.

        Since the class itself is an instance of `AbstractCairoDrawer`, it
        has an attribute named ``bbox`` which will be used as a bounding
        box.

        @param wrap: whether to allow re-wrapping of the text if it does not
            fit within the bounding box horizontally.
        """
        ctx = self.context
        bbox = self.bbox

        text_layout = self.get_text_layout(bbox.left, bbox.top, bbox.width, wrap)
        if not text_layout:
            return

        _, font_descent, line_height = ctx.font_extents()[:3]
        yb = ctx.text_extents(text_layout[0][2])[1]
        total_height = len(text_layout) * line_height

        if self.valign == self.BOTTOM:
            # Bottom vertical alignment
            dy = bbox.height - total_height - yb + font_descent
        elif self.valign == self.CENTER:
            # Centered vertical alignment
            dy = (bbox.height - total_height - yb + font_descent + line_height) / 2.0
        else:
            # Top vertical alignment
            dy = line_height

        for ref_x, ref_y, line in text_layout:
            ctx.move_to(ref_x, ref_y + dy)
            ctx.show_text(line)
        ctx.new_path()
def draw ( self , wrap = False ) : ctx = self . context bbox = self . bbox text_layout = self . get_text_layout ( bbox . left , bbox . top , bbox . width , wrap ) if not text_layout : return _ , font_descent , line_height = ctx . font_extents ( ) [ : 3 ] yb = ctx . text_extents ( text_layout [ 0 ] [ 2 ] ) [ 1 ] total_height = len ( text_layout ) * line_height if self . valign == self . BOTTOM : # Bottom vertical alignment dy = bbox . height - total_height - yb + font_descent elif self . valign == self . CENTER : # Centered vertical alignment dy = ( bbox . height - total_height - yb + font_descent + line_height ) / 2.0 else : # Top vertical alignment dy = line_height for ref_x , ref_y , line in text_layout : ctx . move_to ( ref_x , ref_y + dy ) ctx . show_text ( line ) ctx . new_path ( )