[PyQt] PYQt defaults to fonts looking bold on macOS but C++ Qt does not

Barry Scott barry at barrys-emacs.org
Tue Jul 26 13:34:06 BST 2016


> On 26 Jul 2016, at 13:27, Phil Thompson <phil at riverbankcomputing.com> wrote:
> 
> On 26 Jul 2016, at 1:10 pm, Barry Scott <barry at barrys-emacs.org> wrote:
>> 
>> 
>>> On 6 Jul 2016, at 11:50, Phil Thompson <phil at riverbankcomputing.com> wrote:
>>> 
>>> On 6 Jul 2016, at 11:26 am, Barry Scott <barry at barrys-emacs.org> wrote:
>>>> 
>>>> Compare the windows snapshots taken for a PyQt5 app and a C++ Qt5 app
>>>> that use a QLabel control.
>>>> 
>>>> http://www.barrys-emacs.org/export/Qt5.png
>>>> 
>>>> http://www.barrys-emacs.org/export/PyQt5.png
>>>> 
>>>> You can see that the text in PyQt5 looks like it is bold compared to the
>>>> Qt5 version.
>>>> 
>>>> On Fedora I see that same text for Qt5 and PyQT5.
>>>> 
>>>> Please fix this problem in PyQt5.
>>>> 
>>>> The source code I used is in:
>>>> 
>>>> http://barrys-emacs.org/export/font-example.tar.gz
>>>> 
>>>> Note: This bug affects all text, list, tables, line edit everything.
>>> 
>>> ...on your system. It works fine for me. PyQt does nothing with fonts.
>> 
>> Phil,
>> 
>> I know what macOS preference changes this behaviour.
>> 
>> In "System Preferences…”, “General” there is a property,
>> “Use LCD font smoothing when available” (bottom of the dialog).
>> If this is ticked PyQt5 text is bold in appearance.
>> When it is not ticked it looks normal.
>> 
>> But this setting does not change the output of a Qt5 C++ app.
>> 
>> Can you reproduce this problem now?
> 
> Then it is probably related to the Info.plist. Qt will create one that is appropriate to its needs, but Python doesn't have one. As far as I am aware there is nothing PyQt can do about this.

The Info.plist does not seem to have anything for fonts in it,
I’ll research and report back if I find anything interesting.

I have been using this in my app as a work around:

        if sys.platform == 'darwin':
            self.font.setStyleStrategy( self.font.NoSubpixelAntialias )

Barry



More information about the PyQt mailing list