Litecoin: Force splash text to look correct with Win32 font scaling

This commit is contained in:
Anton Yemelyanov 2013-07-08 18:34:52 -10:00 committed by Warren Togami
parent ba332eed0e
commit 4fdc6ba448
3 changed files with 2 additions and 35 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 KiB

After

Width:  |  Height:  |  Size: 306 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 KiB

After

Width:  |  Height:  |  Size: 311 KiB

View File

@ -9,9 +9,7 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) :
QSplashScreen(pixmap, f) QSplashScreen(pixmap, f)
{ {
// set reference point, paddings // set reference point, paddings
int paddingLeftCol1 = 34;
int paddingLeftCol2 = 230; int paddingLeftCol2 = 230;
int paddingTopCol1 = 396;
int paddingTopCol2 = 376; int paddingTopCol2 = 376;
int line1 = 0; int line1 = 0;
int line2 = 13; int line2 = 13;
@ -22,9 +20,8 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) :
// define text to place // define text to place
QString titleText = QString(QApplication::applicationName()).replace(QString("-testnet"), QString(""), Qt::CaseSensitive); // cut of testnet, place it as single object further down QString titleText = QString(QApplication::applicationName()).replace(QString("-testnet"), QString(""), Qt::CaseSensitive); // cut of testnet, place it as single object further down
QString versionText = QString("Version %1 ").arg(QString::fromStdString(FormatFullVersion())); QString versionText = QString("Version %1 ").arg(QString::fromStdString(FormatFullVersion()));
QString copyrightText1 = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString("The Bitcoin developers"); QString copyrightText1 = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin developers"));
QString copyrightText2 = QChar(0xA9)+QString(" 2011-%1 ").arg(COPYRIGHT_YEAR) + QString("The Litecoin developers"); QString copyrightText2 = QChar(0xA9)+QString(" 2011-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Litecoin developers"));
QString testnetAddText = QString(tr("[testnet]")); // define text to place as single text object
QString font = "Arial"; QString font = "Arial";
@ -40,26 +37,7 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) :
QPainter pixPaint(&newPixmap); QPainter pixPaint(&newPixmap);
pixPaint.setPen(QColor(70,70,70)); pixPaint.setPen(QColor(70,70,70));
// check font size and drawing with
pixPaint.setFont(QFont(font, fontFactor));
QFontMetrics fm = pixPaint.fontMetrics();
int titleTextWidth = fm.width(titleText);
if(titleTextWidth > 160) {
// strange font rendering, Arial probably not found
fontFactor = 0.75;
}
pixPaint.setFont(QFont(font, 28*fontFactor));
fm = pixPaint.fontMetrics();
titleTextWidth = fm.width(titleText);
pixPaint.drawText(paddingLeftCol1,paddingTopCol1,titleText);
pixPaint.setFont(QFont(font, 9*fontFactor)); pixPaint.setFont(QFont(font, 9*fontFactor));
// if the version string is to long, reduce size
fm = pixPaint.fontMetrics();
int versionTextWidth = fm.width(versionText);
pixPaint.drawText(paddingLeftCol2,paddingTopCol2+line3,versionText); pixPaint.drawText(paddingLeftCol2,paddingTopCol2+line3,versionText);
// draw copyright stuff // draw copyright stuff
@ -67,17 +45,6 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) :
pixPaint.drawText(paddingLeftCol2,paddingTopCol2+line1,copyrightText1); pixPaint.drawText(paddingLeftCol2,paddingTopCol2+line1,copyrightText1);
pixPaint.drawText(paddingLeftCol2,paddingTopCol2+line2,copyrightText2); pixPaint.drawText(paddingLeftCol2,paddingTopCol2+line2,copyrightText2);
// draw testnet string if -testnet is on
if(QApplication::applicationName().contains(QString("-testnet"))) {
// draw copyright stuff
QFont boldFont = QFont(font, 10*fontFactor);
boldFont.setWeight(QFont::Bold);
pixPaint.setFont(boldFont);
fm = pixPaint.fontMetrics();
int testnetAddTextWidth = fm.width(testnetAddText);
pixPaint.drawText((newPixmap.width()-testnetAddTextWidth)/2,13,testnetAddText);
}
pixPaint.end(); pixPaint.end();
this->setPixmap(newPixmap); this->setPixmap(newPixmap);