Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: sfan5 <[email protected]>
  • Loading branch information
appgurueu and sfan5 committed Jan 10, 2025
1 parent f454146 commit 8b067fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/client/fontengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,16 @@ gui::IGUIFont *FontEngine::initFont(const FontSpec &spec)
std::string media_name = spec.mode == FM_Mono
? "mono" + setting_suffix
: (setting_suffix.empty() ? "" : setting_suffix.substr(1));
if (media_name == "") media_name = "regular";
if (media_name.empty())
media_name = "regular";

auto createFont = [&](gui::SGUITTFace *face) -> gui::CGUITTFont* {
auto *font = gui::CGUITTFont::createTTFont(m_env,
face, size, true, true, font_shadow,
font_shadow_alpha);

if (!font) return nullptr;
if (!font)
return nullptr;

if (spec.mode != _FM_Fallback) {
FontSpec spec2(spec);
Expand Down
18 changes: 10 additions & 8 deletions src/irrlicht_changes/CGUITTFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ std::size_t SGUITTFace::n_faces;

FT_Library SGUITTFace::getFreeTypeLibrary()
{
if (freetype_library) return *freetype_library;
if (freetype_library)
return *freetype_library;
FT_Library ft;
if (FT_Init_FreeType(&ft))
FATAL_ERROR("initializing freetype failed");
Expand Down Expand Up @@ -85,7 +86,8 @@ SGUITTFace* SGUITTFace::createFace(std::string &&buffer)
{
irr_ptr<SGUITTFace> face(new SGUITTFace(std::move(buffer)));
auto ft = getFreeTypeLibrary();
if (!ft) return nullptr;
if (!ft)
return nullptr;
return (FT_New_Memory_Face(ft,
reinterpret_cast<const FT_Byte*>(face->face_buffer.data()),
face->face_buffer.size(), 0, &face->face))
Expand Down Expand Up @@ -117,10 +119,12 @@ SGUITTFace* SGUITTFace::loadFace(const io::path &filename)

void SGUITTFace::dropFilename()
{
if (!filename.has_value()) return;
if (!filename.has_value())
return;

auto it = faces.find(*filename);
if (it == faces.end()) return;
if (it == faces.end())
return;

SGUITTFace* f = it->second;
// Drop our face. If this was the last face, the destructor will clean up.
Expand Down Expand Up @@ -302,10 +306,8 @@ shadow_offset(0), shadow_alpha(0), fallback(0)

bool CGUITTFont::load(SGUITTFace *face, const u32 size, const bool antialias, const bool transparency)
{
// Some sanity checks.
if (!Driver) return false;
if (size == 0) return false;
if (!face) return false;
if (!Driver || size == 0 || !face)
return false;

this->size = size;

Expand Down

0 comments on commit 8b067fa

Please sign in to comment.