]> git.localhorst.tv Git - gong.git/blob - src/graphics/Font.hpp
code, assets, and other stuff stolen from blank
[gong.git] / src / graphics / Font.hpp
1 #ifndef GONG_GRAPHICS_FONT_HPP_
2 #define GONG_GRAPHICS_FONT_HPP_
3
4 #include "glm.hpp"
5
6 #include <SDL_ttf.h>
7
8
9 namespace gong {
10 namespace graphics {
11
12 class Texture;
13
14 class Font {
15
16 public:
17         enum FontStyle {
18                 STYLE_NORMAL = TTF_STYLE_NORMAL,
19                 STYLE_BOLD = TTF_STYLE_BOLD,
20                 STYLE_ITALIC = TTF_STYLE_ITALIC,
21                 STYLE_UNDERLINE = TTF_STYLE_UNDERLINE,
22                 STYLE_STRIKE = TTF_STYLE_STRIKETHROUGH,
23         };
24         enum FontHinting {
25                 HINT_NORMAL = TTF_HINTING_NORMAL,
26                 HINT_LIGHT = TTF_HINTING_LIGHT,
27                 HINT_MONO = TTF_HINTING_MONO,
28                 HINT_NONE = TTF_HINTING_NONE,
29         };
30
31 public:
32         Font(const char *src, int size, long index = 0);
33         ~Font();
34
35         Font(Font &&) noexcept;
36         Font &operator =(Font &&) noexcept;
37
38         Font(const Font &) = delete;
39         Font &operator =(const Font &) = delete;
40
41 public:
42         int Style() const noexcept;
43         void Style(int) const noexcept;
44         int Outline() const noexcept;
45         void Outline(int) noexcept;
46
47         int Hinting() const noexcept;
48         void Hinting(int) const noexcept;
49         bool Kerning() const noexcept;
50         void Kerning(bool) noexcept;
51
52         int Height() const noexcept;
53         int Ascent() const noexcept;
54         int Descent() const noexcept;
55         int LineSkip() const noexcept;
56
57         const char *FamilyName() const noexcept;
58         const char *StyleName() const noexcept;
59
60         bool HasGlyph(Uint16) const noexcept;
61
62         glm::ivec2 TextSize(const char *) const;
63
64         Texture Render(const char *) const;
65         void Render(const char *, Texture &) const;
66
67 private:
68         TTF_Font *handle;
69
70 };
71
72 }
73 }
74
75 #endif