Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Font.hpp
1#pragma once
2
3#include "resources/Texture.hpp"
4#include "resources/Mesh.hpp"
5#include "Common.hpp"
6
12class Font {
13public:
15 enum class Alignment {
16 LEFT,
17 CENTER,
18 RIGHT
19 };
20
24 explicit Font(std::istream & in);
25
32 void generateLabel(const std::string & text, float scale, Mesh & mesh, Alignment align = Alignment::LEFT) const;
33
37 Font & operator=(const Font &) = delete;
38
40 Font(const Font &) = delete;
41
45 Font & operator=(Font &&) = default;
46
48 Font(Font &&) = default;
49
53 const Texture * atlas() const { return _atlas; }
54
55private:
56
60 struct Glyph {
61 glm::vec2 min;
62 glm::vec2 max;
63 };
64
65 const Texture * _atlas;
68 glm::vec2 _margins;
69
70 std::vector<Glyph> _glyphs;
71};
Font loading and storage: texture atlas, codepoints supported, dimensions of each glyph.
Definition: Font.hpp:12
Font & operator=(const Font &)=delete
Font & operator=(Font &&)=default
void generateLabel(const std::string &text, float scale, Mesh &mesh, Alignment align=Alignment::LEFT) const
Definition: Font.cpp:53
Alignment
Text alignment.
Definition: Font.hpp:15
int _lastCodepoint
The integer value of the last supported character.
Definition: Font.hpp:67
Font(Font &&)=default
const Texture * _atlas
The font texture atlas.
Definition: Font.hpp:65
std::vector< Glyph > _glyphs
The glyphs informations.
Definition: Font.hpp:70
Font(const Font &)=delete
const Texture * atlas() const
Definition: Font.hpp:53
glm::vec2 _margins
Margin to apply around each characters when generating the geometry.
Definition: Font.hpp:68
int _firstCodepoint
The integer value of the first supported character.
Definition: Font.hpp:66
Represents a geometric mesh composed of vertices, other attributes and triangles.
Definition: Mesh.hpp:15
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12
A font glyph bounding box, in UV space.
Definition: Font.hpp:60
glm::vec2 max
Top right corner.
Definition: Font.hpp:62
glm::vec2 min
Bottom left corner.
Definition: Font.hpp:61