@@ -8,6 +8,10 @@ public class GtkMarkdown.View : GtkSource.View {
88 public string font_monospace { get ; set ; default = " Monospace 10" ; }
99 public int url_detection_level { get ; set ; default = 0 ; }
1010
11+ private int base_font_monospace_size { get ; set ; default = 10 ; }
12+
13+ public int scale { get ; set ; default = 100 ; }
14+
1115 public Gdk . RGBA h6_color {
1216 get {
1317 var rgba = get_color ();
@@ -439,24 +443,32 @@ public class GtkMarkdown.View : GtkSource.View {
439443 }
440444 }
441445
446+ var settings = new Settings (Config . APP_ID );
447+ var prefs_font_monospace = settings. get_string (" note-font-monospace" );
448+ if (prefs_font_monospace != font_monospace) {
449+ font_monospace = prefs_font_monospace;
450+ }
451+
452+ settings. changed[" note-font-monospace" ]. connect(() = > change_font ());
453+
454+ var window_state = new Settings (@" $(Config.APP_ID).WindowState" );
455+ var prefs_scale = window_state. get_int (" text-scale" );
456+
457+ scale = prefs_scale;
458+
442459 notify[" dark" ]. connect ((s, p) = > update_color_scheme ());
443460 notify[" theme-color" ]. connect ((s, p) = > update_color_scheme ());
444461 notify[" font-monospace" ]. connect ((s, p) = > update_font ());
445462 notify[" url-detection-level" ]. connect ((s, p) = > update_url_detection ());
446463
447464 var font_desc = Pango . FontDescription . from_string (font_monospace);
448- var font_size = font_desc. get_size ();
449- if (! font_desc. get_size_is_absolute ()) {
450- font_size = font_size / Pango . SCALE ;
451- }
452- if (font_size < 3 ) {
453- font_desc. set_size (10 * Pango . SCALE );
454- font_monospace = font_desc. to_string ();
455- }
465+ base_font_monospace_size = font_desc. get_size ();
456466
457467 update_color_scheme ();
458468 update_font ();
459469
470+ notify[" scale" ]. connect(update_scale);
471+
460472 {
461473 var gutter = get_gutter (Gtk . TextWindowType . LEFT );
462474 renderer = new GtkSource .GutterRendererText ();
@@ -608,17 +620,39 @@ public class GtkMarkdown.View : GtkSource.View {
608620 }
609621 }
610622
611- private void update_font ( ) {
612- var font_desc = Pango . FontDescription . from_string (font_monospace) ;
613- var font_size = font_desc . get_size ();
623+ private int calculate_scaled_font_size ( Pango . FontDescription font_desc ) {
624+ var font_size = base_font_monospace_size ;
625+
614626 if (! font_desc. get_size_is_absolute ()) {
615- font_size = font_size / Pango . SCALE ;
627+ font_size = (( font_size / Pango . SCALE) * scale ) / 100 ;
616628 }
617- if (font_size < 3 ) {
618- font_desc. set_size (10 * Pango . SCALE );
619- font_monospace = font_desc. to_string ();
629+
630+ if (font_size < 4 ) { font_size = 4 ; }
631+
632+ return font_size;
633+ }
634+
635+ private void update_scale () {
636+ var font_desc = Pango . FontDescription . from_string (font_monospace);
637+ var font_size = calculate_scaled_font_size (font_desc);
638+
639+ font_desc. set_size (font_size * Pango . SCALE );
640+ font_monospace = font_desc. to_string ();
641+ }
642+
643+ private void change_font () {
644+ var settings = new Settings (Config . APP_ID );
645+ var prefs_font_monospace = settings. get_string (" note-font-monospace" );
646+ if (prefs_font_monospace != font_monospace) {
647+ font_monospace = prefs_font_monospace;
620648 }
621649
650+ update_font ();
651+ }
652+
653+ private void update_font () {
654+ update_scale ();
655+
622656 text_tag_around = get_or_create_tag (" markdown-code-block-around" );
623657 text_tag_around. font = font_monospace;
624658
0 commit comments