Skip to content

Commit

Permalink
Fix box drawing characters of bitmap fonts not shown when SDL line dr…
Browse files Browse the repository at this point in the history
…awing is disabled
  • Loading branch information
Qrox committed Dec 29, 2019
1 parent f8ba267 commit 237904a
Showing 1 changed file with 75 additions and 21 deletions.
96 changes: 75 additions & 21 deletions src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 );
}
}

Expand Down

0 comments on commit 237904a

Please sign in to comment.