Adding spciial case for MacOS which has a base DPI of 72.
See issue #3547
This commit is contained in:
@@ -42,12 +42,12 @@ void RTScalable::setDPInScale (const double newDPI, const int newScale)
|
|||||||
// HOMBRE: On windows, if scale = 2, the dpi is non significant, i.e. should be considered = 192 ; don't know for linux/macos
|
// HOMBRE: On windows, if scale = 2, the dpi is non significant, i.e. should be considered = 192 ; don't know for linux/macos
|
||||||
dpi = newDPI;
|
dpi = newDPI;
|
||||||
if (scale == 1) {
|
if (scale == 1) {
|
||||||
if (dpi >= 192.) {
|
if (dpi >= baseHiDPI) {
|
||||||
scale = 2;
|
scale = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (scale == 2) {
|
else if (scale == 2) {
|
||||||
if (dpi < 192.) {
|
if (dpi < baseHiDPI) {
|
||||||
dpi *= 2.;
|
dpi *= 2.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,15 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
static constexpr double baseDPI = 72;
|
||||||
|
static constexpr double baseHiDPI = 144;
|
||||||
|
#else
|
||||||
|
static constexpr double baseDPI = 96;
|
||||||
|
static constexpr double baseHiDPI = 192;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void init(Gtk::Window *window);
|
static void init(Gtk::Window *window);
|
||||||
static void cleanup();
|
static void cleanup();
|
||||||
static double getDPI ();
|
static double getDPI ();
|
||||||
|
@@ -188,14 +188,14 @@ RTWindow::RTWindow ()
|
|||||||
if (isPix) {
|
if (isPix) {
|
||||||
// HOMBRE: guessing here...
|
// HOMBRE: guessing here...
|
||||||
// if resolution is lower than 192ppi, we're supposing that it's already expressed in a scale==1 scenario
|
// if resolution is lower than 192ppi, we're supposing that it's already expressed in a scale==1 scenario
|
||||||
if (resolution >= 192) {
|
if (resolution >= int(RTScalable::baseHiDPI)) {
|
||||||
// converting the resolution to a scale==1 scenario
|
// converting the resolution to a scale==1 scenario
|
||||||
resolution /= 2;
|
resolution /= 2;
|
||||||
}
|
}
|
||||||
// 1pt = 1/72in @ 96 ppi
|
// 1pt = 1/72in @ 96 ppi
|
||||||
// HOMBRE: If the font unit is px, is it alredy scaled up to match the resolution ?
|
// HOMBRE: If the font unit is px, is it alredy scaled up to match the resolution ?
|
||||||
// px >inch >pt >"scaled pt"
|
// px >inch >pt >"scaled pt"
|
||||||
pt = (int)(fontSize / 96. * 72 * (96. / resolution) + 0.49);
|
pt = (int)(double(fontSize) / RTScalable::baseDPI * 72. * (RTScalable::baseHiDPI / resolution) + 0.49);
|
||||||
} else {
|
} else {
|
||||||
pt = fontSize / Pango::SCALE;
|
pt = fontSize / Pango::SCALE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user