From d0169216304a30ad94c00d2e6e80f8e5294d0022 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 26 May 2023 19:38:45 +0300 Subject: [PATCH 11/11] sdl2: Fix text surface transparent color issues Sometimes areas that are supposed to be transparent were shown filled with random color. See osdn #47564 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/gui_string.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/gui-sdl2/gui_string.c b/client/gui-sdl2/gui_string.c index e9c3294986..54d35bb58c 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -332,7 +332,7 @@ static SDL_Surface *create_utf8_multi_surf(utf8_str *pstr) pstr->text = utf8_texts[i]; tmp[i] = create_utf8_surf(pstr); - /* find max len */ + /* Find max len */ if (tmp[i]->w > w) { w = tmp[i]->w; } @@ -340,9 +340,11 @@ static SDL_Surface *create_utf8_multi_surf(utf8_str *pstr) pstr->text = buf; - /* create and fill surface */ + /* Create and fill surface */ - SDL_GetColorKey(tmp[0], &color); + if (SDL_GetColorKey(tmp[0], &color) < 0) { + color = SDL_MapRGBA(tmp[0]->format, 0, 0, 0, 0); + } switch (pstr->render) { case 1: @@ -361,7 +363,7 @@ static SDL_Surface *create_utf8_multi_surf(utf8_str *pstr) break; } - /* blit (default: center left) */ + /* Blit (default: center left) */ for (i = 0; i < count; i++) { if (pstr->style & SF_CENTER) { des.x = (w - tmp[i]->w) / 2; -- 2.39.2