Say I create a fontset and populate it with fonts:
(create-fontset-from-fontset-spec
(font-xlfd-name (font-spec :registry "fontset-mine")))
(set-fontset-font "fontset-mine" 'latin "Noto Serif")
(set-fontset-font "fontset-mine" 'kana "Noto Serif CJK JP")
I can't find a way to get a face to use this fontset. For example, if I set it like (set-face-attribute 'my-test-face nil :font "fontset-mine")
, then my-test-face
will show kana
scripts in Noto Sans CJK KR, not JP (presumably a fallback specified by fontset-standard
or something).
According to investigations by Yuan Fu, when set-face-attribute
or similar is given a fontset as :font
, it merely extracts the ASCII font of that set and copies its family, height, etc. onto the face (corroborated by a comparison of describe-face
before and after set-face-attribute
). This means I can't use it to set more than one font to a face simultaneously; anything not supported by the one font that is set, will use some Emacs-wide fallback. The bug report talks about setting the :fontset
attribute, but that doesn't seem to do anything either. (EDIT: this last statement was wrong; see the answer.)
So my question is: is there a way to apply user-defined fontsets to any faces? By user-defined, I mean those created in init.el
with create-fontset-from-fontset-spec
, as opposed to built-in ones like fontset-standard
. If not, are user-defined fontsets useful for anything?
My particular use case is as follows. I want to switch between these sets of fonts, depending on the type of document I'm editing.
- ETbb for
latin
, Noto Serif CJK JP forkana
. - Noto Sans for
latin
, Noto Sans CJK JP forkana
.
(There are lots more scripts I'm interested in, but I'll focus on two.) Right now I can produce a face that has any of the following, none of which is what I want.
- ETbb for
latin
and some fallback font forkana
- Noto Sans for
latin
and some fallback font forkana
- Some fallback font for
latin
and Noto Serif CJK JP forkana
- Some fallback font for
latin
and Noto Sans CJK JP forkana
The point is, without a way to apply a fontset as one indivisible unit, I can only control latin
or kana
, not both; one of them will get specified by default, not by me.