Brenta Engine 1.2
Loading...
Searching...
No Matches
font.hpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#pragma once
7
8#include <brenta/renderer/opengl/vao.hpp>
9#include <brenta/renderer/opengl/buffer.hpp>
10
11#include <glm/vec2.hpp>
12
13#include <tenno/memory.hpp>
14#include <tenno/vector.hpp>
15
16#include <filesystem>
17#include <map>
18
19namespace brenta
20{
21
22class Shader;
23
24class Font
25{
26public:
27
29 {
30 public:
31 unsigned int texture_id; // ID handle of the glyph texture
32 glm::ivec2 size; // Size of glyph
33 glm::ivec2 bearing; // Offset from baseline to left/top of glyph
34 unsigned int advance; // Offset to advance to next glyph
35 };
36
37 class Builder;
38
39 tenno::shared_ptr<Shader> shader;
40 Vao vao;
41 Buffer vbo;
42 std::map<char, Character> characters;
43
44 Font() = default;
45 Font(const std::filesystem::path &path, int size);
46 Font(Font&&) = default;
47 ~Font();
48
49};
50
52{
53public:
54
55 Builder& path(const std::filesystem::path& path);
56 Builder& size(int size);
57
58 // Add path to be watched for hot-reloading
59 Builder &watch(const std::filesystem::path &path);
60
61 Font build();
62 tenno::vector<std::filesystem::path> get_watch_paths() const;
63
64private:
65
66 std::filesystem::path _path;
67 int _size;
68
69 tenno::vector<std::filesystem::path> watch_paths = {};
70
71};
72
73} // namespave brenta