[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to enforce unicode font for all charsets?

From: Sergey Organov
Subject: Re: How to enforce unicode font for all charsets?
Date: Thu, 12 Mar 2020 09:53:05 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> From: Sergey Organov <address@hidden>
>> Cc: Eli Zaretskii <address@hidden>
>> Date: Wed, 11 Mar 2020 08:10:39 +0300
>> I mean, it looks like I need to modify fontset-auto1, as M-x
>> describe-fontset RET shows:
>> Fontset: -PfEd-DejaVu Sans 
>> Mono-normal-normal-normal-*-23-*-*-*-m-0-fontset-auto1
> No, you want to customize fontset-default.

OK, thanks, this snippet from my init.el now does the trick:

(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
(set-fontset-font t '(#x0 . #x3FFFFF)
                  (font-xlfd-name (face-attribute 'default :font)))

I've also tried 'windows-1251 instead of character range and it also
achieves the goal.

>> and after some more digging, I finally tried:
>> (set-fontset-font "fontset-auto1" 'windows-1251
>>   (font-xlfd-name (face-attribute 'default :font))
> Use 'prepend as the 5th argument of set-fontset-font, for more
> predictable results.

I've tried to add `nil 'prepend` at the end:

(set-fontset-font t '(#x0 . #x3FFFFF)
                  (font-xlfd-name (face-attribute 'default :font))
                  nil 'prepend)

but it actually unpredictably /stopped/ to do its intended job. Yet
another mystery to me.

>> which evaluates to:
>> "-PfEd-DejaVu Sans Mono-normal-normal-normal-*-23-*-*-*-m-0-iso10646-1"
>> but doesn't seem to have any visible effect.
> Please describe how you tested that.

That one had a simple mistake: one close paren less, so I've in fact
evaluated just:

(font-xlfd-name (face-attribute 'default :font))


>> And even if that worked, it wouldn't immediately pick subsequent
>> customization of the default face anyway?
> Fontset customizations are independent of faces, so I don't think I
> understand what you mean by "picking customizations of the default
> face".

They both (independently) affect displaying, and customization of
fontset seems to effectively override (parts of) customization of
default face. Let me give an example.

Thanks for your support, I've now got tweaked fontset-default as
described above that makes windows-1251 text to be displayed in DejaVu
font, being the font family of the default face as it is /at startup/.
Fine so far.

Now suppose somewhere in the future I find a font that looks better than
DejaVu. What I usually do to switch font is: M-x customize-face RET
default RET, then change font family to what I need.

Let's try it. I do M-x customize-face RET default RET, change font
family of default face from "DejaVu Sans Mono" to "Courier" and click
"Set for Current session". What I get is an ugly mixture of Courier font
for ASCII text and DejaVu Sans Mono for the rest. That's what I meant by
/no immediate/ "proper" pick-up of customization.

The DejaVu is now "sticky" due to tweaked fontset, and is not changed by
customization of the default face. (I admittedly don't understand why
ASCII text is different, as I've customized the entire range of
codepoints, but that's just yet another mystery of fonts management.)

To get consistent (now all-Courier) fonts, I'd need to click "Save for
future sessions" and then restart Emacs for (set-fontset-font ...) call
to pick new customized font family at startup.

> In general, if the default face's font supports some character, Emacs
> will use that font, so I don't quite understand why you need to
> customize your fonts just to have characters displayed by the default
> face's font.  It shouldn't be needed, if the font really supports
> those characters

Except that it /is/ needed, as I've described in my original question?

My default face's unicode font (DejaVu) obviously supports all the
characters one could ever find in windows-1251 encoding, yet such
characters are displayed in another font for text that has windows-1251
charset property imposed on it. Moreover, it seems to match the
documented Emacs behavior with respect to selecting font depending on

Are you saying that font from default face should be used despite the
charset property being set on text? Is my Emacs misconfigured or
misbehaving then?

Is there a knob to turn off charset-dependency of font selection
algorithms? If not, does it make sense to implement one?

>> >  Moreover, specifying that font for any charset is probably not
>> >  a good idea, since no font covers all of Unicode.
>> Maybe I should be able to express exactly this by specifying, say,
>> "preferred font" for a fontset?
> There's no such thing.  That's not how fontsets in Emacs work.

That's exactly my point. I was just dreaming. That said, as little as I
know about fontsets, it seems to be rather simple /addition/ to the
system that'd solve such kind of configuration problems.

>> Actually, I probably do want to use only this font (and have empty
>> rectangles or some such in case of missed glyphs). I mean some way to
>> force Emacs to behave as if this font is the only available font in the
>> entire system. Still no simple way?
> Maybe there is, but I don't know how, and frankly doing that makes
> little sense to me.

Well, I do have font that has all the glyphs /I need/, so it'd be the
simplest solution for me to just tell Emacs to only ever use that one.
Simple. Fast. Fool-proof. Don't want to resort to running in text
terminal configured to use this font though.

Here is another example of some sense: I get GNUS summary buffer for a
mixture of mails in different languages. Hieroglyphs makes zero sense to
me, yet they occupy more space vertically than most of the other glyphs.
I'd prefer them not to be displayed, and it happened to be rather simple
when there were no UNICODE fonts (just not install fonts in
corresponding encodings), but now this is quite a challenge.

> Emacs was designed to display every possible character by selecting a
> suitable font; forcibly displaying some characters as boxes is against
> its design.

Emacs is also known for its extreme flexibility and there are times when
designs change... Not that I even try to insist on anything, but current
design does seem to be very complex (that might well match the
complexity of the problem) yet not flexible enough. It seems to make
complex things possible, yet doesn't provide simple solutions for simple

Here is an example of a simple configuration that currently seems to be
not achievable: use font specified by particular face, and never resort
to anything else unless the font doesn't have needed glyph.

-- Sergey

reply via email to

[Prev in Thread] Current Thread [Next in Thread]