unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Faré <fahree@gmail.com>, 28901@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	[thread overview]
Message-ID: <m2a78to7cx.fsf@gmail.com> (raw)
In-Reply-To: <87blt9sg07.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 18 Nov 2019 10:14:32 +0100")

>>>>> On Mon, 18 Nov 2019 10:14:32 +0100, Lars Ingebrigtsen <larsi@gnus.org> said:

    Lars> Robert Pluim <rpluim@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@gmail.com>
AuthorDate: Mon Nov 18 10:18:25 2019 +0100
Commit:     Robert Pluim <rpluim@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.  */





  reply	other threads:[~2019-11-18  9:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 16:02 bug#28901: 25.3; Font selector fails to remember current font and size Faré
2019-11-17  8:00 ` Lars Ingebrigtsen
2019-11-17 21:16   ` Robert Pluim
2019-11-18  9:14     ` Lars Ingebrigtsen
2019-11-18  9:34       ` Robert Pluim [this message]
2019-11-18  9:36         ` Lars Ingebrigtsen
2019-11-19 12:43           ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2a78to7cx.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=28901@debbugs.gnu.org \
    --cc=fahree@gmail.com \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).