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