-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbetterfontcb.cpp
More file actions
28 lines (23 loc) · 787 Bytes
/
Copy pathbetterfontcb.cpp
File metadata and controls
28 lines (23 loc) · 787 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
#include "betterfontcb.h"
#include <QDebug>
#include <fontconfig/fontconfig.h>
BetterFontCB::BetterFontCB(QWidget *parent):
QComboBox(parent)
{
setCurrentIndex(0);
Q_ASSERT(FcInit());
auto config = FcConfigGetCurrent();
FcConfigSetRescanInterval(config, 0);
auto objectSet = FcObjectSetBuild(FC_FAMILY,FC_FILE, nullptr);
auto fontSet = FcFontList(config, FcPatternCreate(), objectSet);
for(int i=0; i < fontSet->nfont; i++){
auto font = fontSet->fonts[i];
auto s = FcNameUnparse(font);
QString d(reinterpret_cast<char*>(s));
auto temp = d.split(':');
m_fontNames.push_back(temp.first().split(',').first());
m_fontFiles.push_back(temp.last().mid(5));
addItem(m_fontNames.last());
}
setEditable(true);
}