Neo  0.5.0
Developer Documentation
Font.h
Go to the documentation of this file.
1 //========================================================================
2 // Copyright (c) 2003-2011 Anael Seghezzi <www.maratis3d.com>
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 //
8 // Permission is granted to anyone to use this software for any purpose,
9 // including commercial applications, and to alter it and redistribute it
10 // freely, subject to the following restrictions:
11 //
12 // 1. The origin of this software must not be misrepresented; you must not
13 // claim that you wrote the original software. If you use this software
14 // in a product, an acknowledgment in the product documentation would
15 // be appreciated but is not required.
16 //
17 // 2. Altered source versions must be plainly marked as such, and must not
18 // be misrepresented as being the original software.
19 //
20 // 3. This notice may not be removed or altered from any source
21 // distribution.
22 //
23 //========================================================================
24 
25 
26 #ifndef __FONT_H
27 #define __FONT_H
28 
29 namespace Neo
30 {
31 // Character
32 class NEO_ENGINE_EXPORT Character
33 {
34 public:
35 
36  Character(void);
37  Character(float xAdvance, const Vector2 & offset, const Vector2 & pos, const Vector2 & scale):
38  m_xAdvance(xAdvance),
39  m_offset(offset),
40  m_pos(pos),
41  m_scale(scale)
42  {}
43 
44 private:
45 
46  float m_xAdvance;
47  Vector2 m_offset;
48  Vector2 m_pos;
49  Vector2 m_scale;
50 
51 public:
52 
53  inline float getXAdvance(void){ return m_xAdvance; }
54  inline Vector2 getOffset(void) const { return m_offset; }
55  inline Vector2 getPos(void) const { return m_pos; }
56  inline Vector2 getScale(void) const { return m_scale; }
57 };
58 
59 
60 // Font
61 class NEO_ENGINE_EXPORT Font
62 {
63 public:
64 
65  Font(void);
66  ~Font(void);
67 
68  static Font * getNew(void);
69  void destroy(void);
70 
71 private:
72 
73  unsigned int m_textureId;
74  unsigned int m_textureWidth;
75  unsigned int m_textureHeight;
76  unsigned int m_fontSize;
77 
78  map <unsigned int, Character> m_characters;
79 
80 public:
81 
82  // texture
83  inline void setTextureId(unsigned int textureId){ m_textureId = textureId; }
84  inline void setTextureWidth(unsigned int width){ m_textureWidth = width; }
85  inline void setTextureHeight(unsigned int height){ m_textureHeight = height; }
86  inline unsigned int getTextureId(void){ return m_textureId; }
87  inline unsigned int getTextureWidth(void){ return m_textureWidth; }
88  inline unsigned int getTextureHeight(void){ return m_textureHeight; }
89 
90  // font size
91  inline void setFontSize(unsigned int fontSize){ m_fontSize = fontSize; }
92  inline unsigned int getFontSize(void){ return m_fontSize; }
93 
94  // character
95  void setCharacter(unsigned int charCode, const Character & character);
96  unsigned int getCharactersNumber(void);
97  Character * getCharacter(unsigned int charCode);
98  Character * getCharacterByIndex(unsigned int id);
99  inline map <unsigned int, Character> * getCharacters(void){ return &m_characters; }
100 };
101 }
102 #endif
unsigned int getTextureId(void)
Definition: Font.h:86
unsigned int getTextureWidth(void)
Definition: Font.h:87
map< unsigned int, Character > * getCharacters(void)
Definition: Font.h:99
unsigned int getFontSize(void)
Definition: Font.h:92
float getXAdvance(void)
Definition: Font.h:53
void setTextureHeight(unsigned int height)
Definition: Font.h:85
Definition: Font.h:32
void setTextureWidth(unsigned int width)
Definition: Font.h:84
Vector2 getPos(void) const
Definition: Font.h:55
Vector2 getScale(void) const
Definition: Font.h:56
Character(float xAdvance, const Vector2 &offset, const Vector2 &pos, const Vector2 &scale)
Definition: Font.h:37
Definition: Vector2.h:31
void setTextureId(unsigned int textureId)
Definition: Font.h:83
void setFontSize(unsigned int fontSize)
Definition: Font.h:91
Definition: Font.h:61
Vector2 getOffset(void) const
Definition: Font.h:54
Definition: Color.h:29
unsigned int getTextureHeight(void)
Definition: Font.h:88