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: Draws the text in the current bounding box of the drawer.
  
  Since the class itself is an instance of L{AbstractCairoDrawer}, it
  has an attribute named C{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.
docstr_tok: ["Draws","the","text","in","the","current","bounding","box","of","the","drawer",".","Since","the","class","itself","is","an","instance","of","L","{","AbstractCairoDrawer","}",",","it","has","an","attribute","named","C","{","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","."]
code: def draw(self, wrap=False):
      """Draws the text in the current bounding box of the drawer.
  
      Since the class itself is an instance of L{AbstractCairoDrawer}, it
      has an attribute named C{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()
  
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 2 for calling the CairoTextDrawer obj's underlying member method code with example usage: obj.draw(wrap) without return types