mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Move to pixel size instead of point size for fonts
This commit is contained in:
@@ -18,9 +18,14 @@
|
||||
|
||||
#include "RiaFontCache.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafFixedAtlasFont.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <cmath>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template <>
|
||||
@@ -131,6 +136,36 @@ RiaFontCache::FontSize RiaFontCache::fontSizeEnumFromPointSize( int pointSize )
|
||||
return closestEnumValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiaFontCache::pointSizeToPixelSize( int pointSize )
|
||||
{
|
||||
auto app = RiaGuiApplication::instance();
|
||||
if ( app )
|
||||
{
|
||||
int dpi = app->desktop()->logicalDpiX();
|
||||
double inches = pointSize / 72.0;
|
||||
return static_cast<int>( std::ceil( inches * dpi ) );
|
||||
}
|
||||
return pointSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiaFontCache::pixelSizeToPointSize( int pixelSize )
|
||||
{
|
||||
auto app = RiaGuiApplication::instance();
|
||||
if ( app )
|
||||
{
|
||||
int dpi = app->desktop()->logicalDpiX();
|
||||
double inches = pixelSize / dpi;
|
||||
return static_cast<int>( std::ceil( inches * 72.0 ) );
|
||||
}
|
||||
return pixelSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user