Hi,
thanks, QFont::PreferFullHinting seems to do the trick.
I actually had that set for testing and thought
QTextOption::setDesignMetrics(false) was the fix (after reading a bit of
QFontEngineFT) but it was the hinting all along :-)
Thanks!
Cheers Kai Uwe
Am 06.11.23 um 12:04 schrieb Eskil Abrahamsen Blomfeldt:
Hi!
ForceIntegerMetrics was originally added to get CoreText to look at
little bit better with WebKit, since WebKit did not support subpixel
positioning at the time and CoreText did not support font hinting. I
removed it in Qt 6 because it's honestly not a typographically sensible
thing to do, and the original use case had become irrelevant 🙂
For your case, where you want to make sure your font aligns to the pixel
grid, you could try enabling hinting on it with
font.setHintingPreference(QFont::PreferFullHinting). Font hinting will
slightly alter the glyphs so that they actually align to the pixel grid
instead of introducing kerning errors (which is what ForceIntegerMetrics
did). I'm not sure if this is what you mean by "disabling design
metrics"? If so, what exactly was the issue with it? I principle, I
think this is the most correct solution to the problem, so maybe there's
some way of getting it to work.
If that does not work, then another option is to manually get the
QGlyphRuns from the QTextLayout and align the glyphs yourself before
drawing them. That should get you the same layout as with
ForceIntegerMetrics, both good and bad, without much extra work.
(Of course, ideally the rendering code should not assume integer
advances for the characters, since this is not really a reasonable
expectation for unhinted, scalable fonts, but I can see how it's not
tempting to rewrite it just for this port.)
Eskil Abrahamsen Blomfeldt
Senior Manager, Graphics
--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development