Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.9
-
None
Description
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.
Attachments
Issue Links
- resulted from
-
QTBUG-129731 Fonts look less crisp on a setup with mixed scale factors
- In Review