OpenRaider  0.1.4-dev
Open Source Tomb Raider Game Engine implementation
FontTTF.h
Go to the documentation of this file.
1 
8 #ifndef _FONT_TTF_H_
9 #define _FONT_TTF_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include "stb/stb_truetype.h"
15 #include "system/Shader.h"
16 
17 class FontMapTTF {
18  public:
19  FontMapTTF();
20  FontMapTTF(FontMapTTF&& other);
21  ~FontMapTTF();
22 
23  int initialize(unsigned char* fontData, int firstChar);
24  bool contains(int c);
25  int getTexture() { return texture; }
26  void getQuad(int c, float* xpos, float* ypos, stbtt_aligned_quad* quad);
27 
28  private:
29  int begin;
30  int texture;
32 };
33 
34 class FontTTF {
35  public:
36  static int initialize(std::string f);
37  static void shutdown();
38 
39  static unsigned int widthText(float scale, std::string s);
40  static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
41 
42  static void drawText(unsigned int x, unsigned int y, float scale,
43  glm::vec4 color, std::string s);
44  static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
45  glm::vec4 color, unsigned int maxWidth, std::string s);
46 
47  private:
48  static int charIsMapped(int c);
49  static int getQuad(int c, float* xpos, float* ypos, stbtt_aligned_quad* quad);
50  static void drawTextInternal(unsigned int x, unsigned int y, float scale,
51  glm::vec4 color, unsigned int maxWidth, std::string s,
52  bool drawWrapped);
53 
54  static unsigned char* fontData;
55  static std::vector<FontMapTTF> maps;
58 };
59 
60 #endif
61 
FontMapTTF()
Definition: FontTTF.cpp:21
static int initialize(std::string f)
Definition: FontTTF.cpp:100
OpenGL Shader Implementation.
int begin
Definition: FontTTF.h:29
static unsigned int widthText(float scale, std::string s)
Definition: FontTTF.cpp:147
static std::vector< FontMapTTF > maps
Definition: FontTTF.h:55
int getTexture()
Definition: FontTTF.h:25
static unsigned char * fontData
Definition: FontTTF.h:54
~FontMapTTF()
Definition: FontTTF.cpp:31
static void drawTextWrapped(unsigned int x, unsigned int y, float scale, glm::vec4 color, unsigned int maxWidth, std::string s)
Definition: FontTTF.cpp:182
static ShaderBuffer uvBuffer
Definition: FontTTF.h:57
static unsigned int heightText(float scale, unsigned int maxWidth, std::string s)
Definition: FontTTF.cpp:165
int initialize(unsigned char *fontData, int firstChar)
Definition: FontTTF.cpp:41
void getQuad(int c, float *xpos, float *ypos, stbtt_aligned_quad *quad)
Definition: FontTTF.cpp:88
static void shutdown()
Definition: FontTTF.cpp:138
bool contains(int c)
Definition: FontTTF.cpp:83
static ShaderBuffer vertexBuffer
Definition: FontTTF.h:56
stbtt_packedchar * charInfo
Definition: FontTTF.h:31
static void drawTextInternal(unsigned int x, unsigned int y, float scale, glm::vec4 color, unsigned int maxWidth, std::string s, bool drawWrapped)
Definition: FontTTF.cpp:187
static int charIsMapped(int c)
Definition: FontTTF.cpp:245
static const float scale
Definition: Sprite.cpp:15
int texture
Definition: FontTTF.h:30
static void drawText(unsigned int x, unsigned int y, float scale, glm::vec4 color, std::string s)
Definition: FontTTF.cpp:160
static int getQuad(int c, float *xpos, float *ypos, stbtt_aligned_quad *quad)
Definition: FontTTF.cpp:268