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