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.
describe-fontset
show you for your new fontset?C-@ .. DEL -*-Noto Serif-*-*-*-*-*-*-*-*-*-*-*-*
for ASCII and .. ヿ (#x3040 .. #x30FF) -*-Noto Serif CJK JP-*-*-*-*-*-*-*-*-*-*-*-*
for Japanese, soset-fontset-font
is working as it should, AFAICT. (FYI, a sample kana is あ at #x3042)set-face-font
? It sets attribute:font
, whose value can be a font or a fontset.:font
being able to be a fontset. But that seems to be what lets a face have different fonts for different chars. I filed Emacs bug #53664 to improve this aspect of the manual.set-face-font
. Unfortunately, it's the same deal as setting:font
withset-face-attribute
. The doc is wrong in this respect.