Bitcoin Forum

Other => Beginners & Help => Topic started by: Egoista on February 04, 2014, 07:16:19 PM



Title: How to Change Font in Qt Wallets
Post by: Egoista on February 04, 2014, 07:16:19 PM
Hello, hope you all are having a good day

Wondering how one changes the font in Bitcoin/Litecoin/Altcoin and set it to be used globally?

Add the font as a resource and your QRC file should look somthing like:
Code:
<qresource prefix="/polices" >
<file>DejaVuSerif.ttf</file>
<file>DejaVuSerif-Bold.ttf</file>
<file>DejaVuSerif-BoldItalic.ttf</file>
<file>DejaVuSerif-Italic.ttf</file>
</qresource>

and then add this to the main() function in bitcoin.cpp:

Code:
QStringList list;
list << "DejaVuSerif.ttf" << "DejaVuSerif-Bold.ttf" << "DejaVuSerif-Italic.ttf" << "DejaVuSerif-BoldItalic.ttf";
int fontID(-1);
bool fontWarningShown(false);
for (QStringList::const_iterator constIterator = list.constBegin(); constIterator != list.constEnd(); ++constIterator) {
QFile res(":/polices/" + *constIterator);
if (res.open(QIODevice::ReadOnly) == false) {
if (fontWarningShown == false) {
QMessageBox::warning(0, "Application", (QString)"Impossible d'ouvrir la police " + QChar(0x00AB) + " DejaVu Serif " + QChar(0x00BB) + ".");
fontWarningShown = true;
}
} else {
fontID = QFontDatabase::addApplicationFontFromData(res.readAll());
if (fontID == -1 && fontWarningShown == false) {
QMessageBox::warning(0, "Application", (QString)"Impossible d'ouvrir la police " + QChar(0x00AB) + " DejaVu Serif " + QChar(0x00BB) + ".");
fontWarningShown = true;
}
}
}


Then after that, do :

Code:
QApplication.setFont(QFont("DejaVu Serif", 10));
to set it globally.

You're welcome.