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

Assertion violation in text shaping on special string with EmojiOneColor font.

    XMLWordPrintable

Details

    • Linux/X11, Windows
    • fccd419dd632306a4bd85928223e0a56a59510ef (qt/qtbase/dev) dbaac6e5c1c1725055187bd5473f95de78f5b408 (qt/tqtc-qtbase/tqtc/lts-5.15) ed3edec3bacb4f2000f8732ba12e90c353c2c543 (qt/qtbase/6.0) 065527825e19a8a5eb2efa0ab481980dc86ad58a (qt/qtbase/6.1)

    Description

      This code:

      QFontDatabase::addApplicationFont("EmojiOneColor-SVGinOT.ttf");
      auto image = QImage(256, 256, QImage::Format_ARGB32_Premultiplied);
      const auto string = QString() + QChar(8205) + QChar(9794) + QChar(65039);
      auto p = QPainter(&image);
      p.setFont(QFont("Emoji One Color"));
      p.drawText(0, 0, string);
      

      With "EmojiOneColor-SVGinOT.ttf" file being in the app folder (so it could load the font) crashes with assertion violation in text shaping:

      ASSERT failure in Q_UNREACHABLE(): "Q_UNREACHABLE was reached", file text\qtextengine.cpp, line 1551. (for Qt 5.15.2)

      This leads to crashes in production for my project =(

      UPD

      I've done some debugging, the minimal example is now this:

      QFontDatabase::addApplicationFont("EmojiOneColor-SVGinOT.ttf");
      const auto metrics = QFontMetrics(QFont("Emoji One Color"));
      const auto width = metrics.horizontalAdvance(QString() + QChar(8205));
      

      This appears when a font doesn't have a glyph for a space (' ') and we try to shape a string, that contains only "default ignorables" (in this example - only one). Then hb_ot_hide_default_ignorables() tries to replace it by space (' '), but the space is not in this font, so it removes the glyph and tries to merge clusters. But this is the only character, so the shaped buffer is empty, it doesn't have any glyphs at all and Qt asserts that it should have at least one glyph.

       

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            johnpreston John Preston
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes