Add other font size scaling

Minor fixes:
- Fixes some incorrect cast
- fixes some incorrect comments
This commit is contained in:
Pandagrapher
2022-08-19 19:05:06 +02:00
parent 89d2bdce5b
commit 7ee6fd795b
8 changed files with 97 additions and 51 deletions

View File

@@ -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<double>(RTScalable::getDPI())
/ static_cast<double>(RTScalable::pangoDPI)
* RTScalable::getScale(); // Refer to notes in rtscalable.h
const double fontScale = RTScalable::getDPI() / RTScalable::pangoDPI
* static_cast<double>(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<double>(absoluteFontSize) * fontScale);
const double absoluteFontSize = static_cast<double>(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<double>(Pango::SCALE));
context->set_font_description (fontd);
int w, h;