VAPOR3 3.9.4
Font.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <map>
5#include <glm/glm.hpp>
6#include "vapor/MyBase.h"
7
8#include <ft2build.h>
9#include FT_FREETYPE_H
10
11namespace VAPoR {
12
13struct GLManager;
14
23
25 struct Glyph {
26 unsigned int textureID;
27 int sizeX;
28 int sizeY;
29 int bearingX;
30 int bearingY;
31 long advance;
32 };
33
34 GLManager *_glManager;
35 FT_Library _library;
36 FT_Face _face;
37
38 std::map<int, Glyph> _glyphMap;
39 int _size;
40 unsigned int _VAO, _VBO;
41
42 bool LoadGlyph(int c);
43 Glyph GetGlyph(int c);
44
45public:
46 Font(GLManager *glManager, const std::string &path, int size, FT_Library library = nullptr);
48
55 void DrawText(const std::string &text, const glm::vec4 &color = glm::vec4(1));
56
59 glm::vec2 TextDimensions(const std::string &text);
60 float LineHeight() const;
61};
62
63} // namespace VAPoR
Renders charachter glyphs using FreeType2 This class does not do any transformation,...
Definition: Font.h:24
Font(GLManager *glManager, const std::string &path, int size, FT_Library library=nullptr)
glm::vec2 TextDimensions(const std::string &text)
float LineHeight() const
void DrawText(const std::string &text, const glm::vec4 &color=glm::vec4(1))
Wasp base class.
Definition: MyBase.h:67
#define RENDER_API
Definition: common.h:78
Contains references to context scope OpenGL data.
Definition: GLManager.h:18