diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index a5f332f9f..110555251 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -64,21 +64,20 @@ CropWindow::CropWindow (ImageArea* parent, bool isLowUpdatePriority_, bool isDet Glib::RefPtr context = parent->get_pango_context () ; Pango::FontDescription fontd = context->get_font_description (); fontd.set_weight (Pango::WEIGHT_BOLD); - // Absolute size is defined in "Pango units" and shall be multiplied by - // Pango::SCALE from "px" - const int fontSize = 8; - const int absoluteFontSize = fontSize * Pango::SCALE; - // Guessing that absolute pixel size is given for a 96 DPI reference: + const int fontSize = 8; // pt + // Converting font size to "px" based on DPI and scale #ifndef __APPLE__ - const double fontScale = static_cast(RTScalable::getDPI()) - / static_cast(RTScalable::pangoDPI) - * RTScalable::getScale(); // Refer to notes in rtscalable.h + const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI + * static_cast(RTScalable::getScale()); // 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 const double fontScale = 1.; #endif - fontd.set_absolute_size (static_cast(absoluteFontSize) * fontScale); + const double absoluteFontSize = static_cast(fontSize) * fontScale; // px + // Absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "px": + fontd.set_absolute_size (absoluteFontSize * static_cast(Pango::SCALE)); context->set_font_description (fontd); Glib::RefPtr cllayout = parent->create_pango_layout("1000%"); @@ -2465,21 +2464,20 @@ void CropWindow::drawDecoration (Cairo::RefPtr cr) Glib::RefPtr context = iarea->get_pango_context () ; Pango::FontDescription fontd = context->get_font_description (); fontd.set_weight (Pango::WEIGHT_BOLD); - // Absolute size is defined in "Pango units" and shall be multiplied by - // Pango::SCALE from "px" - const int fontSize = 8; - const int absoluteFontSize = fontSize * Pango::SCALE; - // Guessing that absolute pixel size is given for a 96 DPI reference: + const int fontSize = 8; // pt + // Converting font size to "px" based on DPI and scale #ifndef __APPLE__ - const double fontScale = static_cast(RTScalable::getDPI()) - / static_cast(RTScalable::pangoDPI) - * RTScalable::getScale(); // Refer to notes in rtscalable.h + const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI + * static_cast(RTScalable::getScale()); // 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 const double fontScale = 1.; #endif - fontd.set_absolute_size (static_cast(absoluteFontSize) * fontScale); + const double absoluteFontSize = static_cast(fontSize) * fontScale; // px + // Absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "px": + fontd.set_absolute_size (absoluteFontSize * static_cast(Pango::SCALE)); context->set_font_description (fontd); Glib::RefPtr cllayout = iarea->create_pango_layout(cropLabel); int iw, ih; @@ -2543,21 +2541,20 @@ void CropWindow::drawStraightenGuide (Cairo::RefPtr cr) Glib::RefPtr context = iarea->get_pango_context () ; Pango::FontDescription fontd = context->get_font_description (); fontd.set_weight (Pango::WEIGHT_BOLD); - // Absolute size is defined in "Pango units" and shall be multiplied by - // Pango::SCALE from "px" - const int fontSize = 8; - const int absoluteFontSize = fontSize * Pango::SCALE; - // Guessing that absolute pixel size is given for a 96 DPI reference: + const int fontSize = 8; // pt + // Converting font size to "px" based on DPI and scale #ifndef __APPLE__ - const double fontScale = static_cast(RTScalable::getDPI()) - / static_cast(RTScalable::pangoDPI) - * RTScalable::getScale(); // Refer to notes in rtscalable.h + const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI + * static_cast(RTScalable::getScale()); // 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 const double fontScale = 1.; #endif - fontd.set_absolute_size (static_cast(absoluteFontSize) * fontScale); + const double absoluteFontSize = static_cast(fontSize) * fontScale; // px + // Absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "px": + fontd.set_absolute_size (absoluteFontSize * static_cast(Pango::SCALE)); context->set_font_description (fontd); Glib::RefPtr deglayout = iarea->create_pango_layout(Glib::ustring::compose ("%1 deg", Glib::ustring::format(std::setprecision(2), rot_deg))); diff --git a/rtgui/filebrowserentry.cc b/rtgui/filebrowserentry.cc index 9f9be2eff..b3d4e6904 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -789,7 +789,20 @@ void FileBrowserEntry::drawStraightenGuide (Cairo::RefPtr cr) Glib::RefPtr context = parent->getDrawingArea()->get_pango_context () ; Pango::FontDescription fontd = context->get_font_description (); fontd.set_weight (Pango::WEIGHT_BOLD); - fontd.set_size (8 * Pango::SCALE); + 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(RTScalable::getScale()); // 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 + const double fontScale = 1.; +#endif + const double absoluteFontSize = static_cast(fontSize) * fontScale; // px + // Absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "px": + fontd.set_absolute_size (absoluteFontSize * static_cast(Pango::SCALE)); context->set_font_description (fontd); Glib::RefPtr deglayout = parent->getDrawingArea()->create_pango_layout(Glib::ustring::compose ("%1 deg", Glib::ustring::format(std::setprecision(2), rot_deg))); diff --git a/rtgui/imagearea.cc b/rtgui/imagearea.cc index df9756e88..d60232ff9 100644 --- a/rtgui/imagearea.cc +++ b/rtgui/imagearea.cc @@ -155,7 +155,20 @@ void ImageArea::setInfoText (Glib::ustring text) // update font fontd.set_weight (Pango::WEIGHT_BOLD); - fontd.set_size (10 * Pango::SCALE); + 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(RTScalable::getScale()); // 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 + const double fontScale = 1.; +#endif + const double absoluteFontSize = static_cast(fontSize) * fontScale; // px + // Absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "px": + fontd.set_absolute_size (absoluteFontSize * static_cast(Pango::SCALE)); context->set_font_description (fontd); // create text layout diff --git a/rtgui/lockablecolorpicker.cc b/rtgui/lockablecolorpicker.cc index 0a08bb945..22760c6a2 100644 --- a/rtgui/lockablecolorpicker.cc +++ b/rtgui/lockablecolorpicker.cc @@ -48,7 +48,20 @@ void LockableColorPicker::updateBackBuffer () Pango::FontDescription fontd = pangoContext->get_font_description(); // set font family and size fontd.set_family(options.CPFontFamily == "default" ? "sans" : options.CPFontFamily); - fontd.set_size((options.CPFontFamily == "default" ? 8 : options.CPFontSize) * Pango::SCALE); + 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(RTScalable::getScale()); // 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 + const double fontScale = 1.; +#endif + const double absoluteFontSize = static_cast(fontSize) * fontScale; // px + // Absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "px": + fontd.set_absolute_size (absoluteFontSize * static_cast(Pango::SCALE)); fontd.set_weight(Pango::WEIGHT_NORMAL); pangoContext->set_font_description (fontd); diff --git a/rtgui/rtscalable.cc b/rtgui/rtscalable.cc index 09fb82205..5606fe677 100644 --- a/rtgui/rtscalable.cc +++ b/rtgui/rtscalable.cc @@ -248,9 +248,8 @@ int RTScalable::getScale () double RTScalable::getGlobalScale() { - return (static_cast(RTScalable::getDPI()) / - static_cast(RTScalable::baseDPI) * - RTScalable::getScale()); + return (RTScalable::getDPI() / RTScalable::baseDPI * + static_cast(RTScalable::getScale())); } int RTScalable::scalePixelSize(const int pixel_size) diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index 9ea9dec5a..fede08a9a 100755 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -170,9 +170,8 @@ RTWindow::RTWindow () Glib::ustring css; #ifndef __APPLE__ - const double fontScale = static_cast(RTScalable::getDPI()) - / static_cast(RTScalable::pangoDPI) - * RTScalable::getScale(); // Refer to notes in rtscalable.h + const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI + * static_cast(RTScalable::getScale()); // 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 @@ -205,11 +204,10 @@ RTWindow::RTWindow () // Pango::SCALE to get "px" newFontSize = fontSize / Pango::SCALE; - // Guessing that pixel size is given for a 96 DPI reference: #ifndef __APPLE__ - const double newFontScale = static_cast(RTScalable::getDPI()) - / static_cast(RTScalable::pangoDPI) - * RTScalable::getScale(); // Refer to notes in rtscalable.h + // Guessing that pixel size is given for a 96 DPI reference: + const double newFontScale = RTScalable::getDPI() / RTScalable::baseDPI + * static_cast(RTScalable::getScale()); // 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 @@ -231,7 +229,6 @@ RTWindow::RTWindow () // Set font and size in css css = Glib::ustring::compose ("* { font-size: %1px}", newFontSize); - printf("newFontSize: %d\n", newFontSize); } } diff --git a/rtgui/shcselector.cc b/rtgui/shcselector.cc index ac1149893..dc7e06936 100644 --- a/rtgui/shcselector.cc +++ b/rtgui/shcselector.cc @@ -195,7 +195,22 @@ void SHCSelector::updateBackBuffer() // update font fontd.set_weight (Pango::WEIGHT_NORMAL); - fontd.set_absolute_size((double)h * 0.8 * (double)Pango::SCALE); + // Absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "px" + const double fontSize = static_cast(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(RTScalable::getScale()); // 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 + const double fontScale = 1.; +#endif + const double absoluteFontSize = static_cast(fontSize) * fontScale; // px + // Absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "px": + fontd.set_absolute_size (absoluteFontSize * static_cast(Pango::SCALE)); context->set_font_description (fontd); Glib::RefPtr layout = create_pango_layout(Glib::ustring::format(std::setprecision(2), positions[i])); diff --git a/rtgui/splash.cc b/rtgui/splash.cc index b7d118d58..d00a074dc 100644 --- a/rtgui/splash.cc +++ b/rtgui/splash.cc @@ -43,21 +43,20 @@ bool SplashImage::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr) context->set_cairo_font_options (cfo); Pango::FontDescription fontd = context->get_font_description (); fontd.set_weight (Pango::WEIGHT_LIGHT); - // Absolute size is defined in "Pango units" and shall be multiplied by - // Pango::SCALE from "px" - const int fontSize = 12; - const int absoluteFontSize = fontSize * Pango::SCALE; - // Guessing that absolute pixel size is given for a 96 DPI reference: + const int fontSize = 12; // pt + // Converting font size to "px" based on DPI and scale #ifndef __APPLE__ - const double fontScale = static_cast(RTScalable::getDPI()) - / static_cast(RTScalable::pangoDPI) - * RTScalable::getScale(); // Refer to notes in rtscalable.h + const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI + * static_cast(RTScalable::getScale()); // 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 const double fontScale = 1.; #endif - fontd.set_absolute_size (static_cast(absoluteFontSize) * fontScale); + const double absoluteFontSize = static_cast(fontSize) * fontScale; // px + // Absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "px": + fontd.set_absolute_size (absoluteFontSize * static_cast(Pango::SCALE)); context->set_font_description (fontd); int w, h;