Fonts Look Bad
-
I am developing a Linux application in C++ with Qt. I will have no control over the environments it is deployed to. The Qt is used for a menu activated by an icon in the system tray. When I compile and run the program in my development environment, which is a recent version of CentOS Linux, the text is perfectly fine. However, for certain reasons, we wish to do the final production compile in an environment in which most of the components are old. I compile the program in CentOS 4.8 running Qt 4.2. When the executable is run there or in any other Linux, the text is readable, but thin, and skeletal, and badly aliased. One would think that the fonts come from the run environment, but apparently something is going in during build, since the text has this appearance wherever it is run. A simple example of the code is:
@
#include <qapplication.h>
#include <QObject>
#include <iostream>
#include <QWidget>
#include <QFont>
#include <QPalette>
#include <QLabel>
#include <QGroupBox>
#include "fTest.h"
using namespace std;int main(int argc, char *argv[])
{
QApplication app(argc, argv);AboutWindow aw;
aw.raiseAboutWindow();return app.exec();
}void AboutWindow::raiseAboutWindow()
{
QWidget *aboutwindow;
QLabel *label;string labelText = "\n This is line one\n This is line two\n This is line three";
aboutwindow = new QWidget();
// Change the pop-up window's background color
QPalette p( aboutwindow->palette() );
p.setColor( QPalette::Window, QColor(230, 230, 230, 255) );
// p.setColor( QPalette::Window, Qt::lightGray );
aboutwindow->setPalette( p );// Size the font. I have empirically determined maxWidth below.
int fontSize = 18;
int width = 0, maxWidth = 230;
QFont f;
f.setFamily("Times");aboutwindow->setFont(f);
QFontMetrics fm = aboutwindow->fontMetrics();
f.setPixelSize(fontSize);
aboutwindow->setFont(f);// Labelling above the group box
label = new QLabel(aboutwindow);
label->setText( labelText.c_str() );
label->setAlignment(Qt::AlignTop);aboutwindow->setGeometry(600, 400,285,300);
aboutwindow->setMinimumSize( 285, 300 );
aboutwindow->setMaximumSize( 285, 300 );aboutwindow->show();
}
@
[edit, code wraps added, koahnig] -
Please check out how "to wrap your code":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 while posting.