diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-12-10 20:42:27 +0100 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-12-10 20:46:26 +0100 |
commit | d0ee939a32fc7cec65a77d028d72881ee8ea1495 (patch) | |
tree | dc6983005b145c6be2dbcde5268544adee4fcba7 /src/graphics/textureFont.h | |
parent | 2b6cd04c1fcf9807b6da9aa03e9920c28780db2c (diff) |
Move font support and clean
Diffstat (limited to 'src/graphics/textureFont.h')
-rw-r--r-- | src/graphics/textureFont.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/graphics/textureFont.h b/src/graphics/textureFont.h new file mode 100644 index 0000000..aa89e50 --- /dev/null +++ b/src/graphics/textureFont.h @@ -0,0 +1,38 @@ +#ifndef GRAPHICS_FONT_H +#define GRAPHICS_FONT_H + +#include<string> +#include<array> +#include"SFML/Graphics.hpp" + +namespace Graphics { + class TextureFont { + public: + struct Descr { + std::string mapping; + unsigned int numrows, numcols; + }; + private: + const sf::Texture &tex_; + const Descr description_; + sf::Vector2f glyphSize_; + public: + TextureFont(const sf::Texture &texture, Descr desc); + std::array<sf::Vector2f,4> getGlyphMapping(const char ch); + sf::Vector2f getGlyphSize(); + const sf::Texture *getTexture(); + }; + + class Text : public sf::Drawable, public sf::Transformable { + private: + TextureFont &font_; + const std::string text_; + sf::VertexArray vertices_; + public: + Text(TextureFont &font, const std::string &text); + virtual void draw(sf::RenderTarget& target, + sf::RenderStates states) const override; + }; +} + +#endif // GRAPHICS_FONT_H |