QSyntaxHighlighter text quality

John Sturtz john at sturtz.org
Mon Nov 3 03:21:50 GMT 2025


Hi again.

With some trepidation, I have a question about fonts again.  Not so much 
about fonts in general, but about display quality of the font I am 
using.

I have a QTableView with a custom delegate.  The delegate editor is 
implemented as a QPlainTextEdit widget which has a QSyntaxHighlighter 
associated with it.

I am loading a .ttf file at runtime and using it as the display font.  
Initially the quality is pretty poor everywhere [attached screenshot 
initial.png].

I found online the suggestion to create a font object, call 
.setHintingPreference(PreferNoHinting) on it, then apply that to the 
QApplication object [lines #175-177].  That seems to improve the display 
significantly.

Except for the text displayed by the syntax highlighter.  That text is 
still pixelated [attached screenshot highlighter.png].  It's as though 
the .setHintingPreference() call doesn't affect the syntax highlighter.

Wondering if there's any way around this?

Thanks again!

/John

[Sample code, screenshots and font file are attached]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20251103/c2fc1d46/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 5133 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20251103/c2fc1d46/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Montserrat-VariableFont_wght.ttf
Type: application/octet-stream
Size: 688600 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20251103/c2fc1d46/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: initial.png
Type: image/png
Size: 10186 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20251103/c2fc1d46/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: highlighter.png
Type: image/png
Size: 12368 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20251103/c2fc1d46/attachment-0003.png>


More information about the PyQt mailing list