Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Fonts Look Bad
Qt 6.11 is out! See what's new in the release blog

Fonts Look Bad

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brandon
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Please check out how "to wrap your code":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 while posting.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved