SCV  4.2.1
Simple Components for Visual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FontTahoma.h
Go to the documentation of this file.
1 
7 #ifndef __SCV_FONT_TAHOMA_H__
8 #define __SCV_FONT_TAHOMA_H__
9 
10 #ifndef DOXYGEN_SKIP_THIS
11 #include "Singleton.h"
12 #include "ComponentTexture.h"
13 #endif // DOXYGEN_SKIP_THIS
14 
15 namespace scv {
16 
21 class FontTahoma : public Singleton<FontTahoma> {
22 friend class Singleton<FontTahoma>;
23 
24 public:
25  inline int getStringLength(const std::string &str) const {
26  unsigned int stringLength = 0;
27  for (unsigned int i = 0; i < str.size(); i++)
28  stringLength += getCharWidth(str[i]);
29  return stringLength;
30  }
31 
32  inline int getCharWidth(unsigned char character) const {
33  return (character == ' ')? s_spaceSize : s_charactersWidth[character];
34  }
35 
36  inline int getHeight(void) const {
37  return s_height;
38  }
39 
40  inline int getWidth(void) const {
41  return s_width;
42  }
43 
44  inline ComponentTexture* getTexture(void) const {
45  return _cTexture;
46  }
47 
48 private:
49  FontTahoma(void);
50  void genTexture(void);
51 
52  ComponentTexture *_cTexture;
53 
54  static const int s_height;
55  static const int s_width;
56  static const int s_spaceSize;
57 
58  static const unsigned int s_charactersWidth[256];
59 };
60 
61 } // namespace scv
62 
63 #endif // __SCV_FONT_TAHOMA_H__