'calculate box width for given text.
If max_title_width is given, the returned width is limited to it.'

def box_width(self, text):

    (width, _) = self.drawer.max_layout_size([text], self.font, self.fontsize)
    width = (width + (2 * (self.padding_x + self.borderwidth)))
    return width
