Why same font style show different on windows and linux by QT - c++

I do not use linux x11 windows system, and keep same font family on these two OS, and turn the text to image then save it.I use tahoma.ttf font in QT,set styleStrategy to NoAntialias and set font point size to 7, but on windows
"e""a" looks pretty good on windos.
But on linux :
I am pretty sure the font size is same, because if set pointsize to 8, e will cost 5x6 pixel.
I try the freetype lib on windows not using QT. The result is almost the same with QT in window, so I wonder how to make text the same with windows style.
It looks like that QT 4.7.4 have did included freetype lib, and I try the freetype interface in Qt lib, it shows the same effect with original no modifed Qt qfontengine_ft.cpp.

Related

QPdfWriter not embedding standard fonts properly since Qt 6.0.0

Since switching to QT 6.0.0 I got problems with QPdfWriter. Every Time I try to print a text, the embedded font couldn't get loaded from various pdf reader (even Adobe reader). I'm as well not getting any errors or anything else on the output.
QPdfWriter writer("C:/Users/GGG/Desktop/lol.pdf");
writer.setResolution(300);
writer.setPageSize(QPageSize(QPageSize::A4));
writer.newPage();
QPainter painter;
painter.begin(&writer);
painter.drawText(600,600,"Hello, this is a test");
painter.end();
My attempts:
Check the doc's and internet -> didn't found anything useful
read out the font (there is one embedded, but faulty)
Change font of QPainter to "Calibri"
check if the font is available with db.hasFamily("Calibri"); (return value = true)
Check graphics card driver -> installed rightly, no updates available .
Rebuild with Qt 5.15.2 (in both cases MinGW64) -> Font is embedded correctly. But gone if I turn back to Qt version 6.0.0
Checked my QT components -> I have installed for Qt 6.0.0: MinGW 8.1.0 64Bit, Sources, Qt 5 compatibility Module, Qt Shader Tools, Qt Debug Information Files.
tried the same with QPrinter which prints Pdf files - same behaviour.
Still no clue what could cause this behavior. Does anyone got the same fault or has a solution?
Information about my system:
Windows 10, 64bit - used fonts are installed
Qt creator 4.14.0 - MinGW64 with Qt 6.0.0
Finally, after research on other forums like forum.qt.io I found out it might be a bug.
There's alredy a bugreport open -> https://bugreports.qt.io/browse/QTBUG-89727
edit: Turned out it was a bug - wich is fixed now. As the bugfixer wrote:
Very nice and subtle bug - the container size was changed from int32_t
to int64_t and the font serialization simply used QByteArray::size()
without a cast.
Bugfix here: https://codereview.qt-project.org/c/qt/qtbase/+/329442

Pop up window of Code::bloks on Windows 10

I'm learning OpenCV on Windows and I am using Code::bloks. When I call the funciotion of imshow() it will show a pop up window where is the image. The problem is that I can't zoon this windows so I can't see pixels values.
You can't zoom in an OpenCV default Window, this is not functionality built into the core OpenCV libraries
You can however build this functionality yourself, especially if you build using Qt. Here is an example

AddFontResource does not install the font correctly

I use AddFontResourceW(_T("C:\Program Files\MyApp\MyFont.ttf")); to install 2 fonts from my 64-bit C++ app.
The return value is 1, but in the app the font is displayed 10 times smaller and look like Sans Serif (not my font).
If I manually install the font in Windows, then it is displayed correctly in the app.
I have tried AddFontResourceEx, but the same result. I also have tried to copy the TTF font file in C:\Windows\Fonts with my app installer and then call AddFontResource(_T("myfont.ttf")); and the same result.
If I don't call the AddFontResource at all, then the font is substituted with Arial with the correct size.
Tested in 64-bit Windows 7, 10 and Windows 2012 Server.
I have tried with Oswald font and Ubuntu, but I get the same results.
I have solved the problem by copying the font to C:\Windows\Fonts then add it to registry and then AddFontResource, otherwise it does not display the font correctly. Using it as a temporary font resource it does not work.

Qt quick applications glitching

I opened some Qt quick examples that comes with Qt and when I try to resize the window it starts to glitch.
This is an animated gif using the stoc example:
glitch http://105.imagebam.com/download/ZgcdXsQQukzkLCDchoYVrQ/44471/444703921/glitch.gif
My configuration is: Windows 10, 6 GB ram, i5, and using Qt 5.5.1 64bit MSVC 2013.
Is there any way of fixing it?

QApplication::setWindowIcon works on Windows XP, but does not work on Windows 7

In a simple Qt application starting like this:
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
app.setWindowIcon(QIcon(":/qapp/appicon.ico"));
...
we set the icon in the second line (this line and icon file in resources is the only difference between my test program and application generated by Qt wizard). This application works perfect on Windows XP, but on Windows 7 we can't see our icon in top-left corner of the window (system shows default icon instead of my appicon.ico).
Configuration of developer's computer:
Windows XP-SP3,
Qt 5.1,
MSVS2010-SP1.
UPDATE:
Operating system of developer is Windows XP, so we have temporary answer. When we compiled this application on computer with Windows 7, the problem disappeared (application shows the icon correctly on WinXP and Win7). So now we have to compile releases of this application on Windows 7. But it does not looks like perfect solution.
Do you have any ideas, how to solve this problem better?
Similar question is .ico icons not showing up on Windows.
Solution is simple:
create directory imageformats in application dir,
copy qico.dll in it.
Without this plugin QIcon can't read .ico files. So the problem was not in Windows 7 and Windows XP. The problem was in default paths variables on different computers.
My guess is you've got to create a resource file windows_icon.rc with the following content:
IDI_ICON1 ICON DISCARDABLE "images/app-icon-48.ico"
and add this line to your app's .pro file:
RC_FILE = windows_icon.rc
This is the way you set the app icon on Windows (the one that becomes the icon of the exe-file)