From 4059479ac8cf37a1fd4645edf6d5a878df8dcfda Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 8 Mar 2023 21:39:56 +0100 Subject: [PATCH] added dirty workaround to erase text if input gadget font has draw offset --- src/libgame/gadgets.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index cefffd27..b917b43d 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -346,8 +346,12 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) char text[MAX_GADGET_TEXTSIZE + 1]; int font_nr = (pressed ? gi->font_active : gi->font); int font_width = getFontWidth(font_nr); + int font_height = getFontHeight(font_nr); + struct FontBitmapInfo *font = getFontBitmapInfo(font_nr); int border_x = gi->border.xsize; int border_y = gi->border.ysize; + int text_x = gi->x + font->draw_xoffset; + int text_y = gi->y + font->draw_yoffset; // left part of gadget BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y, @@ -369,6 +373,15 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) strcpy(text, gi->textinput.value); strcat(text, " "); + // dirty workaround to erase text if input gadget font has draw offset + if (font->draw_xoffset != 0 || font->draw_yoffset != 0) + for (i = 0; i < gi->textinput.size + 1; i++) + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x + border_x, gd->y + border_y, + font_width, font_height, + text_x + border_x + i * font_width, + text_y + border_y); + // gadget text value DrawTextExt(drawto, gi->x + border_x, gi->y + border_y, text, -- 2.34.1