'Calculates the offsets of the ticklabels from the tick and
their total heights. The offset only takes account the offset
due to the vertical alignment of the ticklabels, i.e.,if axis
direction is bottom and va is ;top\', it will return 0. if va
is \'baseline\', it will return (height-descent).'

def _get_ticklabels_offsets(self, renderer, label_direction):

    whd_list = self.get_texts_widths_heights_descents(renderer)
    if (not whd_list):
        return (0, 0)
    r = 0
    (va, ha) = (self.get_va(), self.get_ha())
    if (label_direction == u'left'):
        pad = max((w for (w, h, d) in whd_list))
        if (ha == u'left'):
            r = pad
        elif (ha == u'center'):
            r = (0.5 * pad)
    elif (label_direction == u'right'):
        pad = max((w for (w, h, d) in whd_list))
        if (ha == u'right'):
            r = pad
        elif (ha == u'center'):
            r = (0.5 * pad)
    elif (label_direction == u'bottom'):
        pad = max((h for (w, h, d) in whd_list))
        if (va == u'bottom'):
            r = pad
        elif (va == u'center'):
            r = (0.5 * pad)
        elif (va == u'baseline'):
            max_ascent = max(((h - d) for (w, h, d) in whd_list))
            max_descent = max((d for (w, h, d) in whd_list))
            r = max_ascent
            pad = (max_ascent + max_descent)
    elif (label_direction == u'top'):
        pad = max((h for (w, h, d) in whd_list))
        if (va == u'top'):
            r = pad
        elif (va == u'center'):
            r = (0.5 * pad)
        elif (va == u'baseline'):
            max_ascent = max(((h - d) for (w, h, d) in whd_list))
            max_descent = max((d for (w, h, d) in whd_list))
            r = max_descent
            pad = (max_ascent + max_descent)
    return (r, pad)
