mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
Fix missing Qt client icons on Windows (#7931)
* Enable FreeType and Harfbuzz for Windows release builds This fixes icon font glyphs rendering in Qt client. * Bump Qt to 6.10.1 * Use pixel sizes for icon font glyphs rendering on Windows The glyphs otherwise turn out of a smaller, non-standard size which makes them less crisp.
This commit is contained in:
@@ -68,14 +68,16 @@ void ensureFontsLoaded()
|
||||
#endif
|
||||
}
|
||||
|
||||
QPixmap makeIconFromCodepoint(QString const family, QChar const codepoint, int const point_size)
|
||||
QPixmap makeIconFromCodepoint(QString const family, QChar const codepoint, int const pixel_size)
|
||||
{
|
||||
auto const font = QFont{ family, point_size - 8 };
|
||||
auto font = QFont{ family };
|
||||
if (!QFontMetrics{ font }.inFont(codepoint))
|
||||
return {};
|
||||
|
||||
font.setPixelSize(pixel_size);
|
||||
|
||||
// FIXME: HDPI, pixel size vs point size?
|
||||
auto const rect = QRect{ 0, 0, point_size, point_size };
|
||||
auto const rect = QRect{ 0, 0, pixel_size, pixel_size };
|
||||
auto pixmap = QPixmap{ rect.size() };
|
||||
pixmap.fill(Qt::transparent);
|
||||
auto painter = QPainter{ &pixmap };
|
||||
@@ -422,7 +424,7 @@ QIcon icon(Type const type, QStyle const* const style)
|
||||
{
|
||||
ensureFontsLoaded();
|
||||
|
||||
auto const point_sizes = small::max_size_set<int, 7U>{
|
||||
auto const pixel_sizes = small::max_size_set<int, 7U>{
|
||||
style->pixelMetric(QStyle::PM_ButtonIconSize), style->pixelMetric(QStyle::PM_LargeIconSize),
|
||||
style->pixelMetric(QStyle::PM_ListViewIconSize), style->pixelMetric(QStyle::PM_MessageBoxIconSize),
|
||||
style->pixelMetric(QStyle::PM_SmallIconSize), style->pixelMetric(QStyle::PM_TabBarIconSize),
|
||||
@@ -436,8 +438,8 @@ QIcon icon(Type const type, QStyle const* const style)
|
||||
{
|
||||
auto icon = QIcon{};
|
||||
auto const name = QString::fromUtf8(std::data(key), std::size(key));
|
||||
for (int const point_size : point_sizes)
|
||||
if (auto const pixmap = loadSFSymbol(name, point_size); !pixmap.isNull())
|
||||
for (int const pixel_size : pixel_sizes)
|
||||
if (auto const pixmap = loadSFSymbol(name, pixel_size); !pixmap.isNull())
|
||||
icon.addPixmap(pixmap);
|
||||
if (!icon.isNull())
|
||||
return icon;
|
||||
@@ -450,8 +452,8 @@ QIcon icon(Type const type, QStyle const* const style)
|
||||
{
|
||||
auto icon = QIcon{};
|
||||
auto const ch = QChar{ key };
|
||||
for (int const point_size : point_sizes)
|
||||
if (auto pixmap = makeIconFromCodepoint(family, ch, point_size); !pixmap.isNull())
|
||||
for (int const pixel_size : pixel_sizes)
|
||||
if (auto pixmap = makeIconFromCodepoint(family, ch, pixel_size); !pixmap.isNull())
|
||||
icon.addPixmap(pixmap);
|
||||
if (!icon.isNull())
|
||||
return icon;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
$global:Qt6Version = '6.10.0'
|
||||
$global:Qt6Version = '6.10.1'
|
||||
|
||||
$global:Qt6Deps = @(
|
||||
'DBus'
|
||||
@@ -47,8 +47,6 @@ function global:Build-Qt6([string] $PrefixDir, [string] $Arch, [string] $DepsPre
|
||||
'-qt-libpng'
|
||||
'-qt-libjpeg'
|
||||
'-no-opengl'
|
||||
'-no-freetype'
|
||||
'-no-harfbuzz'
|
||||
'-no-feature-androiddeployqt'
|
||||
'-no-feature-assistant'
|
||||
'-no-feature-brotli'
|
||||
@@ -66,9 +64,7 @@ function global:Build-Qt6([string] $PrefixDir, [string] $Arch, [string] $DepsPre
|
||||
'-no-feature-emojisegmenter'
|
||||
'-no-feature-fontcombobox'
|
||||
'-no-feature-fontdialog'
|
||||
'-no-feature-freetype'
|
||||
'-no-feature-gestures'
|
||||
'-no-feature-harfbuzz'
|
||||
'-no-feature-keysequenceedit'
|
||||
'-no-feature-lcdnumber'
|
||||
'-no-feature-listwidget'
|
||||
@@ -131,6 +127,11 @@ function global:Build-Qt6([string] $PrefixDir, [string] $Arch, [string] $DepsPre
|
||||
Edit-TextFile (Join-Path $SourceDir qtactiveqt CMakeLists.txt) 'PrintSupport' ''
|
||||
Edit-TextFile (Join-Path $SourceDir qtactiveqt tools CMakeLists.txt) 'add_subdirectory[(]testcon[)]' ''
|
||||
|
||||
# Fix unity build (due to https://github.com/qt/qtbase/commit/a6ac84731776381ee5ac6b6306acdc4418e900d9)
|
||||
Edit-TextFile (Join-Path $SourceDir qtbase src corelib text qbytearray.h) 'Q_PRESUME.+;' ''
|
||||
Edit-TextFile (Join-Path $SourceDir qtbase src corelib text qstring.h) 'Q_PRESUME.+;' ''
|
||||
Edit-TextFile (Join-Path $SourceDir qtbase src corelib tools qlist.h) 'Q_PRESUME.+;' ''
|
||||
|
||||
# Fix build (including because of disabled features)
|
||||
Edit-TextFile (Join-Path $SourceDir qtbase src gui text windows qwindowsfontdatabasebase_p.h) 'unique_ptr<QCustomFontFileLoader>' 'unique_ptr<int>'
|
||||
Edit-TextFile (Join-Path $SourceDir qtactiveqt src activeqt container qaxwidget.cpp) '.*<(qdockwidget|qwhatsthis)[.]h>|QWhatsThis::[a-zA-Z]+[(][)]' ''
|
||||
|
||||
Reference in New Issue
Block a user