lxgui
Loading...
Searching...
No Matches
gui_sfml_font.hpp
1#ifndef LXGUI_GUI_SFML_FONT_HPP
2#define LXGUI_GUI_SFML_FONT_HPP
3
4#include "lxgui/gui_font.hpp"
5#include "lxgui/impl/gui_sfml_material.hpp"
6#include "lxgui/utils.hpp"
7
8#include <SFML/Graphics/Font.hpp>
9#include <vector>
10
11namespace lxgui::gui::sfml {
12
18class font final : public gui::font {
19public:
29 const std::string& font_file,
30 std::size_t size,
31 std::size_t outline,
32 const std::vector<code_point_range>& code_points,
33 char32_t default_code_point);
34
39 std::size_t get_size() const override;
40
48 bounds2f get_character_uvs(char32_t c) const override;
49
55 bounds2f get_character_bounds(char32_t c) const override;
56
62 float get_character_width(char32_t c) const override;
63
69 float get_character_height(char32_t c) const override;
70
81 float get_character_kerning(char32_t c1, char32_t c2) const override;
82
87 std::weak_ptr<gui::material> get_texture() const override;
88
93 void update_texture(std::shared_ptr<gui::material> mat) override;
94
95private:
96 char32_t get_character_(char32_t c) const;
97
98 sf::Font font_;
99 std::size_t size_ = 0u;
100 std::size_t outline_ = 0u;
101 char32_t default_code_point_ = 0u;
102
103 std::shared_ptr<sfml::material> texture_;
104 std::vector<code_point_range> code_points_;
105};
106
107} // namespace lxgui::gui::sfml
108
109#endif
A texture containing characters.
Definition gui_font.hpp:22
A texture containing characters This is the SFML implementation of the gui::font. It uses sf::Font to...
bounds2f get_character_uvs(char32_t c) const override
Returns the uv coordinates of a character on the texture.
float get_character_width(char32_t c) const override
Returns the width of a character in pixels.
void update_texture(std::shared_ptr< gui::material > mat) override
Update the material to use for rendering.
float get_character_kerning(char32_t c1, char32_t c2) const override
Return the kerning amount between two characters.
float get_character_height(char32_t c) const override
Returns the height of a character in pixels.
std::weak_ptr< gui::material > get_texture() const override
Returns the underlying material to use for rendering.
bounds2f get_character_bounds(char32_t c) const override
Returns the rect coordinates of a character as it should be drawn relative to the baseline.
font(const std::string &font_file, std::size_t size, std::size_t outline, const std::vector< code_point_range > &code_points, char32_t default_code_point)
Constructor.
std::size_t get_size() const override
Get the size of the font in pixels.