osb/source/rendering/StarFontTextureGroup.hpp

53 lines
1.4 KiB
C++
Raw Normal View History

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-21 09:46:23 +00:00
// Font* is only included for key uniqueness and should not be dereferenced
typedef tuple<String::Char, unsigned, String, Font*> GlyphDescriptor;
struct GlyphTexture {
TexturePtr texture;
int64_t time;
Vec2F processingOffset;
};
2023-06-21 09:46:23 +00:00
FontTextureGroup(TextureGroupPtr textureGroup);
2023-06-20 04:33:09 +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);
2023-06-21 09:46:23 +00:00
// Switches the current font
void switchFont(String const& font);
2023-06-21 12:29:40 +00:00
String const& activeFont();
2023-06-21 09:46:23 +00:00
void addFont(FontPtr const& font, String const& name, bool default = false);
2023-06-21 13:13:37 +00:00
void clearFonts();
2023-06-20 04:33:09 +00:00
private:
2023-06-21 09:46:23 +00:00
StringMap<FontPtr> m_fonts;
String m_fontName;
2023-06-20 04:33:09 +00:00
FontPtr m_font;
2023-06-21 09:46:23 +00:00
FontPtr m_defaultFont;
2023-06-20 04:33:09 +00:00
TextureGroupPtr m_textureGroup;
HashMap<GlyphDescriptor, GlyphTexture> m_glyphs;
};
}
#endif