Update Font.cpp
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m33s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m33s
fix memleak
This commit is contained in:
@@ -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();
|
||||
|
3
main.cpp
3
main.cpp
@@ -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);
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user