Update Font.cpp
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m33s

fix memleak
This commit is contained in:
2024-07-17 16:36:45 -04:00
parent 162732e4b7
commit 4ff8d8ff07
4 changed files with 7 additions and 4 deletions

View File

@@ -52,7 +52,7 @@ namespace JGL {
Vector3 C;
};
bool Update(const Vector2& window_size);
void Update(const Vector2& window_size);
//bool InitTextEngine();
Font LoadFont(const std::string& font_path); // TODO: Fully deprecate
void PurgeFontCache();

View File

@@ -71,6 +71,7 @@ public:
auto aspect = (float) window_size[0] / (float) window_size[1];
gladLoadGL();
JGL::InitTextEngine();
JGL::Update(getSize());
FreeSans = JGL::Font("assets/fonts/FreeSans.ttf");
Jupiteroid = JGL::Font("assets/fonts/Jupiteroid.ttf");
@@ -121,7 +122,7 @@ public:
J2D::DrawGradientLine(JGL::Colors::Red, JGL::Colors::Blue, {105, 375}, {200, 275}, 2);
auto result = Jupiteroid.MeasureString("Jupiteroid Font", 16);
DEBUG(std::format("Result: {},{}", result.x, result.y ));
//DEBUG(std::format("Result: {},{}", result.x, result.y ));
// TODO: Note the discrepancy in Y between the FillRect and DrawString call here.
J2D::FillRect(JGL::Colors::Gray, {0, 0}, result);

View File

@@ -23,9 +23,8 @@ namespace JGL {
using namespace J3ML;
Vector2 wS;
bool Update(const Vector2& window_size) {
void Update(const Vector2& window_size) {
wS = window_size;
return JGL::InitTextEngine();
}

View File

@@ -49,6 +49,9 @@ namespace JGL::Detail
}
bool InitTextEngine() {
if (ft != nullptr)
throw std::runtime_error("Error::FREETYPE: FT_Library was initialized but is already initialized.");
if (FT_Init_FreeType(&ft))
return true;
return false;