class_docstr: Class that draws text on a Cairo context.
  
  This class supports multi-line text unlike the original Cairo text
  drawing methods.
class_docstr_tok: ["Class","that","draws","text","on","a","Cairo","context",".","This","class","supports","multi-line","text","unlike","the","original","Cairo","text","drawing","methods","."]
docstr: Calculates the layout of the current text. C{x} and C{y} denote the
  coordinates where the drawing should start. If they are both C{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 C{wrap} is C{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 C{(x, y, line)} tuples where C{x} and
      C{y} refer to reference points on the Cairo canvas and C{line}
      refers to the corresponding text that should be plotted there.
docstr_tok: ["Calculates","the","layout","of","the","current","text",".","C","{","x","}","and","C","{","y","}","denote","the","coordinates","where","the","drawing","should","start",".","If","they","are","both","C","{","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","C","{","wrap","}","is","C","{","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","C","{","(","x",",","y",",","line",")","}","tuples","where","C","{","x","}","and","C","{","y","}","refer","to","reference","points","on","the","Cairo","canvas","and","C","{","line","}","refers","to","the","corresponding","text","that","should","be","plotted","there","."]
code: def get_text_layout(self, x=None, y=None, width=None, wrap=False):
      """Calculates the layout of the current text. C{x} and C{y} denote the
      coordinates where the drawing should start. If they are both C{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 C{wrap} is C{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 C{(x, y, line)} tuples where C{x} and
          C{y} refer to reference points on the Cairo canvas and C{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",
              stacklevel=1,
          )
          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
  
file_path: python-igraph/src/igraph/drawing/cairo/text.py
imports: import re
  from warnings import warn
  from igraph.drawing.cairo.base import AbstractCairoDrawer
label_desc: Use image node_id 3 for calling the CairoTextDrawer obj's underlying member method code with example usage: obj.get_text_layout(x, y, width, wrap) and returns: result