GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Font.hpp
Go to the documentation of this file.
1 #ifndef RADIX_FONT_HPP
2 #define RADIX_FONT_HPP
3 
4 #include <map>
5 #include <string>
6 
8 
9 namespace radix {
10 
11 class Font {
12 public:
13  int num_chars;
14  float size;
15 
16  const Glyph& getGlyph(int index) const {
17  return letters.at(index);
18  }
19 
20  int getStringLength(const std::string &string) const {
21  int length = 0;
22  const char *array = string.c_str();
23  for (unsigned int i = 0; i < string.length(); i++) {
24  const Glyph &letter = getGlyph(array[i]);
25  length += letter.width * this->size;
26  }
27  return length;
28  }
29 
30  std::map<int, Glyph> letters;
31 };
32 
33 } /* namespace radix */
34 
35 #endif /* RADIX_FONT_HPP */
Definition: Font.hpp:11
Definition: GameController.hpp:7
int num_chars
Definition: Font.hpp:13
Definition: Glyph.hpp:8
const Glyph & getGlyph(int index) const
Definition: Font.hpp:16
float size
Definition: Font.hpp:14
int width
Definition: Glyph.hpp:12
int getStringLength(const std::string &string) const
Definition: Font.hpp:20
float length(const Vector4f &v)
Definition: Vector4f.hpp:163
std::map< int, Glyph > letters
Definition: Font.hpp:30