ttf.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | #pragma once
#include <planet/affine/extents2d.hpp>
#include <planet/asset_manager.hpp>
#include <planet/sdl/handle.hpp>
#include <planet/sdl/rw_ops.hpp>
#include <planet/sdl/surface.hpp>
#include <SDL_ttf.h>
namespace planet::sdl {
class init;
|
Initialise TTF
Create one of these for access to the TTF rendering parts of SDL2
| class ttf {
public:
ttf(init &);
~ttf();
};
|
TTF Font
29
30
31
32
33
34
35
36
37
38
39
40
41
42 | class font {
rw_ops_const_memory font_data;
handle<TTF_Font, TTF_CloseFont> pf;
SDL_Color colour;
public:
font(asset_manager const &,
char const *filename,
std::size_t pixel_height,
SDL_Color = {255, 255, 255, 255},
felspar::source_location const & =
felspar::source_location::current());
TTF_Font *get() const noexcept { return pf.get(); }
|
Measurements
| affine::extents2d const space, em;
|
Text dimensions
| affine::extents2d measure(char const *text) const;
|
Render text to a single line
51
52
53
54
55
56
57
58
59 | surface
render(char const *text,
planet::ui::scale fit = planet::ui::scale::never) const {
return render(text, colour, fit);
}
surface
render(char const *text,
SDL_Color,
planet::ui::scale = planet::ui::scale::never) const;
|
Wrap text if it is too wide
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 | surface
render(char const *text,
std::uint32_t const width,
planet::ui::scale fit = planet::ui::scale::never) const {
return render(text, colour, width, fit);
}
surface
render(char const *text,
SDL_Color,
std::uint32_t width,
planet::ui::scale = planet::ui::scale::never) const;
};
}
|