@@ -39,22 +39,21 @@ NotebookWindow::NotebookWindow(Cadabra *c, bool ro)
3939 // Set the window icon.
4040 set_icon_name (" cadabra2-gtk" );
4141
42- // Query high-dpi settings. For now only for cinnamon.
43- scale = 1.0 ;
42+ // Query high-dpi settings. For all systems we can probe the
43+ // HiDPI scale, and for some window managers we also probe the
44+ // text scale factor.
4445 auto screen = Gdk::Screen::get_default ();
46+ scale = screen->get_monitor_scale_factor (0 );
47+ display_scale = scale;
4548#ifndef __APPLE__
4649 const char *ds = std::getenv (" DESKTOP_SESSION" );
4750 if (ds) {
4851 settings = Gio::Settings::create ((strcmp (ds, " cinnamon" ) == 0 ) ? " org.cinnamon.desktop.interface" : " org.gnome.desktop.interface" );
49- scale = settings->get_double (" text-scaling-factor" )*screen->get_monitor_scale_factor (0 );
50- // scale = screen->get_monitor_scale_factor(0);
52+ scale *= settings->get_double (" text-scaling-factor" );
5153 }
52- #else
53- scale = screen->get_monitor_scale_factor (0 );
54- std::cerr << " cadabra-client: scale = " << scale << std::endl;
5554#endif
56- // std::cerr << "monitor scale factor " << Gdk::Monitor::get_scale_factor() << std::endl;
57- engine.set_scale (scale, screen-> get_monitor_scale_factor ( 0 ) );
55+
56+ engine.set_scale (scale, display_scale );
5857
5958#ifndef __APPLE__
6059 if (ds) {
@@ -381,6 +380,7 @@ void NotebookWindow::load_css(const std::string& text_colour)
381380 data += " *:selected { background-color: #ccc; }\n " ;
382381 data += " textview.error { background: transparent; -GtkWidget-cursor-aspect-ratio: 0.2; color: @theme_fg_color; }\n " ;
383382 data += " #ImageView { transition-property: padding, background-color; transition-duration: 1s; }\n " ;
383+ data += " #CodeInput { font-family: monospace; }\n " ;
384384 data += " #Console { padding: 5px; }\n " ;
385385 // data += "scrolledwindow { kinetic-scrolling: false; }\n";
386386
@@ -663,10 +663,10 @@ void NotebookWindow::add_cell(const DTree& tr, DTree::iterator it, bool visible)
663663 CodeInput *ci;
664664 // Ensure that all CodeInput cells share the same text buffer.
665665 if (i==0 ) {
666- ci = new CodeInput (it, it->textbuf ,scale,prefs);
666+ ci = new CodeInput (it, it->textbuf ,scale/display_scale ,prefs);
667667 global_buffer=ci->buffer ;
668668 }
669- else ci = new CodeInput (it, global_buffer,scale,prefs);
669+ else ci = new CodeInput (it, global_buffer,scale/display_scale ,prefs);
670670 if (read_only)
671671 ci->edit .set_editable (false );
672672 ci->get_style_context ()->add_provider (css_provider, GTK_STYLE_PROVIDER_PRIORITY_USER);
0 commit comments