From 42af90012713635b01205c2124ada721f72a8770 Mon Sep 17 00:00:00 2001 From: IoI_xD Date: Wed, 8 Apr 2026 11:47:58 -0700 Subject: [PATCH] ft2, stbtt: draw letters over each other so that they don't clip each other --- src/text/ft2.c | 15 +++++++++++---- src/text/stbtt.c | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/text/ft2.c b/src/text/ft2.c index 80baeea..2737d68 100644 --- a/src/text/ft2.c +++ b/src/text/ft2.c @@ -74,10 +74,17 @@ static int ft2_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const c int oy = y + (ttf->face->height * ttf->px / ttf->face->units_per_EM) - ttf->face->glyph->bitmap_top + cy + (ttf->face->descender * ttf->px / ttf->face->units_per_EM); unsigned char* opx = &px[(oy * tw + ox) * 4]; - opx[0] = color->common.red; - opx[1] = color->common.green; - opx[2] = color->common.blue; - opx[3] = bmp->buffer[cy * bmp->pitch + cx]; + if(opx[3] == 0) { + opx[0] = color->common.red; + opx[1] = color->common.green; + opx[2] = color->common.blue; + opx[3] = bmp->buffer[cy * bmp->pitch + cx]; + } else { + opx[0] = (opx[0] / color->common.red) / 255; + opx[1] = (opx[1] / color->common.green) / 255; + opx[2] = (opx[2] / color->common.blue) / 255; + opx[3] = bmp->buffer[cy * bmp->pitch + cx]; + } } } diff --git a/src/text/stbtt.c b/src/text/stbtt.c index ba97279..5e23f6c 100644 --- a/src/text/stbtt.c +++ b/src/text/stbtt.c @@ -53,10 +53,17 @@ static int stbtt_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const int oy = y + ceil(ttf->ascent * ttf->scale) + y0 + cy; unsigned char* opx = &px[(oy * tw + ox) * 4]; - opx[0] = color->common.red; - opx[1] = color->common.green; - opx[2] = color->common.blue; - opx[3] = out[cy * ow + cx]; + if(opx[3] == 0) { + opx[0] = color->common.red; + opx[1] = color->common.green; + opx[2] = color->common.blue; + opx[3] = out[cy * ow + cx]; + } else { + opx[0] = (opx[0] / color->common.red) / 255; + opx[1] = (opx[1] / color->common.green) / 255; + opx[2] = (opx[2] / color->common.blue) / 255; + opx[3] = out[cy * ow + cx]; + } } }