diff --git a/src/controls/QskPushButtonSkinlet.cpp b/src/controls/QskPushButtonSkinlet.cpp index 2fa76569..6063d9eb 100644 --- a/src/controls/QskPushButtonSkinlet.cpp +++ b/src/controls/QskPushButtonSkinlet.cpp @@ -79,7 +79,7 @@ QRectF QskPushButtonSkinlet::textRect( { // in case of having text + graphic we put the text at the bottom - qreal h = QFontMetricsF( button->effectiveFont( QskPushButton::Text ) ).height(); + qreal h = button->effectiveFontHeight( QskPushButton::Text ); if ( h < r.height() ) r.setTop( r.bottom() - h ); } @@ -153,8 +153,8 @@ QSGNode* QskPushButtonSkinlet::updateTextNode( { const auto rect = button->subControlRect( QskPushButton::Text ).toAlignedRect(); - const QFontMetricsF fm( button->effectiveFont( QskPushButton::Text ) ); - if ( !button->clip() && ( rect.height() < fm.height() ) ) + const auto textHeight = button->effectiveFontHeight( QskPushButton::Text ); + if ( !button->clip() && ( rect.height() < textHeight ) ) return nullptr; const auto alignment = button->alignmentHint( QskPushButton::Text, Qt::AlignCenter ); diff --git a/src/controls/QskSkinnable.cpp b/src/controls/QskSkinnable.cpp index 26f0b03d..e44a52b0 100644 --- a/src/controls/QskSkinnable.cpp +++ b/src/controls/QskSkinnable.cpp @@ -25,6 +25,7 @@ #include "QskGradient.h" #include +#include #include #define DEBUG_MAP 0 @@ -577,6 +578,12 @@ QFont QskSkinnable::effectiveFont( const QskAspect aspect ) const return effectiveSkin()->font( fontRoleHint( aspect ) ); } +qreal QskSkinnable::effectiveFontHeight( const QskAspect aspect ) const +{ + const QFontMetricsF fm( effectiveFont( aspect ) ); + return fm.height(); +} + bool QskSkinnable::setGraphicRoleHint( const QskAspect aspect, int role ) { return qskSetFlag( this, aspect | QskAspect::GraphicRole, role ); diff --git a/src/controls/QskSkinnable.h b/src/controls/QskSkinnable.h index 07479797..4a55c4e2 100644 --- a/src/controls/QskSkinnable.h +++ b/src/controls/QskSkinnable.h @@ -77,6 +77,7 @@ class QSK_EXPORT QskSkinnable const QskSkinlet* skinlet() const; QFont effectiveFont( QskAspect ) const; + qreal effectiveFontHeight( QskAspect ) const; QskColorFilter effectiveGraphicFilter( QskAspect ) const;