aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/Font.h
blob: e34ac63325ed2a1d051bef4d66fd551e022d8d84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include <memory>
#include <SDL2/SDL_ttf.h>

#include "../api/Asset.h"
#include "../api/Config.h"

namespace crepe {

/**
 * \brief Font resource facade
 *
 * This class is a wrapper around an SDL_ttf font instance, encapsulating font loading and usage.
 */
class Font : public Resource{
public:
    /**.
	 * \param src Asset with texture data to load.
	 * \param mediator use the SDLContext reference to load the image
	 */
    Font(const Asset & src, Mediator & mediator);


    ~Font() = default
	const TTF_Font& get_font() const;
private:
	//! The SDL_ttf font object with custom deleter.
    std::unique_ptr<TTF_Font, decltype(&TTF_CloseFont)> font;
	int default_font_size = Config::get_instance().font.font_size;
};

} // namespace crepe