[Development] QSGText: Why round glyph position like this?

Eskil Abrahamsen Blomfeldt Eskil.Abrahamsen-Blomfeldt at qt.io
Tue Aug 29 13:07:50 CEST 2023


Hi!

The reason for rounding is that the subpixel position of the glyphs is baked into the cached rendering of the glyph itself (so horizontal position x.5 would be a different cached object than x.0, but they should both be rendered at pixel x). It's a bit complex because the projected positions of the glyphs are calculated later, in the vertex shader, so you need to do some precalculation to produce something which aligns with the pixel edge when the final scale is applied. I believe the reason retina is mentioned there specifically is just because it's the first place we supported DPI-scaling, but it's not exclusive to Apple anymore.

Which Qt version is in use here? I did fix some bugs related to this, e.g. https://codereview.qt-project.org/c/qt/qtdeclarative/+/417675 and https://codereview.qt-project.org/c/qt/qtdeclarative/+/376361

Most of my testing was on Windows, though, so it sounds like there could still be issues on Wayland.


Eskil Abrahamsen Blomfeldt
Senior Manager, Graphics

The Qt Company
Sandakerveien 116
0484 Oslo, Norway
eskil.abrahamsen-blomfeldt at qt.io
http://qt.io

________________________________
From: Development <development-bounces at qt-project.org> on behalf of Kai Uwe Broulik <kde at privat.broulik.de>
Sent: Monday, August 28, 2023 6:22 PM
To: development at qt-project.org <development at qt-project.org>
Subject: [Development] QSGText: Why round glyph position like this?

Hi everyone,

while investigating blurry font with native renderer in QML apps in
Plasma 6 under Wayland with fractional scaling (devicePixelRatio 1.75 in
my case), I stumbled upon QSGTextMaskMaterial::populate which rounds the
glyph position [1] citing Mac OS behavior.

When I remove the rounding, font appears rendered correctly on my system
(sorry for attachment ;), but this code hasn’t changed since 2014 and I
am not very knowledgeable in this part of Qt. It’s also flooring the X
and rounding the Y coordinate.

What’s the deal with that? Tor Arne, can you perhaps shed some light on
this?

Cheers
Kai Uwe

[1]
https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp#n455
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230829/5c500792/attachment-0001.htm>


More information about the Development mailing list