Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
font_manager.h
Go to the documentation of this file.
1#ifndef FONT_MANAGER_H
2#define FONT_MANAGER_H
3
4#include <QFont>
5#include <QMap>
6#include <QObject>
7
15class FontManager final : public QObject {
16 Q_OBJECT
17
18public:
26 bool Initialize();
27
32 static FontManager *GetInstance();
33
43 QFont GetFont(const QString &font_name, int point_size = 10, int weight = QFont::Normal);
44
53 QString GetFontFamily(const QString &font_name);
54
55private:
60 explicit FontManager(QObject *parent = nullptr): QObject(parent) {
61 };
62
66 ~FontManager() override = default;
67
72
80 QMap<QString, QString> font_families_;
81
91 bool LoadFont(const QString &font_name, const QString &font_path);
92};
93
94#endif // FONT_MANAGER_H
static FontManager * GetInstance()
Gets the singleton instance of the FontManager.
Definition font_manager.cpp:48
bool Initialize()
Initializes the FontManager by loading fonts from predefined paths.
Definition font_manager.cpp:7
QMap< QString, QString > font_families_
Map storing the mapping between logical font names and actual font family names.
Definition font_manager.h:80
FontManager(QObject *parent=nullptr)
Private constructor to enforce the singleton pattern.
Definition font_manager.h:60
QFont GetFont(const QString &font_name, int point_size=10, int weight=QFont::Normal)
Creates a QFont object with the specified logical name, size, and weight.
Definition font_manager.cpp:55
bool LoadFont(const QString &font_name, const QString &font_path)
Loads a single font file into the application using QFontDatabase.
Definition font_manager.cpp:74
QString GetFontFamily(const QString &font_name)
Retrieves the actual font family name associated with a logical font name.
Definition font_manager.cpp:62
~FontManager() override=default
Private default destructor.
static FontManager * instance_
Static pointer to the singleton instance.
Definition font_manager.h:71