Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Using Colour Emojis as a substitution font in Windows
my application is using MS Shell Dlg 2 font on windows. When an emoji is used on a QLabel or QLineEdit the emoji shows as black and white. It is my understanding that when an character is not available in a font, qt will try to find a replacement from the fonts available for the application http://doc.qt.io/qt-5/qfont.html#fontmatching
When I use QFont::insertSubstitution(font().family(), "Segoe UI Emoji"); the result is b/w emojis.
I also tried setStyleSheet(QString("font-family: 'MS Shell Dlg 2', 'segoe ui emoji', 'segoe ui symbol';")); but no luck.
When I set the font of the widget to use "Segoe UI Emoji" font, then the color emojis are used.
When I try the same on linux (with different system and emojis fonts) with insertSubstitution it works like a charm. Any ideas how can I get the behaviour I want? (that is use a font for characters and a different font of my preference for emojis). How can I make the font matching algorithm to do this?
Thank you for your time in advance 😃
Hi and welcome to devnet,
Can you provide a minimal sample code that reproduce this behaviour ?
What version of Qt are you using ?
On what version of Windows ?
boring32 last edited by VRonin
Thank your for your reply.
Currently using Windows 10 + Qt 5.8 but I will check with 5.10 as well.
Here is a code sample demonstrating the issue:
QApplication app(argc, argv); QWidget *mainWindow = new QWidget(); QLayout *layout = new QVBoxLayout(); QLabel *widget1 = new QLabel(); QLabel *widget2 = new QLabel(); QLabel *widget3 = new QLabel(); QFont::insertSubstitution(QApplication::font().family(), "Segoe UI Emoji"); widget1->setText("B/W Emoji \xF0\x9F\x92\xA4"); widget1->setFont(QFont("Sans Serif")); widget2->setText("Color Emoji \xF0\x9F\x92\xA4"); widget2->setFont(QFont("Segoe UI Emoji")); widget3->setText("Should be Color Emoji \xF0\x9F\x92\xA4"); layout->addWidget(widget1); layout->addWidget(widget2); layout->addWidget(widget3); mainWindow->setLayout(layout); mainWindow->show(); return app.exec();
Tried with Qt 5.10 and getting the same result.
Here is a screen grab of the code above:
How did you install that font in your system ?
It is part of windows 10, a native font installed with windows.
Currently on Windows 10 build 1709.
Strange, it sounded like QTBUG-57717 but it should work.
Do you think I should file a bug report for this?
If you can't find anything else on the bug report system then yes.
Can you check with the latest test version of 5.11 before doing that ?
Just tried 5.11 beta and still there.
I will check the bugs again and then report.
Thank you for your help @SGaist
dr_W last edited by
@boring32 In the above example, have you tried using emoji on win7? Why does the use of emoji color on win7 turn black and white?
tofutim last edited by tofutim
I wanted to report that when I use 5.9.4 MinGW the color emoji shows up as BW but when I use 5.9.4 MSVC2017 the color emoji shows up as color. Is there anything I can do to get MinGW to work? Same in 5.11.
I'm using a blank project with a single color emoji in the screen.
If I compile with MSVC2017 then it shows up in color.