Bitcoin Forum
November 14, 2024, 07:00:58 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to Change Font in Qt Wallets  (Read 1205 times)
Egoista (OP)
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
February 04, 2014, 07:16:19 PM
Last edit: February 05, 2014, 10:39:54 PM by Egoista
 #1

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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!