(self, x=None, y=None, width=None, wrap=False)
return result
Calculates the layout of the current text. `x` and `y` denote the
        coordinates where the drawing should start. If they are both ``None``,
        the current position of the context will be used.

        Vertical alignment settings are not taken into account in this method
        as the text is not drawn within a box.

        @param x: The X coordinate of the reference point where the layout should
            start.
        @param y: The Y coordinate of the reference point where the layout should
            start.
        @param width: The width of the box in which the text will be fitted. It
            matters only when the text is right-aligned or centered. The text
            will overflow the box if any of the lines is longer than the box
            width and `wrap` is ``False``.
        @param wrap: whether to allow re-wrapping of the text if it does not
            fit within the given width.

        @return: a list consisting of ``(x, y, line)`` tuples where ``x`` and
            ``y`` refer to reference points on the Cairo canvas and ``line``
            refers to the corresponding text that should be plotted there.
Calculates the layout of the current text. `x` and `y` denote the
        coordinates where the drawing should start. If they are both ``None``,
        the current position of the context will be used.
Calculates the layout of the current text . x and y denote the coordinates where the drawing should start . If they are both None the current position of the context will be used .
def get_text_layout(self, x=None, y=None, width=None, wrap=False):
        """Calculates the layout of the current text. `x` and `y` denote the
        coordinates where the drawing should start. If they are both ``None``,
        the current position of the context will be used.

        Vertical alignment settings are not taken into account in this method
        as the text is not drawn within a box.

        @param x: The X coordinate of the reference point where the layout should
            start.
        @param y: The Y coordinate of the reference point where the layout should
            start.
        @param width: The width of the box in which the text will be fitted. It
            matters only when the text is right-aligned or centered. The text
            will overflow the box if any of the lines is longer than the box
            width and `wrap` is ``False``.
        @param wrap: whether to allow re-wrapping of the text if it does not
            fit within the given width.

        @return: a list consisting of ``(x, y, line)`` tuples where ``x`` and
            ``y`` refer to reference points on the Cairo canvas and ``line``
            refers to the corresponding text that should be plotted there.
        """
        ctx = self.context

        if x is None or y is None:
            x, y = ctx.get_current_point()

        line_height = ctx.font_extents()[2]

        if wrap and width and width > 0:
            iterlines = self._iterlines_wrapped(width)
        elif wrap:
            warn("ignoring wrap=True as no width was specified")
            iterlines = self._iterlines()
        else:
            iterlines = self._iterlines()

        result = []

        if self.halign == self.CENTER:
            # Centered alignment
            if width is None:
                width = self.text_extents()[2]
            for line, line_width, x_bearing in iterlines:
                result.append((x + (width - line_width) / 2.0 - x_bearing, y, line))
                y += line_height

        elif self.halign == self.RIGHT:
            # Right alignment
            if width is None:
                width = self.text_extents()[2]
            x += width
            for line, line_width, x_bearing in iterlines:
                result.append((x - line_width - x_bearing, y, line))
                y += line_height

        else:
            # Left alignment
            for line, _, x_bearing in iterlines:
                result.append((x - x_bearing, y, line))
                y += line_height

        return result
def get_text_layout ( self , x = None , y = None , width = None , wrap = False ) : ctx = self . context if x is None or y is None : x , y = ctx . get_current_point ( ) line_height = ctx . font_extents ( ) [ 2 ] if wrap and width and width > 0 : iterlines = self . _iterlines_wrapped ( width ) elif wrap : warn ( "ignoring wrap=True as no width was specified" ) iterlines = self . _iterlines ( ) else : iterlines = self . _iterlines ( ) result = [ ] if self . halign == self . CENTER : # Centered alignment if width is None : width = self . text_extents ( ) [ 2 ] for line , line_width , x_bearing in iterlines : result . append ( ( x + ( width - line_width ) / 2.0 - x_bearing , y , line ) ) y += line_height elif self . halign == self . RIGHT : # Right alignment if width is None : width = self . text_extents ( ) [ 2 ] x += width for line , line_width , x_bearing in iterlines : result . append ( ( x - line_width - x_bearing , y , line ) ) y += line_height else : # Left alignment for line , _ , x_bearing in iterlines : result . append ( ( x - x_bearing , y , line ) ) y += line_height return result