GNU bug report logs - #28901
25.3; Font selector fails to remember current font and size

Previous Next

Package: emacs;

Reported by: Faré <fahree <at> gmail.com>

Date: Thu, 19 Oct 2017 16:42:02 UTC

Severity: minor

Tags: fixed

Found in version 25.3

Fixed in version 27.1

Done: Robert Pluim <rpluim <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Robert Pluim <rpluim <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Faré <fahree <at> gmail.com>, 28901 <at> debbugs.gnu.org
Subject: bug#28901: 25.3; Font selector fails to remember current font and size
Date: Mon, 18 Nov 2019 10:34:54 +0100
>>>>> On Mon, 18 Nov 2019 10:14:32 +0100, Lars Ingebrigtsen <larsi <at> gnus.org> said:

    Lars> Robert Pluim <rpluim <at> gmail.com> writes:
    >> gtk_font_chooser_set_font? We already use that to set the default
    >> family, but we donʼt remember the size or the style.

    Lars> Yes, the problem is that apparently gtk_font_chooser_set_font doesn't
    Lars> allow you to specify those either.  Or much of anything else, for that
    Lars> matter.  At least that seemed to be the case when I looked at this some
    Lars> time back.

You canʼt directly specify them, but you can at least remember the
previous settings:

commit ccb763dc743167445c898ba56abeb2fafe1504c3
Author:     Robert Pluim <rpluim <at> gmail.com>
AuthorDate: Mon Nov 18 10:18:25 2019 +0100
Commit:     Robert Pluim <rpluim <at> gmail.com>
CommitDate: Mon Nov 18 10:18:25 2019 +0100

    Remember the full GTK font description
    
    Remember the full font description instead of just the family so that
    size/style/weight settings are preserved.
    
    * gtkutil.c (xg_get_font) [HAVE_GTK3]: Use the pango font
    description to set/get the current font (Bug#28901).

diff --git a/src/gtkutil.c b/src/gtkutil.c
index c4d2ef9d80..3447e86ccd 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -2282,7 +2282,16 @@ xg_get_font (struct frame *f, const char *default_name)
     default_name = x_last_font_name;
 
   if (default_name)
-    gtk_font_chooser_set_font (GTK_FONT_CHOOSER (w), default_name);
+    {
+#ifdef HAVE_GTK3
+      PangoFontDescription *desc
+        = pango_font_description_from_string (default_name);
+      gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (w), desc);
+      pango_font_description_free (desc);
+#else
+      gtk_font_chooser_set_font (GTK_FONT_CHOOSER (w), default_name);
+#endif
+    }
 
   gtk_widget_set_name (w, "emacs-fontdialog");
   done = xg_dialog_run (f, w);
@@ -2306,8 +2315,10 @@ xg_get_font (struct frame *f, const char *default_name)
 			QCweight, XG_WEIGHT_TO_SYMBOL (weight),
 			QCslant, XG_STYLE_TO_SYMBOL (style));
 
+          char *font_desc_str = pango_font_description_to_string (desc);
+          dupstring (&x_last_font_name, font_desc_str);
+          g_free (font_desc_str);
 	  pango_font_description_free (desc);
-	  dupstring (&x_last_font_name, family);
 	}
 
 #else /* Use old font selector, which just returns the font name.  */




This bug report was last modified 5 years and 183 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.