diff --git a/rtdata/CMakeLists.txt b/rtdata/CMakeLists.txt index 0f6c907fb..7a0190e15 100644 --- a/rtdata/CMakeLists.txt +++ b/rtdata/CMakeLists.txt @@ -3,7 +3,6 @@ file(GLOB SOUNDFILES "sounds/*") file(GLOB INPUTICCFILES "iccprofiles/input/*") file(GLOB OUTPUTICCFILES "iccprofiles/output/*") file(GLOB DCPFILES "dcpprofiles/*") -file(GLOB FONTS "fonts/*") set(PROFILESDIR "profiles") set(THEMEDIR "themes") @@ -43,9 +42,6 @@ install(FILES ${INPUTICCFILES} DESTINATION "${DATADIR}/iccprofiles/input") install(FILES ${OUTPUTICCFILES} DESTINATION "${DATADIR}/iccprofiles/output") install(FILES ${DCPFILES} DESTINATION "${DATADIR}/dcpprofiles") install(FILES ${OPTIONSFILE} DESTINATION "${DATADIR}" PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ RENAME options) -if(WIN32) - install(FILES ${FONTS} DESTINATION "${DATADIR}/fonts") -endif() install(DIRECTORY "${PROFILESDIR}" DESTINATION "${DATADIR}" FILES_MATCHING PATTERN "*.pp3") install(DIRECTORY "${THEMEDIR}" DESTINATION "${DATADIR}") diff --git a/rtdata/fonts/DroidSansMonoSlashed.ttf b/rtdata/fonts/DroidSansMonoSlashed.ttf deleted file mode 100644 index 8c44b47ed..000000000 Binary files a/rtdata/fonts/DroidSansMonoSlashed.ttf and /dev/null differ diff --git a/rtdata/options/options.osx b/rtdata/options/options.osx index cf31210e6..ef68d7144 100644 --- a/rtdata/options/options.osx +++ b/rtdata/options/options.osx @@ -37,8 +37,3 @@ CustomProfileBuilder= # Default profile name (without extension) to use for standard (8bits) images #ImgDefault=Neutral - -[GUI] -# Set the included font as default -FontFamily=Droid Sans Mono Slashed -CPFontFamily=Droid Sans Mono Slashed diff --git a/rtdata/themes/RawTherapee.css b/rtdata/themes/RawTherapee.css index 3a3162c4e..0805744dc 100644 --- a/rtdata/themes/RawTherapee.css +++ b/rtdata/themes/RawTherapee.css @@ -26,7 +26,6 @@ * { color: #BBBBBB; text-shadow: none; /* Keep at none, or suffer serious performance issues */ - font-size: 1em; } *:disabled { diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index e3c82a09d..458ea05f6 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -62,21 +62,12 @@ CropWindow::CropWindow (ImageArea* parent, bool isLowUpdatePriority_, bool isDet initZoomSteps(); Glib::RefPtr context = parent->get_pango_context () ; - Pango::FontDescription fontd = context->get_font_description (); + Pango::FontDescription fontd = parent->get_style_context()->get_font(); fontd.set_weight (Pango::WEIGHT_BOLD); const int fontSize = 8; // pt - // Converting font size to "px" based on DPI and scale -#ifndef __APPLE__ - 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 - 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)); + // Non-absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "pt": + fontd.set_size (fontSize * Pango::SCALE); context->set_font_description (fontd); Glib::RefPtr cllayout = parent->create_pango_layout("1000%"); @@ -2461,21 +2452,12 @@ void CropWindow::drawDecoration (Cairo::RefPtr cr) int x = xpos, y = ypos; // prepare label Glib::RefPtr context = iarea->get_pango_context () ; - Pango::FontDescription fontd = context->get_font_description (); + Pango::FontDescription fontd = iarea->get_style_context()->get_font(); fontd.set_weight (Pango::WEIGHT_BOLD); const int fontSize = 8; // pt - // Converting font size to "px" based on DPI and scale -#ifndef __APPLE__ - 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 - 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)); + // Non-absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "pt": + fontd.set_size (fontSize * Pango::SCALE); context->set_font_description (fontd); Glib::RefPtr cllayout = iarea->create_pango_layout(cropLabel); int iw, ih; @@ -2537,21 +2519,12 @@ void CropWindow::drawStraightenGuide (Cairo::RefPtr cr) } Glib::RefPtr context = iarea->get_pango_context () ; - Pango::FontDescription fontd = context->get_font_description (); + Pango::FontDescription fontd = iarea->get_style_context()->get_font(); fontd.set_weight (Pango::WEIGHT_BOLD); const int fontSize = 8; // pt - // Converting font size to "px" based on DPI and scale -#ifndef __APPLE__ - 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 - 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)); + // Non-absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "pt": + fontd.set_size (fontSize * 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 b3742ac8f..f889d3b20 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -784,21 +784,12 @@ void FileBrowserEntry::drawStraightenGuide (Cairo::RefPtr cr) } Glib::RefPtr context = parent->getDrawingArea()->get_pango_context () ; - Pango::FontDescription fontd = context->get_font_description (); + Pango::FontDescription fontd = parent->getDrawingArea()->get_style_context()->get_font(); fontd.set_weight (Pango::WEIGHT_BOLD); const int fontSize = 8; // pt - // Converting font size to "px" based on DPI and scale -#ifndef __APPLE__ - 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 - 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)); + // Non-absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "pt": + fontd.set_size (fontSize * 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/filecatalog.cc b/rtgui/filecatalog.cc index b01d83223..fd928c7b2 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -525,7 +525,7 @@ void FileCatalog::on_realize() { Gtk::Box::on_realize(); - Pango::FontDescription fontd = get_pango_context()->get_font_description (); + Pango::FontDescription fontd = get_style_context()->get_font(); fileBrowser->get_pango_context()->set_font_description (fontd); // batchQueue->get_pango_context()->set_font_description (fontd); } diff --git a/rtgui/imagearea.cc b/rtgui/imagearea.cc index 90deb6ba0..a1387db02 100644 --- a/rtgui/imagearea.cc +++ b/rtgui/imagearea.cc @@ -156,18 +156,9 @@ void ImageArea::setInfoText (Glib::ustring text) // update font fontd.set_weight (Pango::WEIGHT_BOLD); const int fontSize = 10; // pt - // Converting font size to "px" based on DPI and scale -#ifndef __APPLE__ - 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 - 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)); + // Non-absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "pt": + fontd.set_size (fontSize * Pango::SCALE); context->set_font_description (fontd); // create text layout diff --git a/rtgui/lockablecolorpicker.cc b/rtgui/lockablecolorpicker.cc index 0133199e8..4a8529c38 100644 --- a/rtgui/lockablecolorpicker.cc +++ b/rtgui/lockablecolorpicker.cc @@ -53,22 +53,13 @@ void LockableColorPicker::updateBackBuffer () Gtk::DrawingArea *iArea = cropWindow->getImageArea(); Glib::RefPtr pangoContext = iArea->get_pango_context (); - Pango::FontDescription fontd = pangoContext->get_font_description(); + Pango::FontDescription fontd = iArea->get_style_context()->get_font(); // set font family and size fontd.set_family(options.CPFontFamily == "default" ? "sans" : options.CPFontFamily); 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; // 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)); + // Non-absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "pt": + fontd.set_size (fontSize * Pango::SCALE); fontd.set_weight(Pango::WEIGHT_NORMAL); pangoContext->set_font_description (fontd); diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 4dd6eae4f..6e9028bce 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -82,9 +82,22 @@ Preferences::Preferences(RTWindow *rtwindow) set_size_request(650, -1); set_default_size(options.preferencesWidth, options.preferencesHeight); - Pango::FontDescription defaultFont = get_style_context()->get_font(); - initialFontFamily = defaultFont.get_family(); - initialFontSize = defaultFont.get_size() / Pango::SCALE; + // Request default font and size from Gtk::Settings + const auto defaultSettings = Gtk::Settings::get_default(); + Glib::ustring defaultFont; + defaultSettings->get_property("gtk-font-name", defaultFont); + const Pango::FontDescription defaultFontDesc = Pango::FontDescription(defaultFont); + initialFontFamily = defaultFontDesc.get_family(); +#if defined(__APPLE__) + // Default MacOS font (i.e. "") is not correctly handled + // in Gtk css. Replacing it by "-apple-system" to avoid this + if (initialFontFamily == ".AppleSystemUIFont") { + initialFontFamily = "-apple-system"; + } +#endif + initialFontSize = defaultFontDesc.get_size() / Pango::SCALE; // Font size is managed in ()"pt" * Pango::SCALE) by Pango (also refer to notes in rtscalable.h) + + printf("initialFont: %s %d\n", initialFontFamily.c_str(), initialFontSize); Gtk::Box* mainBox = get_content_area(); //GTK318 @@ -2016,15 +2029,15 @@ void Preferences::fillPreferences() navGuideColorCB->set_alpha ( (unsigned short) (moptions.navGuideBrush[3] * 65535.0)); if (options.fontFamily == "default") { - mainFontFB->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize)); + mainFontFB->set_font_name (Glib::ustring::compose ("%1, %2", initialFontFamily, initialFontSize)); } else { - mainFontFB->set_font_name (Glib::ustring::compose ("%1 %2", options.fontFamily, options.fontSize)); + mainFontFB->set_font_name (Glib::ustring::compose ("%1, %2", options.fontFamily, options.fontSize)); } if (options.CPFontFamily == "default") { - colorPickerFontFB->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize)); + colorPickerFontFB->set_font_name (Glib::ustring::compose ("%1, %2", initialFontFamily, initialFontSize)); } else { - colorPickerFontFB->set_font_name (Glib::ustring::compose ("%1 %2", options.CPFontFamily, options.CPFontSize)); + colorPickerFontFB->set_font_name (Glib::ustring::compose ("%1, %2", options.CPFontFamily, options.CPFontSize)); } showDateTime->set_active(moptions.fbShowDateTime); @@ -2243,7 +2256,7 @@ void Preferences::cancelPressed() // set the initial font back Pango::FontDescription fd (mainFontFB->get_font_name()); - if (fd.get_family() != options.fontFamily && (fd.get_size() / Pango::SCALE) != options.fontSize) { + if (fd.get_family() != options.fontFamily || (fd.get_size() / Pango::SCALE) != options.fontSize) { if (options.fontFamily == "default") { switchFontTo(initialFontFamily, initialFontSize); } else { @@ -2446,6 +2459,7 @@ void Preferences::fontChanged() { newFont = true; Pango::FontDescription fd (mainFontFB->get_font_name()); + printf("test: %s\n", mainFontFB->get_font_name().c_str()); switchFontTo(fd.get_family(), fd.get_size() / Pango::SCALE); } @@ -2457,34 +2471,26 @@ void Preferences::cpFontChanged() void Preferences::switchFontTo(const Glib::ustring &newFontFamily, const int newFontSize) { - - if (newFontFamily != "default") { - if (!fontcss) { - fontcss = Gtk::CssProvider::create(); - Glib::RefPtr screen = Gdk::Screen::get_default(); - Gtk::StyleContext::add_provider_for_screen(screen, fontcss, GTK_STYLE_PROVIDER_PRIORITY_USER); - } - - 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)); -//#else - fontcss->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", newFontFamily, newFontSize)); -//#endif - //GTK318 - } catch (Glib::Error &err) { - printf("Error: \"%s\"\n", err.what().c_str()); - } catch (...) { - printf("Error: Can't find the font named \"%s\"\n", newFontFamily.c_str()); - } - } else { - if (fontcss) { - fontcss = Gtk::CssProvider::create(); - Glib::RefPtr screen = Gdk::Screen::get_default(); - Gtk::StyleContext::remove_provider_for_screen(screen, fontcss); - } + // Create CssProvider if not existing + if (!fontcss) { + fontcss = Gtk::CssProvider::create(); + Glib::RefPtr screen = Gdk::Screen::get_default(); + Gtk::StyleContext::add_provider_for_screen(screen, fontcss, GTK_STYLE_PROVIDER_PRIORITY_USER); } + + // Create css to load based on new font name and size + const auto css = Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", newFontFamily, newFontSize); + + // Load css to update font name and size + try { + fontcss->load_from_data (css); + } catch (Glib::Error &err) { + printf("Error: \"%s\"\n", err.what().c_str()); + } catch (...) { + printf("Error: Can't load the desired font correctly\n"); + } + + printf("switchFontTo: %s\n", css.c_str()); } void Preferences::workflowUpdate() diff --git a/rtgui/rtscalable.h b/rtgui/rtscalable.h index 673ea5685..6913515aa 100644 --- a/rtgui/rtscalable.h +++ b/rtgui/rtscalable.h @@ -34,6 +34,11 @@ * - 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) + * Notes: + * - By default, size is expressed in non-absolute size (i.e. "pt"). Conversion between absolute + * and non-absolute size is ensured by Pango. + * - On MacOS, font is already scaled by the System library (i.e. "size in px" = "size in pt" * 1.). + * Refer to https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkscreen-quartz.c * * 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. diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index ef2e58934..7899fb250 100755 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -139,71 +139,35 @@ RTWindow::RTWindow () // Set the font face and size Glib::ustring css; -#ifndef __APPLE__ - 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 - const double fontScale = 1.; -#endif - auto style = get_pango_context(); - if (options.fontFamily != "default") { // Set font and size according to user choice - // Scale font size based on DPI and Scale - const int scaledFontSize = static_cast(options.fontSize * fontScale + 0.5); + // Set font and size in css from options + css = Glib::ustring::compose ("* { font-family: %1; font-size: %2pt}", + options.fontFamily, + options.fontSize); // Font size is in "pt" in options + } else { // Set font and size according to default values + // Retrieve default style values from Gtk::Settings + const auto defaultSettings = Gtk::Settings::get_default(); + Glib::ustring defaultFont; + defaultSettings->get_property("gtk-font-name", defaultFont); + const Pango::FontDescription defaultFontDesc = Pango::FontDescription(defaultFont); // Set font and size in css - css = Glib::ustring::compose ("* { font-family: %1; font-size: %2px}", options.fontFamily, scaledFontSize); - - if (rtengine::settings->verbose) { - printf("\"Non-Default\" font size in pt(%d) * scale(%.3f) = font size in px(%d)\n", options.fontSize, fontScale, scaledFontSize); + auto defaultFontFamily = defaultFontDesc.get_family(); + const int defaultFontSize = defaultFontDesc.get_size() / Pango::SCALE; // Font size is managed in ()"pt" * Pango::SCALE) by Pango (also refer to notes in rtscalable.h) +#if defined(__APPLE__) + // Default MacOS font (i.e. "") is not correctly handled + // in Gtk css. Replacing it by "-apple-system" to avoid this + if (defaultFontFamily == ".AppleSystemUIFont") { + defaultFontFamily = "-apple-system"; } - } else { // Set font and size according to default values - // Retrieve default style values - Glib::RefPtr style = Gtk::StyleContext::create(); - Pango::FontDescription pfd = style->get_font(Gtk::STATE_FLAG_NORMAL); - - if (pfd.get_set_fields() & Pango::FONT_MASK_SIZE) { - int fontSize = pfd.get_size(); - const bool isAbsoluteFontSize = pfd.get_size_is_absolute(); - int newFontSize; - - if (isAbsoluteFontSize) { - // Absolute size is defined in "Pango units" and shall be divided by - // Pango::SCALE to get "px" - fontSize = fontSize / Pango::SCALE; - -#ifndef __APPLE__ - // Guessing that pixel size is given for a 96 DPI reference: - 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 - const double newFontScale = 1.; #endif - newFontSize = static_cast(fontSize * newFontScale + 0.5); - - if (rtengine::settings->verbose) { - printf("\"Default\" absolute font size(%d)\n", newFontSize); - } - } else { - // Non-absolute size is defined in "Pango units" and shall be divided by - // Pango::SCALE to get "px" - fontSize = fontSize / Pango::SCALE; - - // Non-absolute size is defined in "pt" and shall be converted to "px" - newFontSize = static_cast(fontSize * fontScale + 0.5); - - if (rtengine::settings->verbose) { - printf("\"Default\" non-absolute font size in pt(%d) * scale(%.3f) = font size in px(%d)\n", fontSize, fontScale, newFontSize); - } - } - - // Set font and size in css - css = Glib::ustring::compose ("* { font-size: %1px}", newFontSize); - } + css = Glib::ustring::compose ("* { font-family: %1; font-size: %2pt}", + defaultFontFamily, + defaultFontSize); } + printf("test : %s\n", css.c_str()); + // Load custom CSS for font if (!css.empty()) { if (rtengine::settings->verbose) { @@ -218,7 +182,7 @@ RTWindow::RTWindow () } catch (Glib::Error &err) { printf ("Error: \"%s\"\n", err.what().c_str()); } catch (...) { - printf ("Error: Can't find the font named \"%s\"\n", options.fontFamily.c_str()); + printf ("Error: Can't load the desired font correctly\n"); } } } diff --git a/rtgui/splash.cc b/rtgui/splash.cc index ea3cb59e7..0015c4864 100644 --- a/rtgui/splash.cc +++ b/rtgui/splash.cc @@ -41,21 +41,12 @@ bool SplashImage::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr) cfo.set_antialias (Cairo::ANTIALIAS_SUBPIXEL); Glib::RefPtr context = get_pango_context (); context->set_cairo_font_options (cfo); - Pango::FontDescription fontd = context->get_font_description (); + Pango::FontDescription fontd = get_style_context()->get_font(); fontd.set_weight (Pango::WEIGHT_LIGHT); const int fontSize = 12; // pt - // Converting font size to "px" based on DPI and scale -#ifndef __APPLE__ - 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 - 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)); + // Non-absolute size is defined in "Pango units" and shall be multiplied by + // Pango::SCALE from "pt": + fontd.set_size(fontSize * Pango::SCALE); context->set_font_description (fontd); int w, h; diff --git a/rtgui/thumbbrowserentrybase.cc b/rtgui/thumbbrowserentrybase.cc index 424b04680..2f9fb4b47 100644 --- a/rtgui/thumbbrowserentrybase.cc +++ b/rtgui/thumbbrowserentrybase.cc @@ -376,7 +376,7 @@ void ThumbBrowserEntryBase::updateBackBuffer () // draw file name Glib::RefPtr context = w->get_pango_context () ; - Pango::FontDescription fontd = context->get_font_description (); + Pango::FontDescription fontd = w->get_style_context()->get_font(); fontd.set_weight (Pango::WEIGHT_BOLD); if (italicstyle) { @@ -442,7 +442,7 @@ void ThumbBrowserEntryBase::getTextSizes (int& infow, int& infoh) // filename: - Pango::FontDescription fontd = context->get_font_description (); + Pango::FontDescription fontd = w->get_style_context()->get_font(); fontd.set_weight (Pango::WEIGHT_BOLD); context->set_font_description (fontd); Glib::RefPtr fn = w->create_pango_layout(dispname);