Browse Source

Switch TTF render to UTF-8

pull/2933/head
Anders Jenbo 5 years ago
parent
commit
958087ab86
  1. 2
      Source/DiabloUI/credits.cpp
  2. 4
      Source/DiabloUI/progress.cpp
  3. 4
      Source/DiabloUI/ttf_render_wrapped.cpp
  4. 4
      Source/utils/ttf_wrap.h

2
Source/DiabloUI/credits.cpp

@ -64,7 +64,7 @@ CachedLine PrepareLine(std::size_t index)
SDLSurfaceUniquePtr surface;
if (contents[0] != '\0') {
const SDL_Color shadowColor = { 0, 0, 0, 0 };
SDLSurfaceUniquePtr text = TTFWrap::RenderText_Solid(font, contents, shadowColor);
SDLSurfaceUniquePtr text = TTFWrap::RenderUTF8_Solid(font, contents, shadowColor);
// Set up the target surface to have 3 colors: mask, text, and shadow.
surface = SDLWrap::CreateRGBSurfaceWithFormat(0, text->w + ShadowOffsetX, text->h + ShadowOffsetY, 8, SDL_PIXELFORMAT_INDEX8);

4
Source/DiabloUI/progress.cpp

@ -41,8 +41,8 @@ void ProgressLoad(const char *msg)
SDL_Color color = { 243, 243, 243, 0 };
SDL_Color black = { 0, 0, 0, 0 };
msgSurface = TTFWrap::RenderText_Solid(font, msg, color);
msgShadow = TTFWrap::RenderText_Solid(font, msg, black);
msgSurface = TTFWrap::RenderUTF8_Solid(font, msg, color);
msgShadow = TTFWrap::RenderUTF8_Solid(font, msg, black);
}
SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 265), (Sint16)(UI_OFFSET_Y + 267), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT };
vecProgress.push_back(std::make_unique<UiButton>(&SmlButton, _("Cancel"), &DialogActionCancel, rect3));

4
Source/DiabloUI/ttf_render_wrapped.cpp

@ -106,7 +106,7 @@ SDLSurfaceUniquePtr RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, S
}
if (strLines.empty())
return TTFWrap::RenderText_Solid(font, text, fg);
return TTFWrap::RenderUTF8_Solid(font, text, fg);
/* Create the target surface */
auto textbuf = SDLWrap::CreateRGBSurface(SDL_SWSURFACE, (strLines.size() > 1) ? wrapLength : width, height * strLines.size() + (lineSpace * (strLines.size() - 1)), 8, 0, 0, 0, 0);
@ -129,7 +129,7 @@ SDLSurfaceUniquePtr RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, S
dest.y += lineskip;
continue;
}
SDLSurfaceUniquePtr tmp = TTFWrap::RenderText_Solid(font, text, fg);
SDLSurfaceUniquePtr tmp = TTFWrap::RenderUTF8_Solid(font, text, fg);
dest.w = static_cast<Uint16>(tmp->w);
dest.h = static_cast<Uint16>(tmp->h);

4
Source/utils/ttf_wrap.h

@ -15,9 +15,9 @@ namespace devilution {
namespace TTFWrap {
inline SDLSurfaceUniquePtr RenderText_Solid(TTF_Font *font, const char *text, SDL_Color fg)
inline SDLSurfaceUniquePtr RenderUTF8_Solid(TTF_Font *font, const char *text, SDL_Color fg)
{
SDLSurfaceUniquePtr ret { TTF_RenderText_Solid(font, text, fg) };
SDLSurfaceUniquePtr ret { TTF_RenderUTF8_Solid(font, text, fg) };
if (ret == nullptr)
ErrTtf();

Loading…
Cancel
Save