Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
font.h
Go to the documentation of this file.
1 #ifndef FONT_H
2 #define FONT_H
3 #include <map>
4 #include <glm/glm.hpp>
5 #include "graphics/vertex_data.h"
6 //= SCRIPTABLE
7 
8 namespace Graphics {
9  namespace UI {
13  struct Character {
14  //= BEGIN SCRIPTABLE
15 
19  unsigned int texture_handle;
23  glm::vec2 position;
27  glm::vec2 size;
31  float advance;
39  unsigned int vertex_array_object;
40  //= END SCRIPTABLE
41  };
42 
46  class Font {
47  private:
48  std::map<char, Character> characters;
49  unsigned int size;
50  unsigned int pixels_per_unit;
51  public:
58  Font(const unsigned int size = 12, const unsigned int pixels_per_unit = 32);
59  //= BEGIN SCRIPTABLE
60 
67  void addCharacter(const char text_char, const Character& character);
75  Character getCharacter(const char text_char);
81  std::map<char, Character> getCharacters() const;
87  unsigned int getSize() const noexcept;
93  float getOpenGLSize() const noexcept;
94  //= END SCRIPTABLE
95  };
96  }
97 }
98 
99 #endif
void addCharacter(const char text_char, const Character &character)
Adds a character.
Definition: font.cpp:9
unsigned int texture_handle
Definition: font.h:19
Character getCharacter(const char text_char)
Gets the character.
Definition: font.cpp:13
Font(const unsigned int size=12, const unsigned int pixels_per_unit=32)
Font constructor.
Definition: font.cpp:5
float advance
Definition: font.h:31
Class for vertex data.
Definition: vertex_data.h:17
VertexData vertex_data
Definition: font.h:35
glm::vec2 position
Definition: font.h:23
std::map< char, Character > getCharacters() const
Gets the characters.
Definition: font.cpp:17
unsigned int getSize() const noexcept
Gets the size.
Definition: font.cpp:21
glm::vec2 size
Definition: font.h:27
unsigned int vertex_array_object
Definition: font.h:39
float getOpenGLSize() const noexcept
Gets the open gl size.
Definition: font.cpp:25
Class for font.
Definition: font.h:46
Struct holding font character information.
Definition: font.h:13