Bound width and height for render_curosr

This commit is contained in:
Kovid Goyal 2020-02-06 06:55:13 +05:30
parent b6c345fc3c
commit 547f138703
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -197,7 +197,7 @@ def render_cursor(which, cell_width=0, cell_height=0, dpi_x=0, dpi_y=0):
ans = CharTexture() ans = CharTexture()
def vert(edge, width_pt=1): def vert(edge, width_pt=1):
width = max(1, int(round(width_pt * dpi_x / 72.0))) width = max(1, min(int(round(width_pt * dpi_x / 72.0)), cell_width))
left = 0 if edge == 'left' else max(0, cell_width - width) left = 0 if edge == 'left' else max(0, cell_width - width)
for y in range(cell_height): for y in range(cell_height):
offset = y * cell_width + left offset = y * cell_width + left
@ -205,7 +205,7 @@ def render_cursor(which, cell_width=0, cell_height=0, dpi_x=0, dpi_y=0):
ans[x] = 255 ans[x] = 255
def horz(edge, height_pt=1): def horz(edge, height_pt=1):
height = max(1, int(round(height_pt * dpi_y / 72.0))) height = max(1, min(int(round(height_pt * dpi_y / 72.0)), cell_height))
top = 0 if edge == 'top' else max(0, cell_height - height) top = 0 if edge == 'top' else max(0, cell_height - height)
for y in range(top, top + height): for y in range(top, top + height):
offset = y * cell_width offset = y * cell_width