Skip to content

Commit

Permalink
Don't show font size preview in font button icons
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nyalldawson committed Sep 30, 2024
1 parent 90517a0 commit be4300f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gui/qgsfontbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down

0 comments on commit be4300f

Please sign in to comment.