diff --git a/designsystems/fluent2/QskFluent2Skin.cpp b/designsystems/fluent2/QskFluent2Skin.cpp index ba49766b..a949d325 100644 --- a/designsystems/fluent2/QskFluent2Skin.cpp +++ b/designsystems/fluent2/QskFluent2Skin.cpp @@ -2035,8 +2035,8 @@ void QskFluent2Skin::initHints() static inline QFont createFont( int size, int lineHeight, QFont::Weight weight ) { - Q_UNUSED( size ); // ??? - const int pixelSize = qRound( qskDpToPixels( lineHeight ) ); + Q_UNUSED( lineHeight ); // ??? + const int pixelSize = qRound( qskPxToPixels( size ) ); /* Font size determines how big or small the letters are, while line height @@ -2064,7 +2064,6 @@ static inline QFont createFont( int size, int lineHeight, QFont::Weight weight ) checkFont = false; } - // sp: this is like the dp unit, but it is also scaled by the user's font size preference font.setPixelSize( pixelSize ); return font; diff --git a/src/common/QskPlatform.cpp b/src/common/QskPlatform.cpp index c54c29eb..10fdc86f 100644 --- a/src/common/QskPlatform.cpp +++ b/src/common/QskPlatform.cpp @@ -76,10 +76,15 @@ static inline qreal qskRoundedDpi( qreal dpi ) qreal qskDpToPixelsFactor() { if ( const auto screen = QGuiApplication::primaryScreen() ) - { - // see: https://en.wikipedia.org/wiki/Device-independent_pixel return qskRoundedDpi( screen->physicalDotsPerInch() ) / 160.0; - } + + return 1.0; +} + +qreal qskPxToPixelsFactor() +{ + if ( const auto screen = QGuiApplication::primaryScreen() ) + return screen->physicalDotsPerInch() / 96.0; return 1.0; } diff --git a/src/common/QskPlatform.h b/src/common/QskPlatform.h index 48be41b3..e5c9fa83 100644 --- a/src/common/QskPlatform.h +++ b/src/common/QskPlatform.h @@ -22,13 +22,16 @@ QSK_EXPORT const QPlatformIntegration* qskPlatformIntegration(); QSK_EXPORT const QPlatformTheme* qskPlatformTheme(); /* + see: https://en.wikipedia.org/wiki/Device-independent_pixel + One dp is a virtual pixel unit that's roughly equal to one pixel on a medium-density screen ( 160 dpi ). - see: https://en.wikipedia.org/wiki/Device-independent_pixel + One px is equivalent to 1/96th of an inch. */ QSK_EXPORT qreal qskDpToPixelsFactor(); +QSK_EXPORT qreal qskPxToPixelsFactor(); inline qreal qskDpToPixels( qreal value ) { @@ -40,4 +43,14 @@ inline qreal qskDpToPixels( qreal value ) return value * factor; } +inline qreal qskPxToPixels( qreal value ) +{ + static qreal factor = -1.0; + + if ( factor < 0.0 ) + factor = qskPxToPixelsFactor(); + + return value * factor; +} + #endif