2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#include "StarColor.hpp"
|
|
|
|
#include "StarFont.hpp"
|
|
|
|
#include "StarRenderer.hpp"
|
2023-07-03 20:01:29 +00:00
|
|
|
#include "StarDirectives.hpp"
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
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
|
2023-07-03 20:01:29 +00:00
|
|
|
typedef tuple<String::Char, unsigned, size_t, Font*> GlyphDescriptor;
|
2023-06-20 14:59:41 +00:00
|
|
|
|
|
|
|
struct GlyphTexture {
|
|
|
|
TexturePtr texture;
|
|
|
|
int64_t time;
|
2023-07-03 04:21:51 +00:00
|
|
|
Vec2F offset;
|
2023-06-20 14:59:41 +00:00
|
|
|
};
|
|
|
|
|
2023-06-21 09:46:23 +00:00
|
|
|
FontTextureGroup(TextureGroupPtr textureGroup);
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2023-07-03 20:01:29 +00:00
|
|
|
const GlyphTexture& glyphTexture(String::Char, unsigned fontSize, Directives const* processingDirectives = nullptr);
|
2023-06-20 14:59:41 +00:00
|
|
|
|
|
|
|
TexturePtr glyphTexturePtr(String::Char, unsigned fontSize);
|
2023-07-03 20:01:29 +00:00
|
|
|
TexturePtr glyphTexturePtr(String::Char, unsigned fontSize, Directives const* processingDirectives = nullptr);
|
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-23 08:54:39 +00:00
|
|
|
void addFont(FontPtr const& font, String const& name, bool isDefault = false);
|
2023-06-21 13:13:37 +00:00
|
|
|
void clearFonts();
|
2023-06-20 04:33:09 +00:00
|
|
|
private:
|
2023-08-02 15:17:08 +00:00
|
|
|
CaseInsensitiveStringMap<FontPtr> m_fonts;
|
2023-06-21 09:46:23 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|