Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-128402

Trouble with QFontDatabase::addApplicationFont

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.15.8, 6.7.2
    • GUI: Font handling
    • None
    • Windows /Linux/ macOS
    • All

    Description

      I added the Poppins-Light.ttf font to the application and noticed that this font has a different name on Windows than on macOS

      The simple code below returns:
      "Poppins Light" under Windows
      "Poppins" under macOS and linux

      #include <QFontDatabase>
      #include <QApplication>
      #include <QDebug>
      
      int main(int argc, char *argv[]){
          QApplication a(argc, argv);
          int fid= QFontDatabase::addApplicationFont(":/fonts/Poppins-Light.ttf");
          qDebug() << "font #" << fid << "families=" << QFontDatabase::applicationFontFamilies(fid);
          return a.exec();
      }
      

      The Poppins is a popular font provided by Google, you can download it from: fonts.google.com/specimen/Poppins .

      This is a big problem because the font name is used in many places in the stylesheets.
      I wouldn't want to create different styles depending on the operating system

      Attached are photos of the font preview in Windows/Linux/Mac, on all systems the font is called "Poppins Light".
      Why does Qt say it's called "Poppins"? (macOS and Linux only)

      If there is no way to get the correct font name, consider adding an additional parameter to the function and let me determine it myself

      Attachments

        1. font-preview-linux.png
          font-preview-linux.png
          161 kB
        2. font-preview-macos.png
          font-preview-macos.png
          275 kB
        3. font-preview-window.png
          font-preview-window.png
          242 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            linusklan Krzysztof Guc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes