Stop using scale factor for font and pixel size scaling
This commit is contained in:
parent
cc48ad2aa1
commit
21ebb81ece
@ -67,8 +67,7 @@ CropWindow::CropWindow (ImageArea* parent, bool isLowUpdatePriority_, bool isDet
|
||||
const int fontSize = 8; // pt
|
||||
// Converting font size to "px" based on DPI and scale
|
||||
#ifndef __APPLE__
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
@ -2467,8 +2466,7 @@ void CropWindow::drawDecoration (Cairo::RefPtr<Cairo::Context> cr)
|
||||
const int fontSize = 8; // pt
|
||||
// Converting font size to "px" based on DPI and scale
|
||||
#ifndef __APPLE__
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
@ -2544,8 +2542,7 @@ void CropWindow::drawStraightenGuide (Cairo::RefPtr<Cairo::Context> cr)
|
||||
const int fontSize = 8; // pt
|
||||
// Converting font size to "px" based on DPI and scale
|
||||
#ifndef __APPLE__
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
|
@ -792,8 +792,7 @@ void FileBrowserEntry::drawStraightenGuide (Cairo::RefPtr<Cairo::Context> cr)
|
||||
const int fontSize = 8; // pt
|
||||
// Converting font size to "px" based on DPI and scale
|
||||
#ifndef __APPLE__
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
|
@ -158,8 +158,7 @@ void ImageArea::setInfoText (Glib::ustring text)
|
||||
const int fontSize = 10; // pt
|
||||
// Converting font size to "px" based on DPI and scale
|
||||
#ifndef __APPLE__
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
|
@ -51,8 +51,7 @@ void LockableColorPicker::updateBackBuffer ()
|
||||
const int fontSize = options.CPFontFamily == "default" ? 8 : options.CPFontSize; // pt
|
||||
// Converting font size to "px" based on DPI and scale
|
||||
#ifndef __APPLE__
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
|
@ -2494,9 +2494,9 @@ void Preferences::switchFontTo(const Glib::ustring &newFontFamily, const int new
|
||||
try {
|
||||
//GTK318
|
||||
//#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20
|
||||
// fontcss->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2px }", newFontFamily, newFontSize * RTScalable::getScale()));
|
||||
// fontcss->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2px }", newFontFamily, newFontSize));
|
||||
//#else
|
||||
fontcss->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", newFontFamily, newFontSize * RTScalable::getScale()));
|
||||
fontcss->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", newFontFamily, newFontSize));
|
||||
//#endif
|
||||
//GTK318
|
||||
} catch (Glib::Error &err) {
|
||||
|
@ -267,8 +267,7 @@ int RTScalable::getScale ()
|
||||
|
||||
double RTScalable::getGlobalScale()
|
||||
{
|
||||
return (RTScalable::getDPI() / RTScalable::baseDPI *
|
||||
static_cast<double>(RTScalable::getScale()));
|
||||
return (RTScalable::getDPI() / RTScalable::baseDPI);
|
||||
}
|
||||
|
||||
int RTScalable::scalePixelSize(const int pixel_size)
|
||||
|
@ -33,7 +33,7 @@
|
||||
* - Absolute size (i.e. "px")
|
||||
* - Non-absolute size (i.e. "pt"): The default resolution is 72 DPI (i.e. pt per inch). To
|
||||
* convert the size to "px", use the following formula:
|
||||
* "size in px" = "size in pt" * ("device resolution" / 72) * "device scale"
|
||||
* "size in px" = "size in pt" * ("device resolution" / 72)
|
||||
*
|
||||
* Hi-DPI implementation according to the OS (source: GDK code):
|
||||
* - Windows: A default DPI of 96 is considered. Current DPI parameter is provided by the OS.
|
||||
@ -41,7 +41,8 @@
|
||||
* forced to 96.
|
||||
* - MacOS: Scale is calculated from OS parameters (= "Retina screen width" / "Virtual width").
|
||||
* DPI is forced to 72.
|
||||
* - Linux: DPI is calculated from OS parameter (= 96 * "text-scaling-factor").
|
||||
* - Linux: DPI is calculated from OS parameter (= 96 * "text-scaling-factor"). Note: "text-scaling-factor"
|
||||
* is different from "device factor".
|
||||
*/
|
||||
class RTScalable
|
||||
{
|
||||
|
@ -170,8 +170,7 @@ RTWindow::RTWindow ()
|
||||
Glib::ustring css;
|
||||
|
||||
#ifndef __APPLE__
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
@ -206,8 +205,7 @@ RTWindow::RTWindow ()
|
||||
|
||||
#ifndef __APPLE__
|
||||
// Guessing that pixel size is given for a 96 DPI reference:
|
||||
const double newFontScale = RTScalable::getDPI() / RTScalable::baseDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double newFontScale = RTScalable::getDPI() / RTScalable::baseDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
|
@ -199,8 +199,7 @@ void SHCSelector::updateBackBuffer()
|
||||
const double fontSize = static_cast<double>(h) * 0.8; // pt
|
||||
// Converting font size to "px" based on DPI and scale
|
||||
#ifndef __APPLE__
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
|
@ -46,8 +46,7 @@ bool SplashImage::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)
|
||||
const int fontSize = 12; // pt
|
||||
// Converting font size to "px" based on DPI and scale
|
||||
#ifndef __APPLE__
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
|
||||
* static_cast<double>(RTScalable::getScale()); // Refer to notes in rtscalable.h
|
||||
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI; // Refer to notes in rtscalable.h
|
||||
#else
|
||||
// On MacOS, font is already scaled by the System library
|
||||
// Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c
|
||||
|
Loading…
x
Reference in New Issue
Block a user