-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheditor_font.cpp
More file actions
43 lines (36 loc) · 1004 Bytes
/
editor_font.cpp
File metadata and controls
43 lines (36 loc) · 1004 Bytes
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
#include <QFontDatabase>
#include <QFontMetrics>
#include "editor_font.h"
#include "settings_manager.h"
#include "debug.h"
editor_font::editor_font(QObject *parent) : QObject(parent)
{
font_setup();
settings_manager::add_persistent_listener(this, "display/font");
self = this;
}
bool editor_font::event(QEvent *event)
{
if(event->type() == (QEvent::Type)SETTINGS_EVENT){
settings_event *e = (settings_event *)event;
if(e->data().first == "display/font"){
default_font_size = e->data().second.toInt();
font_setup();
emit font_changed();
}
}
return true;
}
void editor_font::font_setup()
{
font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
font.setPointSize(default_font_size);
QFontMetrics font_info(font);
font_width = font_info.averageCharWidth();
font_height = font_info.height();
}
int editor_font::font_height = 0;
int editor_font::font_width = 0;
int editor_font::default_font_size = 9;
QFont editor_font::font;
editor_font *editor_font::self = nullptr;