bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#21028: Slow font rendering in emacs


From: Eli Zaretskii
Subject: bug#21028: Slow font rendering in emacs
Date: Tue, 14 Mar 2017 17:47:49 +0200

> From: Ralf Jung <address@hidden>
> Date: Mon, 13 Mar 2017 16:54:01 +0100
> 
> Here's the setup which makes things behave badly:
> 
> (dolist (ft (fontset-list))
>   ; Main font
>   (set-fontset-font ft 'unicode (font-spec :name "Monospace" :size 11.0))
>   ; Fallback font
>   (set-fontset-font ft 'unicode (font-spec :name "DejaVu Sans Mono"
> :size 11.0) nil 'append)
> )
> 
> And here's the one I use instead, which behaves much better:
> 
> (dolist (ft (fontset-list))
>   ; Main font
>   (set-fontset-font ft 'unicode (font-spec :name "Monospace" :size 11.0))
>   ; Fallback font
>   (set-fontset-font ft nil (font-spec :name "DejaVu Sans Mono" :size 11.0))
> )
> 
> (For the record, my "Monospace" font is "Fira Sans Mono".)

See, this setup makes very little sense.  It sets up no less than 2
monospaced fonts for the entire range of Unicode codepoints, when both
of these fonts support only Latin, Greek, and Cyrillic blocks.  What's
more, this is done in all the fontsets, so Emacs will waste many
cycles on futile search through these fonts, multiple times!

Try this instead:

  (set-fontset-font "fontset-default" 'greek
                    (font-spec :name "DejaVu Sans Mono"
                    :size 11.0 :registry "iso10646-1") nil 'prepend)
  (set-fontset-font "fontset-default" 'cyrillic
                    (font-spec :name "DejaVu Sans Mono"
                    :size 11.0 :registry "iso10646-1") nil 'prepend)
  (set-fontset-font "fontset-default" 'latin
                    (font-spec :name "DejaVu Sans Mono"
                    :size 11.0 :registry "iso10646-1") nil 'prepend)
  (set-fontset-font "fontset-default" 'greek
                    (font-spec :name "Monospace"
                    :size 11.0 :registry "iso10646-1") nil 'prepend)
  (set-fontset-font "fontset-default" 'cyrillic
                    (font-spec :name "Monospace"
                    :size 11.0 :registry "iso10646-1") nil 'prepend)
  (set-fontset-font "fontset-default" 'latin
                    (font-spec :name "Monospace"
                    :size 11.0 :registry "iso10646-1") nil 'prepend)
  (set-fontset-font t nil (font-spec :name "Symbola"
                                     :size 11.0 :registry "iso10646-1")
                          nil 'append)

(I'd also drop the :size part, but maybe you have a good reason for
that.)

In Emacs 25.2, the last form is not necessary, as Symbola is already
set up by default.

> And just in case you wonder -- no, I have no idea what I am doing here.
> I arrived at that configuration after several hours of random, fairly
> unguided modifications to it until all my test characters picked the
> font I wanted:

I suggest to look at fontset.el in the Emacs sources for inspiration
on how to set up the fontset correctly.  Or ask on emacs-devel.  I
very much doubt that random modifications are likely to come up with
correct and efficient setup of the fonts, since this is indeed a
tricky issue.  (I think Emacs 25.2 improves the situation quite a bit,
so you may wish to try the latest version.)

> While I do consider it a bug that emacs picks the wrong fonts per
> default, shouldn't emacs be reasonably fast to use even if I do some
> manual configuration?

If the manual configuration forces Emacs to unnecessarily search fonts
for characters that aren't there, then it could get unreasonably slow.
We are giving the users here enough rope to hang themselves, in the
hope that they won't try doing that too hard...





reply via email to

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