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

Mac - Emojis like 5️⃣ are rendered wrong

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.3.2
    • GUI: Font handling
    • None
    • macOS

    Description

      Emojis that are combined from latin symbols with variation selectors are rendered badly.

      For example emoji 5️⃣

      https://apps.timwhitlock.info/unicode/inspect?s=5%EF%B8%8F
      (Unfortunately the link is broken, but this emoji may be inserted at the form on page and then inspected)

      Even if "Apple Color Emoji" font is added as substitution, it's not applied to this emoji, because starting symbol is from latin set.

      There's no way to use "Apple Color Emoji" as default font in applications, because it breaks text rendering in other cases. But it should properly substitute emojies.

      Sample:

      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
      
          auto defaultSystemFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
          QString defaultFontFamily = defaultSystemFont.family();
          QStringList fontSubstitutions = QStringList() << "Apple Color Emoji";
          QFont::insertSubstitutions(defaultFontFamily, fontSubstitutions);
          QFont applicationFont(defaultFontFamily);
          app.setFont(applicationFont);
      
          QQmlApplicationEngine engine;
          const QUrl url(QStringLiteral("qrc:/main.qml"));
          QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                           &app, [url](QObject *obj, const QUrl &objUrl) {
              if (!obj && url == objUrl)
                  QCoreApplication::exit(-1);
          }, Qt::QueuedConnection);
          engine.load(url);
      
          return app.exec();
      }
      
      import QtQuick
      import QtQuick.Controls
      import QtQuick.Layouts
      import QtQuick.Window
      
      
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
          
          ColumnLayout {
              anchors.fill: parent
              anchors.margins: 20
              
              Text { // Emojies are OK
                  Layout.fillWidth: true
                  wrapMode: Text.Wrap
                  font.family: 'Apple Color Emoji'
                  text: '☺️☹️☠️❤️♥️❣️✌️☝️✍️⚕️☘️☀️❄️☃️☁️⭐⚡☔⚓✈️♟️⌨️⚗️⚙️⚒️✏️✒️✉️⌚⚔️⚖️⚰️⚱️❤️⚪⚫⬜♐♏♎♍♌♋♊♉♈♑♒♓♀️♂️‼️⁉️🅾️🅱️🅰️♨️㊙️㊗️✴️🈷️▶️◀️⏏️⚠️〽️⚜️☣️☢️✳️❇️💱⬅️↙️⬇️↘️➡️↗️⬆️☑️↕️↔️↩️↪️⤴️⤵️🈂️5️⃣4️⃣3️⃣2️⃣1️⃣0️⃣*️⃣#️⃣6️⃣7️⃣8️⃣9️⃣Ⓜ️⚕️♿🅿️⚛️☪️☦️✝️☯️☮️☸️✡️♾️©️®️™️▪️◾◼️▫️◽◻️'
              }
      
              Text { // Rendered poorly, the spaces are too wide
                  Layout.fillWidth: true
                  wrapMode: Text.Wrap
                  font.family: 'Apple Color Emoji'
                  text: 'Hello, World' + ' ' + "Apple Color Emoji"
              }
      
              Text { // Emojies are broken
                  Layout.fillWidth: true
                  wrapMode: Text.Wrap
                  text: '☺️☹️☠️❤️♥️❣️✌️☝️✍️⚕️☘️☀️❄️☃️☁️⭐⚡☔⚓✈️♟️⌨️⚗️⚙️⚒️✏️✒️✉️⌚⚔️⚖️⚰️⚱️❤️⚪⚫⬜♐♏♎♍♌♋♊♉♈♑♒♓♀️♂️‼️⁉️🅾️🅱️🅰️♨️㊙️㊗️✴️🈷️▶️◀️⏏️⚠️〽️⚜️☣️☢️✳️❇️💱⬅️↙️⬇️↘️➡️↗️⬆️☑️↕️↔️↩️↪️⤴️⤵️🈂️5️⃣4️⃣3️⃣2️⃣1️⃣0️⃣*️⃣#️⃣6️⃣7️⃣8️⃣9️⃣Ⓜ️⚕️♿🅿️⚛️☪️☦️✝️☯️☮️☸️✡️♾️©️®️™️▪️◾◼️▫️◽◻️'
              }
      
              Text { // Rendered OK
                  Layout.fillWidth: true
                  wrapMode: Text.Wrap
                  text: 'Hello, World' + ' ' + font.family
              }
      
              Item {
                  Layout.fillHeight: true
                  Layout.fillWidth: true
              }
          }
      }
      

      P.S. This is probable not limited to macOS.

      Attachments

        1. Screenshot 2023-02-20 at 15.29.04.png
          13 kB
          Sergei Nevdakh
        2. Screenshot 2023-02-20 at 15.43.11.png
          483 kB
          Sergei Nevdakh

        Issue Links

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              sergei.nevdakh Sergei Nevdakh
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: