From 424e0e328d9b7ffbb6669d67b034324b48ea777c Mon Sep 17 00:00:00 2001 From: memdmp Date: Sun, 12 Jan 2025 03:18:35 +0100 Subject: fix: last pixel rendering shit --- src/font.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/font.rs') diff --git a/src/font.rs b/src/font.rs index a547928..8f06222 100644 --- a/src/font.rs +++ b/src/font.rs @@ -71,10 +71,12 @@ impl RenderableCharacter { let mut idx: usize = 0; for pixel in self.data { let index = idx * 4; - buffer[index] = colour.r; // Red - buffer[index + 1] = colour.g; // Green - buffer[index + 2] = colour.b; // Blue - buffer[index + 3] = *pixel; // Alpha + if index < buffer.len() { + buffer[index] = colour.r; // Red + buffer[index + 1] = colour.g; // Green + buffer[index + 2] = colour.b; // Blue + buffer[index + 3] = *pixel; // Alpha + } idx += 1; } }); -- cgit v1.2.3