From fe787de97aac342dfc1a1d7d14b98856ee42be88 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 7 Oct 2021 18:54:23 -0400 Subject: [PATCH] Fixed clip boundaries. --- src/renderer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer.c b/src/renderer.c index 4768606c..629c2cff 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -238,7 +238,8 @@ float ren_draw_text(RenFont *font, const char *text, float x, int y, RenColor co int bitmap_index = font->subpixel ? (int)(fmod(pen_x, 1.0) * SUBPIXEL_BITMAPS_CACHED) : 0; GlyphSet* set = font_get_glyphset(font, codepoint, bitmap_index + (bitmap_index < 0 ? SUBPIXEL_BITMAPS_CACHED : 0)); GlyphMetric* metric = &set->metrics[codepoint % 256]; - int start_x = floor(pen_x) + metric->bitmap_left, end_x = metric->x1 - metric->x0 + pen_x; + int start_x = floor(pen_x) + metric->bitmap_left; + int end_x = (metric->x1 - metric->x0) + start_x; int glyph_end = metric->x1, glyph_start = metric->x0; if (set->surface && color.a > 0 && end_x >= clip.x && start_x < clip_end_x) { unsigned char* source_pixels = set->surface->pixels;