Fix incorrect handling of zero extra pixel offset

This commit is contained in:
Kovid Goyal 2018-01-10 13:54:51 +05:30
parent 025a46bb35
commit 9ccc6bf835
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -143,10 +143,12 @@ def fit_image(width, height, pwidth, pheight):
def calculate_in_cell_x_offset(width, cell_width, align): def calculate_in_cell_x_offset(width, cell_width, align):
if align == 'left': if align == 'left':
return 0 return 0
extra_pixels = cell_width - (width % cell_width) extra_pixels = width % cell_width
if not extra_pixels:
return 0
if align == 'right': if align == 'right':
return extra_pixels return cell_width - extra_pixels
return extra_pixels // 2 return (cell_width - extra_pixels) // 2
def set_cursor(cmd, width, height, align): def set_cursor(cmd, width, height, align):