Skip to content

Commit

Permalink
rely on FT_Library being a pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
appgurueu committed Jan 10, 2025
1 parent f800e6b commit a7c14f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/irrlicht_changes/CGUITTFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,25 @@

#include <cstdlib>
#include <iostream>
#include <optional>

namespace irr
{
namespace gui
{

std::map<io::path, SGUITTFace*> SGUITTFace::faces;
std::optional<FT_Library> SGUITTFace::freetype_library;
std::size_t SGUITTFace::n_faces;
FT_Library SGUITTFace::freetype_library = nullptr;
std::size_t SGUITTFace::n_faces = 0;

FT_Library SGUITTFace::getFreeTypeLibrary()
{
if (freetype_library)
return *freetype_library;
return freetype_library;
FT_Library ft;
if (FT_Init_FreeType(&ft))
FATAL_ERROR("initializing freetype failed");
freetype_library = ft;
return *freetype_library;
return freetype_library;
}

SGUITTFace::SGUITTFace(std::string &&buffer) : face_buffer(std::move(buffer))
Expand All @@ -77,8 +76,8 @@ SGUITTFace::~SGUITTFace()
// If there are no more faces referenced by FreeType, clean up.
if (n_faces == 0) {
assert(freetype_library);
FT_Done_FreeType(*freetype_library);
freetype_library = std::nullopt;
FT_Done_FreeType(freetype_library);
freetype_library = nullptr;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/irrlicht_changes/CGUITTFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace gui
private:

static std::map<io::path, SGUITTFace*> faces;
static std::optional<FT_Library> freetype_library;
static FT_Library freetype_library;
static std::size_t n_faces;

static FT_Library getFreeTypeLibrary();
Expand Down

0 comments on commit a7c14f5

Please sign in to comment.