code: def measure(self, text, escape = True, max_width = None):
          
  
          if escape:
              text = text.replace ("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
  
          if (max_width, text) in self._measures:
              return self._measures[(max_width, text)]
  
          width, height = None, None
  
          context = self._test_context
  
          layout = self._test_layout
          layout.set_font_description(self.font_desc)
          layout.set_markup(text)
          layout.set_single_paragraph_mode(self.single_paragraph)
  
          if self.alignment:
              layout.set_alignment(self.alignment)
  
          if self.wrap is not None:
              layout.set_wrap(self.wrap)
              layout.set_ellipsize(pango.EllipsizeMode.NONE)
          else:
              layout.set_ellipsize(self.ellipsize or pango.EllipsizeMode.END)
  
          if max_width is not None:
              layout.set_width(max_width * pango.SCALE)
          else:
              if self.max_width:
                  max_width = self.max_width * pango.SCALE
  
              layout.set_width(int(self._bounds_width or max_width or -1))
  
          width, height = layout.get_pixel_size()
  
          self._measures[(max_width, text)] = width, height
          return self._measures[(max_width, text)]
docs: measures given text with label's font and size.
          returns width, height and ascent. Ascent's null in case if the label
          does not have font face specified (and is thusly using pango)