All my fonts are appearing pixelated, so I used AntiAliasing but it isn't helping out. As you can see the pixelated font in the image itself:
This is the code I am currently using:
butt1 = QtWidgets.QLabel("""Scrappr""")
font = QtGui.QFont()
font.setStyleStrategy(QtGui.QFont.PreferAntialias)
font.setPixelSize(22)
font.setFamily('Segoe UI Bold')
butt1.setFont(QtGui.QFont(font))
I tried different solutions on SO, qtforums etc but nothing works for me :(
I tried:
Different combinations of ClearType text but It didn't work out as, by default all the text appears good on windows and chrome but with Qt only, it becomes pixelated.
Changing windows aero theme to classic one...
But none of them helped.
Here are My PC Specs:
windows: 7 ultimate
PySide2 version: 5.14.2.1
Resolution: 1360 X 768
I'm using BrownPro font and the texts were blurry at all resolutions, but much more evident at low resolutions.
I was able to solve the issue by setting the hinting preference for the font to: PreferNoHinting. Applying it at the application level, fixes the issue everywhere.
Here is the documentation: https://doc.qt.io/qt-5/qfont.html#HintingPreference-enum
And here is the code I used:
QFontDatabase::addApplicationFont(":/fonts/BrownPro-Bold.ttf");
QFontDatabase::addApplicationFont(":/fonts/BrownPro-Regular.ttf");
QFontDatabase::addApplicationFont(":/fonts/BrownPro-Light.ttf");
QFont brown_pro_font("BrownPro");
brown_pro_font.setHintingPreference(QFont::HintingPreference::PreferNoHinting); //This line did the trick
QApplication::setFont(brown_pro_font);
Try to see the fonts used by PyQt5:
import PyQt5
from pyQt5 import QtGui
dir(QtGui.QFont)
the result will show all you need for QFond and the fonts can be used:
[..., 'Helvetica',...,'SansSerif',..., 'Serif',..., 'Times', ...
You can try to add your custom fonts but you need to test each font.
For example, the documentation tells us:
In Windows a request for the “Courier” font is automatically changed to “Courier New”, an improved version of Courier that allows for smooth scaling. The older “Courier” bitmap font can be selected by setting the PreferBitmap style strategy (see setStyleStrategy() ).
Once a font is found, the remaining attributes are matched in order of priority:
fixedPitch()
pointSize() (see below)
weight()
style()
I happen to work with Qt last year and i used qml for building the UI part of my application.
Qt itself prefers us to use qml for building UI, since they have written a UI engine that renders everything better compared to the old engines.
In case of PyQt you are using the python only approach which is only not usually recommended, i am not saying that the qml version is pixel perfect. it still works bad at drawing curves (but that is not the stuff we usually require). As far as your problem is concerned qml will work fine for you (it has much better text rendering).
You might struggle a bit finding the learning resource for qml. But at least give it a shot and yes it is easier much easier than Python only approach.
I'm working on a PyQt4 GUI. My issue is that it looks very different when I run the code from windows or linux. I think the main reason is the difference in default font size between platforms. With that in mind, I wanted to change the font size of the pyqtgraph's ParameterTree. How can I do that?
If you have a more general answer that could help solving all the differences, it would be greatly appreciated.
I wrote a GUI for my desktop a while ago and have just tried to run it on a surface pro 3 only to find the fonts are all exceeding their bounding boxes. Labels are exceeding the worst. Disabling the bold attribute helps when it comes to buttons but not by much.
I have checked to make sure the chosen fonts are compatible for both devices.
Has anyone else encountered this issue and know of a fix for it?
Thanks,
I am dealing with a splash screen logo and I've noticed that on different OS versions this image gets distorted, but it happens to work when dealing with Windows 8.1, but not on Windows 7 or Vista. I've been using Adobe Fireworks in conjunction with Illustrator to generate it, and I must have tried a ton of different settings but I can't get the same experience across all operating systems.
I load it into my WiX project as follows:
<Binary Id="SplashBinary" SourceFile="Splash.jpg"/>
And I use it like so:
<Control Id="SplashBitmap" Type="Bitmap" X="0" Y="0" Width="373" Height="252" Text="SplashBinary" TabSkip="yes" Sunken="no" Disabled="yes" />
I've tried using the width and height above but it would not look good on 8.1 (too blurry), so I doubled it on the image to get a crisper result in Windows 8.1 (its perfect in 8.1). But again, it looks like its aliasing is messed up on 7 and Vista. Can anyone shed some light as to what I need to do to get a consistent experience? What do I need to do to my image to export it such that it renders a nice crisp result on these platforms?
I got it to work by scaling my image up by an exact factor of 1.3333333333 (I got this idea from this question):
[ Width ] -> 373 * 1.3333333333 = 497.3333333209
[ Height ] -> 252 * 1.3333333333 = 335.9999999916
This is the stupidest thing I've ever had to do. I don't know why this is the case. However, it now looks fantastic on all operating systems. I'm so displeased by this being a necessary step. PS: I also have my image at a resolution of 300 PPI.
Does anyone know a working PNG transparency fix for IE6 that also works on background images (of divs)? All that I tried (over 5) do not fix background images consistently. Adobe Browser Lab shows it's fixed but the target browsers still get that bluish transparency.
Thank you.
Have you tried this one?
http://www.twinhelix.com/css/iepngfix/