1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Add a function to dispose the fonts

This commit is contained in:
Mathieu Schroeter 2023-06-15 22:45:29 +02:00
parent 95ff92c7d5
commit 2cc4760ee5
3 changed files with 28 additions and 4 deletions

View File

@ -1116,6 +1116,7 @@ main (int argc, char * argv[])
Platform::run (HandleEvent); Platform::run (HandleEvent);
DisposeFonts ();
FinishObjects (); FinishObjects ();
if (g_renderer) if (g_renderer)

View File

@ -68,9 +68,21 @@ struct TexText {
~TexText () ~TexText ()
{ {
SDL_DestroyTexture (this->outline); if (this->outline)
SDL_DestroyTexture (this->base); {
SDL_DestroyTexture (this->over); SDL_DestroyTexture (this->outline);
this->outline = nullptr;
}
if (this->base)
{
SDL_DestroyTexture (this->base);
this->base = nullptr;
}
if (this->over)
{
SDL_DestroyTexture (this->over);
this->over = nullptr;
}
} }
}; };
@ -133,7 +145,7 @@ public:
TTF_SetFontDirection (this->font, TTF_DIRECTION_RTL); TTF_SetFontDirection (this->font, TTF_DIRECTION_RTL);
} }
~Font () { TTF_CloseFont (this->font); } ~Font () { this->cache.Clear (); TTF_CloseFont (this->font); }
TTF_Font * GetFont () { return this->font; } TTF_Font * GetFont () { return this->font; }
@ -379,6 +391,10 @@ public:
} }
~Fonts () ~Fonts ()
{
}
void Clear ()
{ {
delete this->latinLittle; delete this->latinLittle;
delete this->latinRed; delete this->latinRed;
@ -654,6 +670,12 @@ GetFonts ()
return &fonts; return &fonts;
} }
void
DisposeFonts ()
{
GetFonts ()->Clear ();
}
/** /**
* \brief Draw a text in a pixmap to a specific position. * \brief Draw a text in a pixmap to a specific position.
* *

View File

@ -30,6 +30,7 @@
class Fonts; class Fonts;
Fonts * GetFonts (); Fonts * GetFonts ();
void DisposeFonts ();
void DrawText ( void DrawText (
CPixmap * pPixmap, Point pos, const char * pText, Sint32 font = 0, CPixmap * pPixmap, Point pos, const char * pText, Sint32 font = 0,