[Development] Replacement for QFont::ForceIntegerMetrics in Qt 6?

Kai Uwe Broulik kde at privat.broulik.de
Sat Nov 4 10:50:10 CET 2023


Hi everyone,

in Qt 5.15 the QFont::ForceIntegerMetrics was deprecated and 
subsequently removed in Qt 6.

The rendering engine in Konsole, KDE’s terminal emulator, relies on the 
fact that every glyph in the monospace font is rendered at the same 
width, since sections of different style (e.g. search highlight, text 
selection, various escape sequence formattings, etc) are painted in 
different pases, basically positioned at charWidth * letterXPos.

With Qt 6, without this flag, the individual letters might be placed at 
fractional positions, so a long text run can end up short of what the 
renderer expects, leading to gaps in the rendering, see the attached 
screenshot where I selected some text which now makes a gap.

I have read into QFontEngine a bit and found that the general 
replacement is disabling use of “design metrics”. I changed the 
rendering to use QPainter::paint with a QTextOption disabling design 
metrics [1], which fixed the issue on my machine but apparently causes 
issues with other fonts again.

Many of us have tried to find a solution for this but haven’t, really, 
and it is a major showstopper for the Qt 6 adoption here. Any idea how 
to address this properly, short of rewriting the renderer that I assume 
has been like this for decades or perhaps some insights on what prompted 
the removal?

Cheers
Kai Uwe

[1] https://invent.kde.org/utilities/konsole/-/merge_requests/911
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pngout.png
Type: image/png
Size: 3531 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20231104/3b6d91fd/attachment.png>


More information about the Development mailing list