char_lengths_in_px = {"a": 9, "b": 7, "c": 8, ... }
px_per_line = 768
current_length = reduce(lambda x,y: y+char_lengths_in_px[x], my_text, 0)
space_left = (px_per_line*num_lines)-current_length
FTFY char_lengths_in_px = {"a": 9, "b": 7, "c": 8, ... }
px_per_line = 768
current_length = reduce(lambda x,y: y+char_lengths_in_px[x], my_text, 0)
space_left = (px_per_line*num_lines)-current_length
FTFY(Also, it's layout for print, so better to think in terms of pts or picas.)