2023-06-20 04:33:09 +00:00
|
|
|
#ifndef STAR_FONT_TEXTURE_GROUP_HPP
|
|
|
|
#define STAR_FONT_TEXTURE_GROUP_HPP
|
|
|
|
|
|
|
|
#include "StarColor.hpp"
|
|
|
|
#include "StarFont.hpp"
|
|
|
|
#include "StarRenderer.hpp"
|
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
STAR_CLASS(FontTextureGroup);
|
|
|
|
|
|
|
|
class FontTextureGroup {
|
|
|
|
public:
|
2023-06-20 14:59:41 +00:00
|
|
|
typedef tuple<String::Char, unsigned, String> GlyphDescriptor;
|
|
|
|
|
|
|
|
struct GlyphTexture {
|
|
|
|
TexturePtr texture;
|
|
|
|
int64_t time;
|
|
|
|
Vec2F processingOffset;
|
|
|
|
};
|
|
|
|
|
2023-06-20 04:33:09 +00:00
|
|
|
FontTextureGroup(FontPtr font, TextureGroupPtr textureGroup);
|
|
|
|
|
2023-06-20 14:59:41 +00:00
|
|
|
const GlyphTexture& glyphTexture(String::Char, unsigned fontSize, String const& processingDirectives);
|
|
|
|
|
|
|
|
TexturePtr glyphTexturePtr(String::Char, unsigned fontSize);
|
|
|
|
TexturePtr glyphTexturePtr(String::Char, unsigned fontSize, String const& processingDirectives);
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
unsigned glyphWidth(String::Char c, unsigned fontSize);
|
|
|
|
|
|
|
|
// Removes glyphs that haven't been used in more than the given time in
|
|
|
|
// milliseconds
|
|
|
|
void cleanup(int64_t timeout);
|
|
|
|
private:
|
|
|
|
|
|
|
|
FontPtr m_font;
|
|
|
|
TextureGroupPtr m_textureGroup;
|
|
|
|
HashMap<GlyphDescriptor, GlyphTexture> m_glyphs;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|