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. Qt 5.7.0 Font Rendering Problem
Forum Updated to NodeBB v4.3 + New Features

Qt 5.7.0 Font Rendering Problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 2.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.
  • M Offline
    M Offline
    mireiner
    wrote on 23 Aug 2016, 19:35 last edited by mireiner
    #1

    Hi there,

    I got a QWidget / QPainter font rendering problem on Windows 10 64 bit desktop using Qt 5.7.0.

    Look the following screenshots. Using Qt the space between 'tt' and 'ti' is missing at Calibri and Carlito font:

    Qt: https://s19.postimg.org/dzl1pst8z/image.png

    Wordpad (Windows): https://s19.postimg.org/9rq9h1rtf/Wordpad_Windows.png

    LibreOffice: https://s19.postimg.org/9t07agtn7/Libre_Office.png

    Sourcecode of the Qt screenshot:

    #include <QApplication>
    #include <QWidget>
    #include <QPainter>
    
    class Widget : public QWidget
    {
    public:
    	Widget();
    
    protected:
    	void paintEvent(QPaintEvent *);
    };
    
    Widget::Widget()
    {
    	setAutoFillBackground(true);
    	setPalette(Qt::white);
    }
    
    void Widget::paintEvent(QPaintEvent *)
    {
    	QPainter painter(this);
    
        painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
    
        QFont Calibri_18_Normal("Calibri", 22, QFont::Normal);
        QFont Calibri_18_Bold("Calibri", 22, QFont::Bold);
        QFont Arial_18_Normal("Arial", 22, QFont::Normal);
        QFont Arial_18_Bold("Arial", 22, QFont::Bold);
        QFont Carlito_18_Normal("Carlito", 22, QFont::Normal);
        QFont Carlito_18_Bold("Carlito", 22, QFont::Bold);
    
        int y = 100;
    
        painter.setFont(Calibri_18_Bold);
        painter.drawText(200, y += 40, "Qt: Look for missing space between 'tt' and 'ti'");
    
        painter.setFont(Calibri_18_Normal);
        painter.drawText(200, y += 80, "Calibri: Rating Betting Setup - (Windows Clear Type)");
        painter.setFont(Calibri_18_Bold);
        painter.drawText(200, y += 40, "Calibri: Rating Betting Setup - (Windows Clear Type)");
    
        painter.setFont(Arial_18_Normal);
        painter.drawText(200, y += 80, "Arial: Rating Betting Setup - (Windows)");
        painter.setFont(Arial_18_Bold);
        painter.drawText(200, y += 40, "Arial: Rating Betting Setup - (Windows)");
    
        painter.setFont(Carlito_18_Normal);
        painter.drawText(200, y += 80, "Carlito: Rating Betting Setup - (Open Source, LibreOffice)");
        painter.setFont(Carlito_18_Bold);
        painter.drawText(200, y += 40, "Carlito: Rating Betting Setup - (Open Source, LibreOffice)");
    }
    
    int main(int argc, char *argv[])
    {
    	QApplication app(argc, argv);
    	Widget widget;
    	widget.showMaximized();
    	return app.exec();
    }
    
    K 1 Reply Last reply 23 Aug 2016, 19:41
    0
    • M mireiner
      23 Aug 2016, 19:35

      Hi there,

      I got a QWidget / QPainter font rendering problem on Windows 10 64 bit desktop using Qt 5.7.0.

      Look the following screenshots. Using Qt the space between 'tt' and 'ti' is missing at Calibri and Carlito font:

      Qt: https://s19.postimg.org/dzl1pst8z/image.png

      Wordpad (Windows): https://s19.postimg.org/9rq9h1rtf/Wordpad_Windows.png

      LibreOffice: https://s19.postimg.org/9t07agtn7/Libre_Office.png

      Sourcecode of the Qt screenshot:

      #include <QApplication>
      #include <QWidget>
      #include <QPainter>
      
      class Widget : public QWidget
      {
      public:
      	Widget();
      
      protected:
      	void paintEvent(QPaintEvent *);
      };
      
      Widget::Widget()
      {
      	setAutoFillBackground(true);
      	setPalette(Qt::white);
      }
      
      void Widget::paintEvent(QPaintEvent *)
      {
      	QPainter painter(this);
      
          painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
      
          QFont Calibri_18_Normal("Calibri", 22, QFont::Normal);
          QFont Calibri_18_Bold("Calibri", 22, QFont::Bold);
          QFont Arial_18_Normal("Arial", 22, QFont::Normal);
          QFont Arial_18_Bold("Arial", 22, QFont::Bold);
          QFont Carlito_18_Normal("Carlito", 22, QFont::Normal);
          QFont Carlito_18_Bold("Carlito", 22, QFont::Bold);
      
          int y = 100;
      
          painter.setFont(Calibri_18_Bold);
          painter.drawText(200, y += 40, "Qt: Look for missing space between 'tt' and 'ti'");
      
          painter.setFont(Calibri_18_Normal);
          painter.drawText(200, y += 80, "Calibri: Rating Betting Setup - (Windows Clear Type)");
          painter.setFont(Calibri_18_Bold);
          painter.drawText(200, y += 40, "Calibri: Rating Betting Setup - (Windows Clear Type)");
      
          painter.setFont(Arial_18_Normal);
          painter.drawText(200, y += 80, "Arial: Rating Betting Setup - (Windows)");
          painter.setFont(Arial_18_Bold);
          painter.drawText(200, y += 40, "Arial: Rating Betting Setup - (Windows)");
      
          painter.setFont(Carlito_18_Normal);
          painter.drawText(200, y += 80, "Carlito: Rating Betting Setup - (Open Source, LibreOffice)");
          painter.setFont(Carlito_18_Bold);
          painter.drawText(200, y += 40, "Carlito: Rating Betting Setup - (Open Source, LibreOffice)");
      }
      
      int main(int argc, char *argv[])
      {
      	QApplication app(argc, argv);
      	Widget widget;
      	widget.showMaximized();
      	return app.exec();
      }
      
      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 23 Aug 2016, 19:41 last edited by kshegunov
      #2

      @mireiner
      It's not a problem with the rendering, it's a problem with your fonts.
      Choose fonts without ligatures if you don't want them rendered.

      Kind regards.

      Read and abide by the Qt Code of Conduct

      M 1 Reply Last reply 23 Aug 2016, 19:56
      1
      • K kshegunov
        23 Aug 2016, 19:41

        @mireiner
        It's not a problem with the rendering, it's a problem with your fonts.
        Choose fonts without ligatures if you don't want them rendered.

        Kind regards.

        M Offline
        M Offline
        mireiner
        wrote on 23 Aug 2016, 19:56 last edited by mireiner
        #3

        @kshegunov
        But why are doing the native Windows program 'WordPad' and 'LibreOffice' on Windows (based on JAVA) just fine? They all got spaces between 'tt' and 'ti'.

        Before I began Qt programming I did Microsoft MFC programming. MFC applications on Windows also got spaces between 'tt' and 'ti' using these fonts.

        Without spaces between 'tt' and 'ti' the fonts looks ugly to me.

        K 1 Reply Last reply 23 Aug 2016, 19:58
        0
        • M mireiner
          23 Aug 2016, 19:56

          @kshegunov
          But why are doing the native Windows program 'WordPad' and 'LibreOffice' on Windows (based on JAVA) just fine? They all got spaces between 'tt' and 'ti'.

          Before I began Qt programming I did Microsoft MFC programming. MFC applications on Windows also got spaces between 'tt' and 'ti' using these fonts.

          Without spaces between 'tt' and 'ti' the fonts looks ugly to me.

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 23 Aug 2016, 19:58 last edited by
          #4

          @mireiner said:

          But why are doing the native Windows program 'WordPad' and 'LibreOffice' on Windows (based on JAVA) just fine?

          No idea. My suspicion is that it depends how exactly the text rendering is done at the low-level (how the API is used). Sadly I don't know of a way to disable the ligatures in Qt.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          1

          1/4

          23 Aug 2016, 19:35

          • Login

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