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