Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
appgurueu committed Jan 10, 2025
1 parent 4d08353 commit f454146
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions src/irrlicht_changes/CGUITTFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@
[email protected]
*/

#include <cstdlib>
#include <iostream>
#include <optional>
#include "CGUITTFont.h"

#include "irr_ptr.h"
#include "log.h"
#include "filesys.h"
#include "debug.h"

#include "CGUITTFont.h"
#include "IFileSystem.h"
#include "IGUIEnvironment.h"

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

namespace irr
{
namespace gui
Expand All @@ -52,13 +53,14 @@ std::map<io::path, SGUITTFace*> SGUITTFace::faces;
std::optional<FT_Library> SGUITTFace::freetype_library;
std::size_t SGUITTFace::n_faces;

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

SGUITTFace::SGUITTFace(std::string &&buffer) : face_buffer(std::move(buffer))
Expand All @@ -84,7 +86,7 @@ SGUITTFace* SGUITTFace::createFace(std::string &&buffer)
irr_ptr<SGUITTFace> face(new SGUITTFace(std::move(buffer)));
auto ft = getFreeTypeLibrary();
if (!ft) return nullptr;
return (FT_New_Memory_Face(*ft,
return (FT_New_Memory_Face(ft,
reinterpret_cast<const FT_Byte*>(face->face_buffer.data()),
face->face_buffer.size(), 0, &face->face))
? nullptr : face.release();
Expand Down
4 changes: 2 additions & 2 deletions src/irrlicht_changes/CGUITTFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#pragma once

#include <ft2build.h>
#include FT_FREETYPE_H
#include <freetype/freetype.h>

#include "IGUIEnvironment.h"
#include "IGUIFont.h"
Expand All @@ -59,7 +59,7 @@ namespace gui
static std::optional<FT_Library> freetype_library;
static std::size_t n_faces;

static std::optional<FT_Library> getFreeTypeLibrary();
static FT_Library getFreeTypeLibrary();

public:

Expand Down

0 comments on commit f454146

Please sign in to comment.