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

Attempting to render glyphs that don't exist in a given font with the DirectWrite font engine behaves strangely and can crash

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 4.8.0
    • GUI: Font handling
    • None
    • Windows 7
    • 69fb70f6b3c88d4d2bb5ca97dbb7f77f42c828c5

    Description

      With the GDI font engine, rendering glyphs that aren't present in a given font will gracefully fall back to a font that does contain the glyphs, and render them correctly. For example, rendering Japanese or Chinese text in Times New Roman will display correctly, even though the font doesn't contain those glyphs. In DirectWrite however, these glyphs don't display, and in fact very odd things happen - you get fragments of glyphs drawing at enormous sizes offset from the glyph's true position.

      To see what I mean, build and run the attached test app, then:

      1. Switch off the 'DirectWrite' checkbox.
      2. Switch on the 'Japanese' radio button.
      3. Observe that the Japanese glyphs display fine with GDI, falling back to some Japanese-aware font when T.N.R. is used.
      4. Try the same with the 'Chinese' radio button - also works.
      5. Now switch back to 'English' and turn on 'DirectWrite'.
      6. Switch to 'Japanese'. Note a distinct lag between clicking this and the next redraw.
      7. The text is gone.
      8. Click on the window maximise button to make the window fill the screen.
      9. Observe some strange glyph fragments being drawn towards the bottom of the window.

      In our real application, we've seen crashes in QImageTextureGlyphCache::fillTexture with Chinese text, where presumably it's failing to allocate sufficient memory for a truly huge Chinese glyph.

      Another strange thing is that these corrupted glyphs seem to be in inverse proportion to the size requested. Open mainwindow.cpp in my test app and change setPixelSize(50) for setPixelSize(100), then run it again: you'll see that the Japanese glyph that DirectWrite is trying to draw is now much smaller, though still incorrect.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            jlarcombe James Larcombe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes