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:
parent
95ff92c7d5
commit
2cc4760ee5
@ -1116,6 +1116,7 @@ main (int argc, char * argv[])
|
|||||||
|
|
||||||
Platform::run (HandleEvent);
|
Platform::run (HandleEvent);
|
||||||
|
|
||||||
|
DisposeFonts ();
|
||||||
FinishObjects ();
|
FinishObjects ();
|
||||||
|
|
||||||
if (g_renderer)
|
if (g_renderer)
|
||||||
|
30
src/text.cxx
30
src/text.cxx
@ -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.
|
||||||
*
|
*
|
||||||
|
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user