1 /*
2  *  This file is part of Dune Legacy.
3  *
4  *  Dune Legacy is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  Dune Legacy is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with Dune Legacy.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef FONTMANAGER_H
19 #define FONTMANAGER_H
20 
21 #include <SDL.h>
22 #include "Font.h"
23 
24 #include <memory>
25 #include <string>
26 
27 typedef enum {
28     FONT_STD10,
29     FONT_STD12,
30     FONT_STD24,
31     NUM_FONTS
32 } Fonts_enum;
33 
34 /// A class for managing fonts.
35 /**
36     This class manages all fonts used in Dune Legacy and provides methods for rendering texts with a specific font.
37 */
38 class FontManager
39 {
40 public:
41     FontManager();
42     ~FontManager();
43 
44     void drawTextOnSurface(SDL_Surface* pSurface, const std::string& text, Uint32 color, unsigned int fontNum);
45     int getTextWidth(const std::string& text, unsigned int fontNum);
46     int getTextHeight(unsigned int fontNum);
47     SDL_Surface* createSurfaceWithText(const std::string& text, Uint32 color, unsigned int fontNum);
48     SDL_Texture* createTextureWithText(const std::string& text, Uint32 color, unsigned int fontNum);
49     SDL_Surface* createSurfaceWithMultilineText(const std::string& text, Uint32 color, unsigned int fontNum, bool bCentered = false);
50     SDL_Texture* createTextureWithMultilineText(const std::string& text, Uint32 color, unsigned int fontNum, bool bCentered = false);
51 private:
52     std::shared_ptr<Font> fonts[NUM_FONTS];
53 
54 };
55 
56 #endif // FONTMANAGER_H
57