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

QMessageBox with Japanese characters gives "Missing font family" warning on macOS

    XMLWordPrintable

Details

    • macOS
    • 69d525a6fa (qt/qtbase/dev) 69d525a6fa (qt/tqtc-qtbase/dev) fcd5a02886 (qt/qtbase/6.3) fcd5a02886 (qt/tqtc-qtbase/6.3) fcd5a02886 (qt/tqtc-qtbase/6.3.0) 64dd5a8183 (qt/tqtc-qtbase/dev) 36427480dd (qt/qtbase/6.3) 34d9da8371 (qt/qtbase/6.2)

    Description

      When Japanese fonts are used in a QMessageBox, the error `qt.qpa.fonts: Populating font family aliases took 713 ms. Replace uses of missing font family ".AppleSystemFallback" with one that exists to avoid this cost` appears. This error does not appear when Japanese fonts are used in a standard QLabel.

      The error also appears when Japanese fonts are used in other places, such as when QTranslator is used, so the bug is not specific to QMessageBox; it just doesn't appear everywhere.

      I'm running Python 3.9.7 and PySide6 6.2.2 on macOS Big Sur 11.6.1.

      MWE:

      import sys
      import random
      from PySide6 import QtCore, QtWidgets, QtGui
      
      class MyWidget(QtWidgets.QWidget):
          def __init__(self):
              super().__init__()
      
              self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир", "こんにちは世界"]
      
              self.button = QtWidgets.QPushButton("Click me!")
              self.text = QtWidgets.QLabel("Hello World",
                                           alignment=QtCore.Qt.AlignCenter)
      
              self.layout = QtWidgets.QVBoxLayout(self)
              self.layout.addWidget(self.text)
              self.layout.addWidget(self.button)
      
              self.button.clicked.connect(self.magic)
      
          @QtCore.Slot()
          def magic(self):
              self.text.setText(random.choice(self.hello))
              # Commenting out the next 4 lines makes error disappear
              msgBox = QtWidgets.QMessageBox()
              msgBox.setIcon(QtWidgets.QMessageBox.Information)
              msgBox.setText("こんにちは世界") # NB: Replacing the Japanese characters in the message box with Привет мир also makes the error disappear, so the issue is specific to only certain character sets.
              msgBox.exec()
      
      if __name__ == "__main__":
          app = QtWidgets.QApplication([])
      
          widget = MyWidget()
          widget.resize(800, 600)
          widget.show()
      
          sys.exit(app.exec())
      

       

      See https://forum.qt.io/topic/132657/qmessagebox-with-japanese-characters-gives-missing-font-family-warning-on-macos for more discussion.

      Attachments

        For Gerrit Dashboard: QTBUG-99216
        # Subject Branch Project Status CR V

        Activity

          People

            vestbo Tor Arne Vestbø
            efremdan1 Efrem Braun
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: