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

Investigate support for smarter DPR support in text layouts

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.9
    • GUI: Text handling
    • None
    • All

      When the system is scaling for high-dpi, we disable font hinting by default in Qt. This is because font hinting makes less sense in cases where the screen density is high (it is a technology specifically to increase legibility on low-resolution rasterization) and because hinted text layouts do not scale linearly, so you can't make a hinted text layout at font size N and expect it to look correct when you scale everything up by e.g. 2x.

      An idea to making Qt smarter in this area is to provide API for setting the DPR on the layout: QTextLayout::setDevicePixelRatio(). This would scale the font by the DPR before creating the layout, and then it would scale down the glyph positions we get by 1/DPR. When we later draw this with a scale of DPR, the glyph positions become the correct hinted positions.

      There may be issues with this, but it's worth investigating. Internally we could use this whenever we know the target device of the text layout, such as in the scene graph or when drawing text with QPainter::drawText().

      The DPR could default to 1.0, in which case everything would work as before.

      One thing to consider is whether this would mean that we can remove the logic that automatically disables hinting when the DPR is > 1. Anyone creating their own QTextLayouts which do not set this DPR will get a regression in that case. However, this is something to consider later.

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

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

              Created:
              Updated:

                There are no open Gerrit changes