From 212d00ea13c8eda0ab72508634c6e1a1b92b5909 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Mon, 27 Apr 2026 04:25:16 +0900 Subject: [PATCH] fix stuff --- src/text/ft2.c | 6 +++--- src/text/text.c | 9 ++++++++- src/widget/listbox.c | 16 ++++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/text/ft2.c b/src/text/ft2.c index 472a93f..fef3f05 100644 --- a/src/text/ft2.c +++ b/src/text/ft2.c @@ -49,11 +49,10 @@ static int ft2_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const c FT_Bitmap* bmp; int cy, cx; int c, c2; - int l = MwUTF8ToUTF32(text, &c); FT_Vector vec; const char* old_text; - if(l <= 0) break; - text += l; + + text += MwUTF8ToUTF32(text, &c); ft_table.FT_Load_Char(ttf->face, c, FT_LOAD_RENDER); bmp = &ttf->face->glyph->bitmap; @@ -124,6 +123,7 @@ static int ft2_MwTextWidth(MwFLFont ttf, const char* text) { text = old_text; } + tw -= ttf->face->glyph->advance.x >> 6; tw += ttf->face->glyph->bitmap_left + ttf->face->glyph->bitmap.width; return tw + 1; diff --git a/src/text/text.c b/src/text/text.c index c3f7cc7..9ad6435 100644 --- a/src/text/text.c +++ b/src/text/text.c @@ -70,7 +70,6 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, char* last = input; int cp; - if(strlen(text) == 0) return; #ifdef TTF if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf); #endif @@ -95,6 +94,14 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, } } + if(strlen(line) == 0) { + free(line); + + last = input; + + continue; + } + p.x = point->x; if(align == MwALIGNMENT_CENTER) { p.x -= MwTextWidth(handle, ttf, line) / 2; diff --git a/src/widget/listbox.c b/src/widget/listbox.c index e9865d0..359d8e5 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -199,16 +199,24 @@ static void frame_draw(MwWidget handle) { str = MwStringDuplicate(t); if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M")) { - int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M") - 3; - int seek = 0; - int l = 0; + int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M") - 3; + int seek = 0; + int l = 0; + char* old = str; + + if(ind < 0) ind = 0; + + str = malloc(strlen(old) + 5); + strcpy(str, old); + free(old); while(str[seek] != 0) { int cp; + if(l == ind) break; + seek += MwUTF8ToUTF32(str + seek, &cp); l++; - if(l == ind) break; } memset(str + seek, '.', 3);