sfml_impl 0.1.0
Vendor SFML 3.0.2 : IGraphic2Module / IAudioModule
Loading...
Searching...
No Matches
SfmlFont.hpp
Go to the documentation of this file.
1
11#ifndef SFMLFONT_HPP_
12#define SFMLFONT_HPP_
13
14//Sfml
15#include <SFML/Graphics.hpp>
16
17//Interface
18#include "IFont.hpp"
19
20#include <iostream>
21#include <optional>
22
27class SfmlFont : public graphic::IFont {
28
29 public:
30 SfmlFont(std::string path) {
31 try {
32 _font.emplace(path);
33 } catch (const sf::Exception &e) {
34 std::cerr << "Failed to load font: " << e.what() << std::endl;
35 }
36 }
37
38 ~SfmlFont() = default;
39
40 bool isReady() const override {
41 return _font.has_value();
42 }
43
44 const sf::Font &handle() const {
45 return _font.value();
46 }
47
48 private:
49 std::optional<sf::Font> _font;
50};
51
54#endif /* !SFMLFONT_HPP_ */
Sfml Font class - owns the loaded font. SfmlText only references it (sf::Text itself already takes a ...
Definition SfmlFont.hpp:27
SfmlFont(std::string path)
Definition SfmlFont.hpp:30
bool isReady() const override
Definition SfmlFont.hpp:40
const sf::Font & handle() const
Definition SfmlFont.hpp:44
~SfmlFont()=default