#ifndef SPECTRE_GRAPHCIS_FONT_H #define SPECTRE_GRAPHCIS_FONT_H #include #include #include #include #include #include class FontDriver; // TODO: Fixup this api :) class Font { public : struct Info { std::string name; }; struct Glyph { vec2b size; // Width, Height of bounding box. vec2b offset; // Offset from cursor where the box begins. unsigned char advance; //vec4u tex_coords; vec2u texture_origin; const Texture* texture; // Texture atlas. }; Font(); ~Font(); bool loadFromFile(const std::string& filename, unsigned int size = 22); bool loadFromMemory(const void *data, unsigned int size); Glyph getGlyph(unsigned int code) const; const Texture* getTexture() const; protected : bool loadData(); void loadChar(unsigned char code) const; void createTexture(); void resizeTexture() const; Vector2u findTextureRegion(const Image& img) const; protected : FontDriver *m_driver; mutable std::map m_charset; unsigned int m_size; // font size, in pixels. not points. // Texture atlas used by the font. mutable Texture m_texture; mutable vec2u m_texpos; mutable unsigned m_shelf; std::vector m_rawData; }; #endif /* SPECTRE_GRAPHCIS_FONT_H */