Aether3D Game Engine
Font.hpp
1 #ifndef FONT_H
2 #define FONT_H
3 
4 namespace ae3d
5 {
6  namespace FileSystem
7  {
8  struct FileContentsData;
9  }
10 
12  class Font
13  {
14  public:
16  Font();
17 
22  void LoadBMFont( class Texture2D* fontTex, const FileSystem::FileContentsData& metaData );
23 
25  Texture2D* GetTexture() { return texture; }
26 
28  int TextWidth( const char* text ) const;
29 
30  private:
31  friend class TextRendererComponent;
32 
33  struct Character
34  {
35  float x = 0, y = 0;
36  float width = 0, height = 0;
37  float xOffset = 0, yOffset = 0;
38  float xAdvance = 0;
39  };
40 
46  void CreateVertexBuffer( const char* text, const struct Vec4& color, class VertexBuffer& outVertexBuffer ) const;
47 
49  void LoadBMFontMetaText(const FileSystem::FileContentsData& metaData);
50 
52  void LoadBMFontMetaBinary(const FileSystem::FileContentsData& metaData);
53 
55  int spacing[ 2 ];
56 
58  int padding[ 4 ];
59 
61  int lineHeight = 32;
62 
64  int base = 32;
65 
66  Character chars[ 256 ];
67  Texture2D* texture = nullptr;
68  };
69 }
70 
71 #endif
Texture2D * GetTexture()
Definition: Font.hpp:25
Contains glyphs loaded from AngelCode BMFont files. For Mac there is a compatible program called BMGl...
Definition: Font.hpp:12
Definition: AudioClip.hpp:4
4-component vector.
Definition: Vec3.hpp:351
Contains text.
Definition: TextRendererComponent.hpp:10
2D texture.
Definition: Texture2D.hpp:17
Definition: FileSystem.hpp:12