Unsolved Using stylesheets for widget sizing (based on the font sizes) produce different results different linux
-
Hi there!
I've probably encounter a possible bug in Qt caused by libfreetype or libfontconfig changes in latest versions.
Or I simply do something wrong.
This probable bug affects length calculation in stylesheets while length of object set with help of 'em' or 'ex' values.
It is only visible on newest Linuxes like Suse Leap 15.0 or Ubuntu 18.10 (probably 18.04 also affected).
On affected systems calculated sizes become bigger but the fonts itself looks the same size and with same intervals between text lines.
I've produce small application with this stylesheet on MainWindow:QMainWindow { font-family: "DejaVu Sans"; font-size: 12px; min-height: 14em; min-width: 24em; max-height: 14em; max-width: 24em; } QMainWindow * { font-family: "DejaVu Sans"; font-size: 12px; }
Inside the code I add some debug printing:
MainWindow w; w.show(); QFont font = w.font(); QFontMetrics metric(font); qDebug() << "Font " << font << " / bounding rect size " << metric.boundingRect('M').size(); qDebug() << "Window size " << w.size();
And got next results:
Ubuntu 16.04 Font Font QFont( "DejaVu Sans,-1,12,5,50,0,0,0,0,0" ) / bounding rect size QSize(9, 9) Window size QSize(336, 196) 336/24=14 pixels per 'em' Suse Leap 15.0 Font QFont( "DejaVu Sans,-1,12,5,50,0,0,0,0,0,Regular" ) / bounding rect size QSize(9, 9) Window size QSize(360, 210) 360/24=15 pixels per 'em'
With increased 13px font:
Ubuntu 16.04 Font QFont( "DejaVu Sans,-1,13,5,50,0,0,0,0,0" ) / bounding rect size QSize(9, 9) Window size QSize(360, 210) 360/24=15 pixels per 'em' Suse Leap 15.0 Font QFont( "DejaVu Sans,-1,13,5,50,0,0,0,0,0,Regular" ) / bounding rect size QSize(9, 9) Window size QSize(408, 238) 408/24=17 pixels per 'em'
With increased 14px font:
Ubuntu 16.04 Font QFont( "DejaVu Sans,-1,14,5,50,0,0,0,0,0" ) / bounding rect size QSize(10, 10) Window size QSize(384, 224) 384/24=16 pixels per 'em' Suse Leap 15.0 Font QFont( "DejaVu Sans,-1,14,5,50,0,0,0,0,0,Regular" ) / bounding rect size QSize(10, 10) Window size QSize(408, 238) 408/24=17 pixels per 'em' MacOSX Sierra Font QFont( "DejaVu Sans,-1,14,5,50,0,0,0,0,0" ) / bounding rect size QSize(9, 10) Window size QSize(384, 224) Windows Font QFont( "DejaVu Sans,-1,14,5,50,0,0,0,0,0" ) / bounding rect size QSize(10, 10) Window size QSize(384, 224)
I've tried to statically link libfreetype or libfontconfig and it helps with the sizes on new Linux system but embeded font looks quite different in this case.
Judging by same sizes on old linux, macosx and windows I conclude something went wrong with Qt and new versions libfreetype or libfontconfig.
So my questions should I post a ticket into Qt JIRA?
Is it something already known?
Or do I missed something and done something wrong that produce such results? -
Hi and welcome to devnet,
What version of Qt are you using during your tests ?
-
Before posting this issue I compile test application with Qt stock 5.11.2 for Linux.
But initially I stuck on this problem on custom built 5.11.1.
I will try to build with latest 5.12.0-beta4 and let you know about results. -
I've seen same behavior with 5.12.0-beta4. So I suppose it is likely current development branch of Qt also affected.
I've enclosed this test application. It contain two DejaVu fonts so it not quite tiny as the code itself.
[0_1541759152867_TestFonts.txz](Uploading 100%) -
Just to be sure test application available here:
https://drive.google.com/open?id=16igl74anxWOmiqHrJgnelkIxaMrQMvdC