GNU bug report logs - #36288
27.0.50; Cannot use menu-set-font

Previous Next

Package: emacs;

Reported by: Robert Pluim <rpluim <at> gmail.com>

Date: Wed, 19 Jun 2019 07:49:01 UTC

Severity: normal

Found in version 27.0.50

Done: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 36288 in the body.
You can then email your comments to 36288 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Wed, 19 Jun 2019 07:49:01 GMT) Full text and rfc822 format available.

Message #3 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; Cannot use menu-set-font
Date: Wed, 19 Jun 2019 09:48:04 +0200
emacs -Q
M-x menu-set-font
select Ubuntu Mono Regular =>

"set-face-attribute: Font not available: #<font-spec xft nil Ubuntu\ Mono nil nil normal normal nil 10.0 nil nil nil ((:name . "Ubuntu Mono"))>"

I can select Ubuntu Mono using M-x customize-face. Why does
menu-set-font try to use an xft spec?

(frame-parameter nil 'font-backend) =>
(xfthb x)



In GNU Emacs 27.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-06-19
Repository revision: 50c5d5621cb5e6d7c86829ac4b776d81e47b2189
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description: Ubuntu 18.04.2 LTS

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM THREADS PDUMPER LCMS2 GMP




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Thu, 20 Jun 2019 02:55:03 GMT) Full text and rfc822 format available.

Message #6 received at 36288 <at> debbugs.gnu.org (full text, mbox):

From: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 36288 <at> debbugs.gnu.org
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Thu, 20 Jun 2019 11:54:21 +0900
On Wed, 19 Jun 2019 16:48:04 +0900,
Robert Pluim wrote:
> 
> emacs -Q
> M-x menu-set-font
> select Ubuntu Mono Regular =>
> 
> "set-face-attribute: Font not available: #<font-spec xft nil Ubuntu\ Mono nil nil normal normal nil 10.0 nil nil nil ((:name . "Ubuntu Mono"))>"
> 
> I can select Ubuntu Mono using M-x customize-face. Why does
> menu-set-font try to use an xft spec?
> 
> (frame-parameter nil 'font-backend) =>
> (xfthb x)

Maybe better to use the first entry of the font-backend frame
parameter rather than hardcoded one?

				     YAMAMOTO Mitsuharu
				mituharu <at> math.s.chiba-u.ac.jp

diff --git a/src/gtkutil.c b/src/gtkutil.c
index dccee159254..de4b25f7794 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -2281,19 +2281,16 @@ xg_get_font (struct frame *f, const char *default_name)
 	  gint        size   = pango_font_description_get_size (desc);
 	  PangoWeight weight = pango_font_description_get_weight (desc);
 	  PangoStyle  style  = pango_font_description_get_style (desc);
+	  Lisp_Object frame, font_type_wanted;
 
-#ifdef USE_CAIRO
-#define FONT_TYPE_WANTED (Qftcr)
-#else
-#define FONT_TYPE_WANTED (Qxft)
-#endif
+	  XSETFRAME (frame, f);
+	  font_type_wanted = XCAR (Fframe_parameter (frame, Qfont_backend));
 	  font = CALLN (Ffont_spec,
 			QCname, build_string (name),
 			QCsize, make_float (pango_units_to_double (size)),
 			QCweight, XG_WEIGHT_TO_SYMBOL (weight),
 			QCslant, XG_STYLE_TO_SYMBOL (style),
-			QCtype,
-                        FONT_TYPE_WANTED);
+			QCtype, font_type_wanted);
 
 	  pango_font_description_free (desc);
 	  dupstring (&x_last_font_name, name);




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Thu, 20 Jun 2019 07:52:01 GMT) Full text and rfc822 format available.

Message #9 received at 36288 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
Cc: 36288 <at> debbugs.gnu.org
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Thu, 20 Jun 2019 09:51:19 +0200
>>>>> On Thu, 20 Jun 2019 11:54:21 +0900, YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp> said:


    >> Maybe better to use the first entry of the font-backend frame
    >> parameter rather than hardcoded one?

Thanks, that works for me. Iʼve not tested what happens if I try to
use an X font rather than an xft one, but I think that usage will
eventually go away anyway.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Thu, 20 Jun 2019 08:33:01 GMT) Full text and rfc822 format available.

Message #12 received at 36288 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
Cc: 36288 <at> debbugs.gnu.org
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Thu, 20 Jun 2019 10:32:34 +0200
>>>>> On Thu, 20 Jun 2019 09:51:19 +0200, Robert Pluim <rpluim <at> gmail.com> said:

>>>>> On Thu, 20 Jun 2019 11:54:21 +0900, YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp> said:
    >>> Maybe better to use the first entry of the font-backend frame
    >>> parameter rather than hardcoded one?

    Robert> Thanks, that works for me. Iʼve not tested what happens if I try to
    Robert> use an X font rather than an xft one, but I think that usage will
    Robert> eventually go away anyway.

I tried a different variant:

(add-to-list 'default-frame-alist '(font-backend x xfthb))

then M-x menu-set-font

which gives (with your patch):

set-face-attribute: Font not available: #<font-spec x nil Ubuntu\ Mono nil nil normal normal nil 1.0 nil nil nil ((:name . "Ubuntu Mono"))>

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Thu, 20 Jun 2019 12:58:02 GMT) Full text and rfc822 format available.

Message #15 received at 36288 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 36288 <at> debbugs.gnu.org, mituharu <at> math.s.chiba-u.ac.jp
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Thu, 20 Jun 2019 15:56:52 +0300
> From: Robert Pluim <rpluim <at> gmail.com>
> Date: Thu, 20 Jun 2019 10:32:34 +0200
> Cc: 36288 <at> debbugs.gnu.org
> 
> I tried a different variant:
> 
> (add-to-list 'default-frame-alist '(font-backend x xfthb))

Where did you put this?  In the init file? or just evaluated it after
Emacs started?  In the latter case, it will be in effect only for
frames created henceforth.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Thu, 20 Jun 2019 14:20:02 GMT) Full text and rfc822 format available.

Message #18 received at 36288 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 36288 <at> debbugs.gnu.org
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Thu, 20 Jun 2019 16:19:05 +0200
>>>>> On Thu, 20 Jun 2019 15:56:52 +0300, Eli Zaretskii <eliz <at> gnu.org> said:

    >> From: Robert Pluim <rpluim <at> gmail.com>
    >> Date: Thu, 20 Jun 2019 10:32:34 +0200
    >> Cc: 36288 <at> debbugs.gnu.org
    >> 
    >> I tried a different variant:
    >> 
    >> (add-to-list 'default-frame-alist '(font-backend x xfthb))

    Eli> Where did you put this?  In the init file? or just evaluated it after
    Eli> Emacs started?  In the latter case, it will be in effect only for
    Eli> frames created henceforth.

I evaluated it, and then created a new frame, and ran menu-set-font
from there. Although I just retested with it in init.el and the result
is the same.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Thu, 20 Jun 2019 16:22:01 GMT) Full text and rfc822 format available.

Message #21 received at 36288 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 36288 <at> debbugs.gnu.org
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Thu, 20 Jun 2019 19:21:05 +0300
> From: Robert Pluim <rpluim <at> gmail.com>
> Cc: 36288 <at> debbugs.gnu.org
> Date: Thu, 20 Jun 2019 16:19:05 +0200
> 
> >>>>> On Thu, 20 Jun 2019 15:56:52 +0300, Eli Zaretskii <eliz <at> gnu.org> said:
> 
>     >> From: Robert Pluim <rpluim <at> gmail.com>
>     >> Date: Thu, 20 Jun 2019 10:32:34 +0200
>     >> Cc: 36288 <at> debbugs.gnu.org
>     >> 
>     >> I tried a different variant:
>     >> 
>     >> (add-to-list 'default-frame-alist '(font-backend x xfthb))
> 
>     Eli> Where did you put this?  In the init file? or just evaluated it after
>     Eli> Emacs started?  In the latter case, it will be in effect only for
>     Eli> frames created henceforth.
> 
> I evaluated it, and then created a new frame, and ran menu-set-font
> from there. Although I just retested with it in init.el and the result
> is the same.

This seems to be X- (and maybe also GTK-) specific.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Fri, 21 Jun 2019 13:53:02 GMT) Full text and rfc822 format available.

Message #24 received at 36288 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 36288 <at> debbugs.gnu.org
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Fri, 21 Jun 2019 15:52:43 +0200
>>>>> On Thu, 20 Jun 2019 19:21:05 +0300, Eli Zaretskii <eliz <at> gnu.org> said:

    >> From: Robert Pluim <rpluim <at> gmail.com>
    >> Cc: 36288 <at> debbugs.gnu.org
    >> Date: Thu, 20 Jun 2019 16:19:05 +0200
    >> 
    >> >>>>> On Thu, 20 Jun 2019 15:56:52 +0300, Eli Zaretskii <eliz <at> gnu.org> said:
    >> 
    >> >> From: Robert Pluim <rpluim <at> gmail.com>
    >> >> Date: Thu, 20 Jun 2019 10:32:34 +0200
    >> >> Cc: 36288 <at> debbugs.gnu.org
    >> >> 
    >> >> I tried a different variant:
    >> >> 
    >> >> (add-to-list 'default-frame-alist '(font-backend x xfthb))
    >> 
    Eli> Where did you put this?  In the init file? or just evaluated it after
    Eli> Emacs started?  In the latter case, it will be in effect only for
    Eli> frames created henceforth.
    >> 
    >> I evaluated it, and then created a new frame, and ran menu-set-font
    >> from there. Although I just retested with it in init.el and the result
    >> is the same.

    Eli> This seems to be X- (and maybe also GTK-) specific.

And it doesnʼt happen in emacs-26, which makes me strongly suspect
something to do with either the HarfBuzz or Cairo changes.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Sun, 23 Jun 2019 06:35:02 GMT) Full text and rfc822 format available.

Message #27 received at 36288 <at> debbugs.gnu.org (full text, mbox):

From: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 36288 <at> debbugs.gnu.org
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Sun, 23 Jun 2019 15:34:23 +0900
On Thu, 20 Jun 2019 11:54:21 +0900,
YAMAMOTO Mitsuharu wrote:
> 
> On Wed, 19 Jun 2019 16:48:04 +0900,
> Robert Pluim wrote:
> > 
> > emacs -Q
> > M-x menu-set-font
> > select Ubuntu Mono Regular =>
> > 
> > "set-face-attribute: Font not available: #<font-spec xft nil Ubuntu\ Mono nil nil normal normal nil 10.0 nil nil nil ((:name . "Ubuntu Mono"))>"
> > 
> > I can select Ubuntu Mono using M-x customize-face. Why does
> > menu-set-font try to use an xft spec?
> > 
> > (frame-parameter nil 'font-backend) =>
> > (xfthb x)
> 
> Maybe better to use the first entry of the font-backend frame
> parameter rather than hardcoded one?

On second thought, it seems to be better to leave the font type
unspecified.  Hard-coding the wanted font type was introduced as a
"fix" for Bug#3228, but I suspect its reasoning is no longer valid (I
couldn't find fonts.alias in the Type1 font directory in CentOS or
Linux Mint).  Also, probably we should set the :family font property
instead of :name.

				     YAMAMOTO Mitsuharu
				mituharu <at> math.s.chiba-u.ac.jp

diff --git a/src/gtkutil.c b/src/gtkutil.c
index dccee159254..1d15aec253e 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -2277,26 +2277,19 @@ xg_get_font (struct frame *f, const char *default_name)
 
       if (desc)
 	{
-	  const char *name   = pango_font_description_get_family (desc);
+	  const char *family = pango_font_description_get_family (desc);
 	  gint        size   = pango_font_description_get_size (desc);
 	  PangoWeight weight = pango_font_description_get_weight (desc);
 	  PangoStyle  style  = pango_font_description_get_style (desc);
 
-#ifdef USE_CAIRO
-#define FONT_TYPE_WANTED (Qftcr)
-#else
-#define FONT_TYPE_WANTED (Qxft)
-#endif
 	  font = CALLN (Ffont_spec,
-			QCname, build_string (name),
+			QCfamily, build_string (family),
 			QCsize, make_float (pango_units_to_double (size)),
 			QCweight, XG_WEIGHT_TO_SYMBOL (weight),
-			QCslant, XG_STYLE_TO_SYMBOL (style),
-			QCtype,
-                        FONT_TYPE_WANTED);
+			QCslant, XG_STYLE_TO_SYMBOL (style));
 
 	  pango_font_description_free (desc);
-	  dupstring (&x_last_font_name, name);
+	  dupstring (&x_last_font_name, family);
 	}
 
 #else /* Use old font selector, which just returns the font name.  */




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36288; Package emacs. (Sun, 23 Jun 2019 13:51:02 GMT) Full text and rfc822 format available.

Message #30 received at 36288 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
Cc: 36288 <at> debbugs.gnu.org
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Sun, 23 Jun 2019 15:50:11 +0200
>>>>> On Sun, 23 Jun 2019 15:34:23 +0900, YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp> said:
    >> On second thought, it seems to be better to leave the font type
    >> unspecified.  Hard-coding the wanted font type was introduced as a
    >> "fix" for Bug#3228, but I suspect its reasoning is no longer valid (I
    >> couldn't find fonts.alias in the Type1 font directory in CentOS or
    >> Linux Mint).  Also, probably we should set the :family font property
    >> instead of :name.

Thanks, that fixed things for me, with font-backend '(xfthb x) and '(x xfthb)

Iʼve not looked at Bug#3228, but at least on my Ubuntu machine I have:

/usr/share/fonts/X11/Type1/fonts.alias
/usr/share/fonts/X11/misc/fonts.alias

but given the prevalence of opentype and truetype fonts, Iʼm not sure
that thereʼs anything to worry about.

Robert




Reply sent to YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>:
You have taken responsibility. (Sun, 30 Jun 2019 07:03:02 GMT) Full text and rfc822 format available.

Notification sent to Robert Pluim <rpluim <at> gmail.com>:
bug acknowledged by developer. (Sun, 30 Jun 2019 07:03:02 GMT) Full text and rfc822 format available.

Message #35 received at 36288-done <at> debbugs.gnu.org (full text, mbox):

From: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 36288-done <at> debbugs.gnu.org
Subject: Re: bug#36288: 27.0.50; Cannot use menu-set-font
Date: Sun, 30 Jun 2019 16:02:46 +0900
On Sun, 23 Jun 2019 22:50:11 +0900,
Robert Pluim wrote:
> 
> >>>>> On Sun, 23 Jun 2019 15:34:23 +0900, YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp> said:
>     >> On second thought, it seems to be better to leave the font type
>     >> unspecified.  Hard-coding the wanted font type was introduced as a
>     >> "fix" for Bug#3228, but I suspect its reasoning is no longer valid (I
>     >> couldn't find fonts.alias in the Type1 font directory in CentOS or
>     >> Linux Mint).  Also, probably we should set the :family font property
>     >> instead of :name.
> 
> Thanks, that fixed things for me, with font-backend '(xfthb x) and '(x xfthb)
> 
> Iʼve not looked at Bug#3228, but at least on my Ubuntu machine I have:
> 
> /usr/share/fonts/X11/Type1/fonts.alias
> /usr/share/fonts/X11/misc/fonts.alias
> 
> but given the prevalence of opentype and truetype fonts, Iʼm not sure
> that thereʼs anything to worry about.

Ah, the package gsfonts-X11 seems to provide fonts.alias for URW Type1
fonts.  Anyway, I think the behavior originally reported as Bug#3228
is actually consistent in the sense that "% emacs -fn courier-12" also
displays the text in "ugly" font in OP's environment.

Also, x-select-font is a function for a generic font selection dialog,
not specific to menu-select-font.  So its result should not include
font type property only for menu-select-font.

I've pushed the patch to master as e2d8c1e8bcf.  Closing the bug.

				     YAMAMOTO Mitsuharu
				mituharu <at> math.s.chiba-u.ac.jp




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 28 Jul 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 274 days ago.

Previous Next


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