implement font deletion

This commit is contained in:
2026-03-26 21:01:43 +01:00
parent d2ab60c824
commit bc06a3fee8
5 changed files with 20 additions and 4 deletions

View File

@@ -70,6 +70,7 @@ class PD_API Drawlist {
/** Font Handling */
void SetFont(Font* font) { pFont = font; }
void SetFontscale(float fontscale = 1.f) { pFontScale = fontscale; }
const float& GetFontScale() const { return pFontScale; }
/** Data geters */
const Pool<Command>& Data() const { return pCommands; }

View File

@@ -64,6 +64,11 @@ class PD_API Font {
void CmdTextEx(Drawlist& dl, const fvec2& pos, u32 color, float scale,
const char* text, LiTextFlags flags = 0, const fvec2& box = 0);
/**
* Cleanup Font and unload Textures
*/
void Delete();
/**
* Garbage collection for TextMapSystem
*/
@@ -80,7 +85,7 @@ class PD_API Font {
/** Data Section */
int PixelHeight = 0;
int DefaultPixelHeight = 24;
int DefaultPixelHeight = 32;
std::vector<TextureID> Textures;
/**
* 32Bit Codepoint Dataholder reference map

View File

@@ -7,9 +7,7 @@ constexpr const char* pColorYellow = "\033[33m";
constexpr const char* pColorRed = "\033[31m";
static LogLevel pFilter = LogLevel::Info;
PD_API void LogFilter(LogLevel lvl) {
pFilter = lvl;
}
PD_API void LogFilter(LogLevel lvl) { pFilter = lvl; }
PD_API void Log(const std::string& txt, LogLevel lvl) {
if ((int)lvl < (int)pFilter) return;

View File

@@ -271,5 +271,15 @@ PD_API std::string Font::pShortText(const std::string& txt, float scale,
return "";
}
PD_API void Font::Delete() {
for (auto& it : Textures) {
// Creating a tmp fake Li tex for deletion
PD::Gfx::DeleteTexture(PD::Li::Texture(it, 0));
}
pCurrentTex = 0;
PixelHeight = 0;
pTMS.clear();
CodeMap.clear();
}
} // namespace Li
} // namespace PD

View File

@@ -29,6 +29,8 @@ class OsCtx {
return fvec2(in.x * pViewPort.y, in.y * pViewPort.y);
}
const PD::ivec2& GetViewport() const { return pViewPort; }
protected:
PD::ivec2 pViewPort;
const Driver pDriver;