diff options
author | pommicket <pommicket@gmail.com> | 2023-07-18 17:20:11 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-07-19 19:02:27 -0400 |
commit | 6ba52193b95b78c62ea56f54d94a55d0e31504d1 (patch) | |
tree | 9aaff5249db58725d2e39559a902343171074f54 /buffer.c | |
parent | fb1c8d184156c9af5432a28831b88776f252da91 (diff) |
font fallbacks
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -956,8 +956,14 @@ bool buffer_pixels_to_pos(TextBuffer *buffer, vec2 pixel_coords, BufferPos *pos) x -= buffer->x1; y -= buffer->y1; - x = clampd(x, 0, buffer->x2 - buffer->x1); - y = clampd(y, 0, buffer->y2 - buffer->y1); + double buffer_width = buffer->x2 - buffer->x1; + double buffer_height = buffer->y2 - buffer->y1; + + if (x < 0 || y < 0 || x >= buffer_width || y >= buffer_height) + ret = false; + + x = clampd(x, 0, buffer_width); + y = clampd(y, 0, buffer_height); double xoff = x + buffer->scroll_x * text_font_char_width(font, ' '); |