SHCSelector, ThresholdSelector, LabGrid and Curves now handles HiDPI

see issue #3547
This commit is contained in:
Hombre
2019-01-02 18:04:58 +01:00
parent a9cf56a957
commit 78fa7dc063
20 changed files with 1551 additions and 1142 deletions

View File

@@ -319,45 +319,37 @@ RTWindow *create_rt_window()
if (options.fontFamily != "default") {
//GTK318
#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20
css = Glib::ustring::compose ("* { font-family: %1; font-size: %2px }", options.fontFamily, options.fontSize * scale);
css = Glib::ustring::compose ("* { font-family: %1; font-size: %2px}", options.fontFamily, options.fontSize * scale);
#else
css = Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", options.fontFamily, options.fontSize * scale);
css = Glib::ustring::compose ("* { font-family: %1; font-size: %2pt}", options.fontFamily, options.fontSize * scale);
#endif
//GTK318
fontScale = options.fontSize / 9.f;
} else if (scale == 2) {
} else {
Glib::RefPtr<Gtk::StyleContext> style = Gtk::StyleContext::create();
Pango::FontDescription pfd = style->get_font(Gtk::STATE_FLAG_NORMAL);
int pt;
if (pfd.get_set_fields() & Pango::FONT_MASK_SIZE) {
int fontSize = pfd.get_size();
bool isPix = pfd.get_size_is_absolute();
printf("FONT SIZE = %d pt\n", fontSize);
double r = style->get_screen()->get_resolution();
printf("RESOLUTION = %.3f\n", r);
int resolution = (int)style->get_screen()->get_resolution();
if (isPix) {
// 1pt = 1/72in @ 96 ppi
// HOMBRE: If the font unit is px, is it alredy scaled up to match the resolution ?
double resolution = style->get_screen()->get_resolution();
// px >inch >pt >"scaled pt"
int pt = (int)(fontSize / 96. * 72 * (96. / resolution) + 0.49);
// HOMBRE: guessing here...
// if resolution is lower than 192ppi, we're supposing that it's already expressed in a scale==1 scenario
if (resolution >= 192) {
// it's already scaled up, no need to set the font size
resolution /= 2.; // Reducing the value for a scale==1 case
pt /= 2.;
} else {
// fontSize is for scale==1, we have to scale up
css = Glib::ustring::compose ("* { font-size: %1pt }", pt * scale);
// converting the resolution to a scale==1 scenario
resolution /= 2;
}
fontScale = (float)pt / 9.f;
// 1pt = 1/72in @ 96 ppi
// HOMBRE: If the font unit is px, is it alredy scaled up to match the resolution ?
// px >inch >pt >"scaled pt"
pt = (int)(fontSize / 96. * 72 * (96. / resolution) + 0.49);
} else {
int pt = fontSize / Pango::SCALE;
css = Glib::ustring::compose ("* { font-size: %1pt }", pt * scale);
fontScale = (float)pt / 9.f;
pt = fontSize / Pango::SCALE;
}
fontScale = (float)pt / 9.f;
if (scale > 1 || pt != 9) {
css = Glib::ustring::compose ("* { font-size: %1pt}", pt * scale);
}
} else {
fontScale = 1.f;