blob: b2fa572c7230fcc0c616fb06aa90769a652fcc32 (
plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#pragma once
#include "StarColor.hpp"
#include "StarFont.hpp"
#include "StarRenderer.hpp"
#include "StarDirectives.hpp"
namespace Star {
STAR_CLASS(FontTextureGroup);
class FontTextureGroup {
public:
// Font* is only included for key uniqueness and should not be dereferenced
typedef tuple<String::Char, unsigned, size_t, Font*> GlyphDescriptor;
struct GlyphTexture {
TexturePtr texture;
bool colored = false;
int64_t time = 0;
Vec2F offset;
};
FontTextureGroup(TextureGroupPtr textureGroup);
const GlyphTexture& glyphTexture(String::Char, unsigned fontSize, Directives const* processingDirectives = nullptr);
TexturePtr glyphTexturePtr(String::Char, unsigned fontSize);
TexturePtr glyphTexturePtr(String::Char, unsigned fontSize, Directives const* processingDirectives = nullptr);
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);
// Switches the current font
void switchFont(String const& font);
String const& activeFont();
void addFont(FontPtr const& font, String const& name);
void clearFonts();
void setFixedFonts(String const& defaultFontName, String const& fallbackFontName, String const& emojiFontName);
private:
Font* getFontForCharacter(String::Char);
CaseInsensitiveStringMap<FontPtr> m_fonts;
String m_fontName;
FontPtr m_activeFont;
FontPtr m_defaultFont;
FontPtr m_fallbackFont;
FontPtr m_emojiFont;
TextureGroupPtr m_textureGroup;
HashMap<GlyphDescriptor, GlyphTexture> m_glyphs;
};
}
|