Beispiel #1
0
def _get_text_metrics(text: str, font: ImageFont):
    """
    Returns some useful metrics about the font.

    :param text: the text to be displayed
    :param font: the font object
    :return: a tuple consisting of four sections of the text (top offset, text, bottom offset)
    """
    ascent, descent = font.getmetrics()
    (width, _), (_, offset_y) = font.font.getsize(text)
    return width, offset_y, ascent - offset_y, descent