RhythmGame 1.4.3
Loading...
Searching...
No Matches
Lr2FontCache.h
Go to the documentation of this file.
1#pragma once
2
3#include <QHash>
4#include <QImage>
5#include <QList>
6#include <QRect>
7#include <QString>
8#include <memory>
9#include <mutex>
10
11namespace resource_managers {
12
14{
15 int imgIdx = -1;
16 QRect rect;
17};
18
20{
21 QList<QImage> textures;
22 QHash<char32_t, Lr2FontGlyph> glyphs;
23 QHash<int, int> imgMap; // file-declared ID -> index into textures
24 int height = 0;
25 int kerning = 0;
26};
27
28// Process-wide cache of parsed .lr2font files. Returned pointers stay valid
29// for the lifetime of the process, including when providers load off-thread.
31{
32 public:
33 static Lr2FontCache& instance();
34
35 // Returns nullptr on load failure. Pointer is stable for the lifetime
36 // of the process.
37 const Lr2FontDict* load(const QString& path);
38
39 Lr2FontCache(const Lr2FontCache&) = delete;
41
42 private:
43 Lr2FontCache() = default;
44
45 std::mutex m_mutex;
46 QHash<QString, std::shared_ptr<Lr2FontDict>> m_cache;
47};
48
49} // namespace resource_managers
QString path
Definition Lr2SkinParser.cpp:87
Definition Lr2FontCache.h:31
Lr2FontCache(const Lr2FontCache &)=delete
const Lr2FontDict * load(const QString &path)
Definition Lr2FontCache.cpp:308
Lr2FontCache & operator=(const Lr2FontCache &)=delete
static Lr2FontCache & instance()
Definition Lr2FontCache.cpp:301
Classes and functions related to loading and managing resources such as charts, sounds,...
Definition ProfileArenaIdentityProvider.h:12
Definition Lr2FontCache.h:20
QList< QImage > textures
Definition Lr2FontCache.h:21
int height
Definition Lr2FontCache.h:24
QHash< int, int > imgMap
Definition Lr2FontCache.h:23
int kerning
Definition Lr2FontCache.h:25
QHash< char32_t, Lr2FontGlyph > glyphs
Definition Lr2FontCache.h:22
Definition Lr2FontCache.h:14
QRect rect
Definition Lr2FontCache.h:16
int imgIdx
Definition Lr2FontCache.h:15