Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
font_generator.h
Go to the documentation of this file.
1 #ifndef FONT_GENERATOR_H
2 #define FONT_GENERATOR_H
3 #include <memory>
4 #include <map>
5 #include <freetype2/ft2build.h>
6 #include FT_FREETYPE_H
7 #include "graphics/ui/text.h"
8 #include "graphics/ui/font.h"
9 //= SCRIPTABLE
10 
11 namespace Graphics {
12  namespace UI {
16  class FontGenerator {
17  private:
18  FT_Library freetype;
19  std::string font_path;
20  unsigned int pixels_per_unit;
21  std::map<std::string, std::shared_ptr<Font>> fonts;
22  public:
29  FontGenerator(const std::string& font_path = "", const unsigned int pixels_per_unit = 32);
34 
35  //= BEGIN SCRIPTABLE
36 
42  void setFontPath(const std::string& font_path) noexcept;
48  std::string getFontPath() const noexcept;
49 
57  void loadFont(const std::string& ttf_file, const unsigned int size, const std::string& name="");
65  std::shared_ptr<Font> getFont(const std::string& name) const noexcept;
66  //= END SCRIPTABLE
67  };
68  }
69 }
70 
71 #endif
FontGenerator(const std::string &font_path="", const unsigned int pixels_per_unit=32)
Font generator constructor.
Definition: font_generator.cpp:9
Class for font generator.
Definition: font_generator.h:16
std::string getFontPath() const noexcept
Gets the font path.
Definition: font_generator.cpp:27
~FontGenerator()
Destroys the font generator.
Definition: font_generator.cpp:15
void loadFont(const std::string &ttf_file, const unsigned int size, const std::string &name="")
Loads a font.
Definition: font_generator.cpp:31
std::shared_ptr< Font > getFont(const std::string &name) const noexcept
Gets the font.
Definition: font_generator.cpp:132
void setFontPath(const std::string &font_path) noexcept
Sets the font path.
Definition: font_generator.cpp:23