From 237904a1a49413802b7795ba3b20743c0965860f Mon Sep 17 00:00:00 2001 From: Qrox Date: Sun, 29 Dec 2019 20:49:53 +0800 Subject: [PATCH] Fix box drawing characters of bitmap fonts not shown when SDL line drawing is disabled --- src/sdltiles.cpp | 96 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 21 deletions(-) diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index bdb00e4d0372b..382e836634376 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -709,8 +709,23 @@ void CachedTTFFont::OutputChar( const std::string &ch, const int x, const int y, bool BitmapFont::isGlyphProvided( const std::string &ch ) const { - uint32_t t = UTF8_getch( ch ); - return t < 256; + const uint32_t t = UTF8_getch( ch ); + switch( t ) { + case LINE_XOXO_UNICODE: + case LINE_OXOX_UNICODE: + case LINE_XXOO_UNICODE: + case LINE_OXXO_UNICODE: + case LINE_OOXX_UNICODE: + case LINE_XOOX_UNICODE: + case LINE_XXXO_UNICODE: + case LINE_XXOX_UNICODE: + case LINE_XOXX_UNICODE: + case LINE_OXXX_UNICODE: + case LINE_XXXX_UNICODE: + return true; + default: + return t < 256; + } } void BitmapFont::OutputChar( const std::string &ch, const int x, const int y, @@ -723,25 +738,64 @@ void BitmapFont::OutputChar( const std::string &ch, const int x, const int y, void BitmapFont::OutputChar( const int t, const int x, const int y, const unsigned char color, const float opacity ) { - if( t > 256 ) { - return; - } - SDL_Rect src; - src.x = ( t % tilewidth ) * fontwidth; - src.y = ( t / tilewidth ) * fontheight; - src.w = fontwidth; - src.h = fontheight; - SDL_Rect rect; - rect.x = x; - rect.y = y; - rect.w = fontwidth; - rect.h = fontheight; - if( opacity != 1.0f ) { - SDL_SetTextureAlphaMod( ascii[color].get(), opacity * 255 ); - } - RenderCopy( renderer, ascii[color], &src, &rect ); - if( opacity != 1.0f ) { - SDL_SetTextureAlphaMod( ascii[color].get(), 255 ); + if( t <= 256 ) { + SDL_Rect src; + src.x = ( t % tilewidth ) * fontwidth; + src.y = ( t / tilewidth ) * fontheight; + src.w = fontwidth; + src.h = fontheight; + SDL_Rect rect; + rect.x = x; + rect.y = y; + rect.w = fontwidth; + rect.h = fontheight; + if( opacity != 1.0f ) { + SDL_SetTextureAlphaMod( ascii[color].get(), opacity * 255 ); + } + RenderCopy( renderer, ascii[color], &src, &rect ); + if( opacity != 1.0f ) { + SDL_SetTextureAlphaMod( ascii[color].get(), 255 ); + } + } else { + unsigned char uc = 0; + switch( t ) { + case LINE_XOXO_UNICODE: + uc = LINE_XOXO_C; + break; + case LINE_OXOX_UNICODE: + uc = LINE_OXOX_C; + break; + case LINE_XXOO_UNICODE: + uc = LINE_XXOO_C; + break; + case LINE_OXXO_UNICODE: + uc = LINE_OXXO_C; + break; + case LINE_OOXX_UNICODE: + uc = LINE_OOXX_C; + break; + case LINE_XOOX_UNICODE: + uc = LINE_XOOX_C; + break; + case LINE_XXXO_UNICODE: + uc = LINE_XXXO_C; + break; + case LINE_XXOX_UNICODE: + uc = LINE_XXOX_C; + break; + case LINE_XOXX_UNICODE: + uc = LINE_XOXX_C; + break; + case LINE_OXXX_UNICODE: + uc = LINE_OXXX_C; + break; + case LINE_XXXX_UNICODE: + uc = LINE_XXXX_C; + break; + default: + return; + } + draw_ascii_lines( uc, x, y, color ); } }