Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 41 lines (31 sloc) 1.075 kb
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 36 37 38 39 40
#ifndef GRAPHICAL_FONT_HPP_INCLUDED
#define GRAPHICAL_FONT_HPP_INCLUDED

#include <boost/shared_ptr.hpp>
#include <boost/unordered_map.hpp>

#include <string>
#include <vector>

#include "geometry.hpp"
#include "texture.hpp"
#include "variant.hpp"

class graphical_font;
typedef boost::shared_ptr<graphical_font> graphical_font_ptr;
typedef boost::shared_ptr<const graphical_font> const_graphical_font_ptr;

class graphical_font
{
public:
static void init(variant node);
static const_graphical_font_ptr get(const std::string& id);
explicit graphical_font(variant node);
const std::string& id() const { return id_; }
rect draw(int x, int y, const std::string& text, int size=2) const;
rect dimensions(const std::string& text, int size=2) const;

private:
rect do_draw(int x, int y, const std::string& text, bool draw_text, int size) const;

std::string id_;

graphics::texture texture_;
//hashmap to map characters to rectangles in the texture
typedef boost::unordered_map<unsigned int, rect> char_rect_map;
char_rect_map char_rect_map_;
int kerning_;
};

#endif
Something went wrong with that request. Please try again.