1px: 1/96th of an inch
This commit is contained in:
parent
5dfcbf8cfa
commit
03ede1a0e6
|
@ -2035,8 +2035,8 @@ void QskFluent2Skin::initHints()
|
||||||
|
|
||||||
static inline QFont createFont( int size, int lineHeight, QFont::Weight weight )
|
static inline QFont createFont( int size, int lineHeight, QFont::Weight weight )
|
||||||
{
|
{
|
||||||
Q_UNUSED( size ); // ???
|
Q_UNUSED( lineHeight ); // ???
|
||||||
const int pixelSize = qRound( qskDpToPixels( lineHeight ) );
|
const int pixelSize = qRound( qskPxToPixels( size ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Font size determines how big or small the letters are, while line height
|
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;
|
checkFont = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sp: this is like the dp unit, but it is also scaled by the user's font size preference
|
|
||||||
font.setPixelSize( pixelSize );
|
font.setPixelSize( pixelSize );
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
|
|
|
@ -76,10 +76,15 @@ static inline qreal qskRoundedDpi( qreal dpi )
|
||||||
qreal qskDpToPixelsFactor()
|
qreal qskDpToPixelsFactor()
|
||||||
{
|
{
|
||||||
if ( const auto screen = QGuiApplication::primaryScreen() )
|
if ( const auto screen = QGuiApplication::primaryScreen() )
|
||||||
{
|
|
||||||
// see: https://en.wikipedia.org/wiki/Device-independent_pixel
|
|
||||||
return qskRoundedDpi( screen->physicalDotsPerInch() ) / 160.0;
|
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;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,16 @@ QSK_EXPORT const QPlatformIntegration* qskPlatformIntegration();
|
||||||
QSK_EXPORT const QPlatformTheme* qskPlatformTheme();
|
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
|
One dp is a virtual pixel unit that's roughly equal to one pixel
|
||||||
on a medium-density screen ( 160 dpi ).
|
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 qskDpToPixelsFactor();
|
||||||
|
QSK_EXPORT qreal qskPxToPixelsFactor();
|
||||||
|
|
||||||
inline qreal qskDpToPixels( qreal value )
|
inline qreal qskDpToPixels( qreal value )
|
||||||
{
|
{
|
||||||
|
@ -40,4 +43,14 @@ inline qreal qskDpToPixels( qreal value )
|
||||||
return value * factor;
|
return value * factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline qreal qskPxToPixels( qreal value )
|
||||||
|
{
|
||||||
|
static qreal factor = -1.0;
|
||||||
|
|
||||||
|
if ( factor < 0.0 )
|
||||||
|
factor = qskPxToPixelsFactor();
|
||||||
|
|
||||||
|
return value * factor;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue