From be4300f81c9e666f1e9bb3c80cbf25222890235a Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 12 Sep 2024 11:07:29 +1000 Subject: [PATCH] Don't show font size preview in font button icons Just reset the font size to a standard size when generating the preview, otherwise we end up with invisible text on the buttons if the font size is too big or too little. --- src/gui/qgsfontbutton.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/qgsfontbutton.cpp b/src/gui/qgsfontbutton.cpp index b9a6abdbcb5c..b87685643b8b 100644 --- a/src/gui/qgsfontbutton.cpp +++ b/src/gui/qgsfontbutton.cpp @@ -850,6 +850,13 @@ void QgsFontButton::updatePreview( const QColor &color, QgsTextFormat *format, Q if ( color.isValid() ) tempFormat.setColor( color ); + // always show font previews based on the standard font size for buttons. Otherwise large/small text + // will be unreadable, making the button very non-user-friendly. + // Note that we take away a few points here, as the text in these buttons is rendered with a fairly large + // margin and we'd like to avoid cropping the text. + tempFormat.setSize( QToolButton::font().pointSizeF() - 2 ); + tempFormat.setSizeUnit( Qgis::RenderUnit::Points ); + QSize currentIconSize; //icon size is button size with a small margin if ( menu() )