def _rendered_size ( text , point_size , font_file ) : emu_per_inch = 914400 px_per_inch = 72.0 font = _Fonts . font ( font_file , point_size ) px_width , px_height = font . getsize ( text ) emu_width = int ( px_width / px_per_inch * emu_per_inch ) emu_height = int ( px_height / px_per_inch * emu_per_inch ) return emu_width , emu_height
python measure string in font
Return a ( width height ) pair representing the size of * text * in English Metric Units ( EMU ) when rendered at * point_size * in the font defined in * font_file * .
def _rendered_size(text, point_size, font_file):
    """
    Return a (width, height) pair representing the size of *text* in English
    Metric Units (EMU) when rendered at *point_size* in the font defined in
    *font_file*.
    """
    emu_per_inch = 914400
    px_per_inch = 72.0

    font = _Fonts.font(font_file, point_size)
    px_width, px_height = font.getsize(text)

    emu_width = int(px_width / px_per_inch * emu_per_inch)
    emu_height = int(px_height / px_per_inch * emu_per_inch)

    return emu_width, emu_height