1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| TTF_Font *Main12;
TTF_Font *Main13;
TTF_Font *Main14;
bool LoadFonts(void)
{
Main12 = TTF_OpenFont("Main.ttf", 12);
Main13 = TTF_OpenFont("Main.ttf", 13);
Main14 = TTF_OpenFont("Main.ttf", 14);
if (Main12 == NULL || Main13 == NULL || Main14 == NULL)
{
MessageDiag("Le moteur de rendu de texte a rencontré un problème. Surface vide retournée.", "Erreur");
return false;
}
return true;
}
void FreeFonts(void)
{
TTF_CloseFont(Main12);
TTF_CloseFont(Main13);
TTF_CloseFont(Main14);
}
SDL_Surface *QualityStandardText(string text, int size) // Possible memory loss with message pointer
{
SDL_Color textColor = {0, 0, 0};
SDL_Surface *message = NULL;
switch (size)
{
case 12:
message = TTF_RenderText_Blended(Main12, text.c_str(), textColor);
break;
case 13:
message = TTF_RenderText_Blended(Main13, text.c_str(), textColor);
break;
case 14:
message = TTF_RenderText_Blended(Main14, text.c_str(), textColor);
break;
default:
message = TTF_RenderText_Blended(Main12, text.c_str(), textColor);
break;
}
if (message == NULL)
{
MessageDiag("Le rendu du texte a échoué.", "Erreur");
}
return message;
} |
Partager