Skip to content

Commit

Permalink
Switch TTF render to UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Sep 21, 2021
1 parent 4af6ff1 commit a3b8931
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Source/DiabloUI/credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Source/DiabloUI/progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions Source/DiabloUI/ttf_render_wrapped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Source/utils/ttf_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit a3b8931

Please sign in to comment.