Otclient  14/8/2020
fontmanager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef FONTMANAGER_H
24 #define FONTMANAGER_H
25 
26 #include "bitmapfont.h"
27 
28 //@bindsingleton g_fonts
30 {
31 public:
32  FontManager();
33 
34  void terminate();
35  void clearFonts();
36 
37  bool importFont(std::string file);
38 
39  bool fontExists(const std::string& fontName);
40  BitmapFontPtr getFont(const std::string& fontName);
41  BitmapFontPtr getDefaultFont() { return m_defaultFont; }
42 
43  void setDefaultFont(const std::string& fontName) { m_defaultFont = getFont(fontName); }
44 
45 private:
46  std::vector<BitmapFontPtr> m_fonts;
47  BitmapFontPtr m_defaultFont;
48 };
49 
50 extern FontManager g_fonts;
51 
52 #endif
FontManager::fontExists
bool fontExists(const std::string &fontName)
Definition: fontmanager.cpp:81
g_fonts
FontManager g_fonts
Definition: fontmanager.cpp:29
FontManager::clearFonts
void clearFonts()
Definition: fontmanager.cpp:42
FontManager::importFont
bool importFont(std::string file)
Definition: fontmanager.cpp:48
FontManager::FontManager
FontManager()
Definition: fontmanager.cpp:31
FontManager::setDefaultFont
void setDefaultFont(const std::string &fontName)
Definition: fontmanager.h:43
FontManager::terminate
void terminate()
Definition: fontmanager.cpp:36
stdext::shared_object_ptr< BitmapFont >
FontManager::getFont
BitmapFontPtr getFont(const std::string &fontName)
Definition: fontmanager.cpp:90
bitmapfont.h
FontManager
Definition: fontmanager.h:29
FontManager::getDefaultFont
BitmapFontPtr getDefaultFont()
Definition: fontmanager.h:41