-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFontMaster.h
More file actions
66 lines (45 loc) · 1.65 KB
/
FontMaster.h
File metadata and controls
66 lines (45 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include <glm/glm.hpp>
#include <map>
#include <string>
#include <FreeType/src/psaux/pstypes.h>
#include "Appl.h"
class FontManager {
private:
OVRFW::GlProgram glProgram;
GLuint VAO;
GLuint VBO;
GLfloat vertices[6 * 100][4];
public:
static FT_Library ft;
struct Character {
glm::fvec4 Position; // the position of the character inside of the texture
glm::ivec2 Size; // size of glyph
glm::ivec2 Bearing; // offset from baseline to left/top of glyph
GLuint Advance; // offset to advance to next glyph
};
struct RenderFont {
int FontSize;
int offsetY;
int PHeight;
int PStart;
GLuint textureID;
std::map<GLchar, Character> Characters;
};
FontManager();
void Free();
FontManager(FontManager&) = delete;
FontManager(FontManager&&) = delete;
FontManager &operator=(FontManager&) = delete;
FontManager &operator=(FontManager&&) = delete;
void Init(glm::mat4 projection);
static void CloseFontLoader();
void Begin();
void RenderText(RenderFont font, std::string text, GLfloat x, GLfloat y, GLfloat scale, ovrVector4f color, float transparency);
void RenderFontTexture(FontManager::RenderFont font, ovrVector4f color, float transparency);
void End();
static int GetWidth(RenderFont font, std::string text);
static void LoadFont(RenderFont *font, const char *filePath, uint fontSize);
static void LoadFontFromAssets(OVRFW::ovrFileSys *fileSys, RenderFont *font, const char *filePath, uint fontSize);
static void LoadFont(RenderFont *font, FT_Face face, uint fontSize);
};