summaryrefslogtreecommitdiff
path: root/src/graphics/font.h
blob: 9a8e9197c2bf9fb6fc31dd200b966e45dea55435 (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
34
35
#ifndef GRAPHICS_FONT_H
#define GRAPHICS_FONT_H

#include<string>
#include<array>
#include"SFML/Graphics.hpp"

namespace Graphics {
    class Font {
        private:
            const sf::Texture &tex_;
            const std::string mapping_;
            const unsigned int numrows_, numcols_;
            sf::Vector2f glyphSize_;
        public:
            Font(const sf::Texture &texture, const std::string &mapping,
                    unsigned int numrows, unsigned int numcols);
            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:
            Font &font_;
            const std::string text_;
            sf::VertexArray vertices_;
        public:
            Text(Font &font, const std::string &text);
            virtual void draw(sf::RenderTarget& target,
                    sf::RenderStates states) const override;
    };
}

#endif // GRAPHICS_FONT_H