jGL
Loading...
Searching...
No Matches
glyph.h
Go to the documentation of this file.
1#ifndef GLYPH_H
2#define GLYPH_H
3
4#include <ft2build.h>
5#include FT_FREETYPE_H
6
7#include <jGL/defaultFont.h>
8
9#include <glm/glm.hpp>
10
11#include <stdexcept>
12#include <vector>
13#include <string>
14#include <memory>
15#include <iostream>
16#include <array>
17
18namespace jGL
19{
20 class Glyph
21 {
22
23 public:
24
25 Glyph() = default;
26
27 Glyph
28 (
29 const FT_Face & face,
30 unsigned char ch
31 );
32
33 std::vector<unsigned char> & getPixels() {return bitmap;}
34
35 glm::ivec2 getSize() const
36 {
37 return size;
38 }
39
40 std::array<glm::vec2, 6> vertices(float x, float y, float scale)
41 {
42 float xpos = x + bearing.x * scale;
43 float ypos = y + (size.y - bearing.y) * scale;
44
45 float w = size.x * scale;
46 float h = size.y * scale;
47
48 std::array<glm::vec2, 6> v;
49 v[0] = glm::vec2(xpos, ypos-h);
50 v[1] = glm::vec2(xpos, ypos);
51 v[2] = glm::vec2(xpos+w, ypos);
52 v[3] = glm::vec2(xpos, ypos-h);
53 v[4] = glm::vec2(xpos+w, ypos);
54 v[5] = glm::vec2(xpos+w, ypos-h);
55
56 return v;
57 }
58
59
60 private:
61
62 std::vector<unsigned char> bitmap;
63 unsigned char character;
64 glm::ivec2 size, bearing;
65 uint64_t offset;
66
67 };
68}
69
70#endif /* GLYPH_H */
Definition glyph.h:21
std::array< glm::vec2, 6 > vertices(float x, float y, float scale)
Definition glyph.h:40
Glyph()=default
glm::ivec2 getSize() const
Definition glyph.h:35
std::vector< unsigned char > & getPixels()
Definition glyph.h:33
A drawable graphic.
Definition id.h:10