Subject: Re: bug#29630: 25.3; Unable to change fontset using :family face attribute

From: Thomas Morgan <[email-masked]>
Date: Sat, 23 Dec 2017 21:25:22 -0800

handa <[email-masked]> writes:

> Here, fontset works as just a provider of font-related properties
> (family, weight, size, etc), and then, based on the selected font, a new
> fontset is automatically created.  This roundabout behavior was not to
> break (Emacs-internal) backward compatibility by introducing the concept
> of fontset.

Thank you, Handa-san.

(elisp)Face Attributes says this:

`:font'
     [...] If you specify a string, the contents of the string should
     be a font name (*note (emacs)Fonts::); if the font name is an XLFD
     containing wildcards, Emacs chooses the first font matching those
     wildcards. [...]

Would it make sense to add the following after the quoted sentence?

  You may also specify a fontset name as a string.  For reasons of
  backward compatibility, in the case of the `default' face this may
  automatically generate a new fontset based on the family, weight,
  size, and other font-related properties of the specified fontset.

It would probably also be helpful to document the :fontset attribute
in the manual, if that's the proper way to specify a fontset for the
the frame's default face.

> At least, calling set-fontset-font for the fontset of the current frame
> should work... and worked as far as I rememnber... but I've just found
> that this does not work with the latest Emacs?!?
>
> (set-fontset-font nil 'unicode-bmp "dejavu sans mono")
> (set-fontset-font nil 'unicode-bmp "Freemono" nil 'append)
>
> I'm now checking what is wrong.

This seems to work for me with Emacs 25.3.1.  To test it I started Emacs
with `emacs -Q' and evaluated this in *scratch*:

(progn
  (set-fontset-font nil 'unicode-bmp "DejaVu Sans Mono")
  (set-fontset-font nil 'unicode-bmp "FreeMono" nil 'append)
  (list (font-at 0 nil "G") (font-at 0 nil "⅁")))

(The second character is TURNED SANS-SERIF CAPITAL G, which is covered
by FreeMono but not by DejaVu Sans Mono.)

As expected, this was displayed in the echo area:

(#<font-object "-PfEd-DejaVu Sans Mono-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1">
 #<font-object "-GNU -FreeMono-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1">)