QMessageBox with Japanese characters gives "Missing font family" warning on macOS
-
I just upgraded from PySide2 to PySide6, and my application started giving me 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.
when I display Japanese.In building a MWE, I found that this only occurs when using certain Qt functionality, such as message boxes. Although it's not in the MWE, I'm seeing it also when using QTranslator. Note that I didn't specify any non-default fonts.
MWE below (adapted from the simple example given at https://doc.qt.io/qtforpython/quickstart.html). It shows the error occurring when you open a message box. If you comment out the lines mentioned, the error stops appearing even though the same characters appear.
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())
I'm running Python 3.9.7 and PySide6 6.2.2 on macOS Big Sur 11.6.1.
-
Hi,
How did you install Python and PySide6 ?
-
-
@efremdan1 said in QMessageBox with Japanese characters gives "Missing font family" warning on macOS:
In building a MWE, I found that this only occurs when using certain Qt functionality, such as message boxes.
When does it show the Japanese (and Cyrillic) characters correctly and when does it show it incorrectly?
-
@mchinand said in QMessageBox with Japanese characters gives "Missing font family" warning on macOS:
When does it show the Japanese (and Cyrillic) characters correctly and when does it show it incorrectly?
In the example, it always shows Cyrillic characters without any error messages. Japanese characters are also always shown correctly; however, an error message is shown (with an accompanying delay of ~713 ms) when the characters appear in a QMessageBox. If the QMessageBox isn't present, and the characters are only appearing in the QLabel, no error message is shown.
-
There must have been a change in the backend somewhere. I can reproduce it on Catalina with the latest PySide 6 (pyside6-6.2.2.1)
It would recommend checking the bug report system to see if it's something known. The message does not appear with PySide2.