From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ralf Jung Newsgroups: gmane.emacs.bugs Subject: bug#21028: Slow font rendering in emacs Date: Tue, 14 Mar 2017 19:41:15 +0100 Message-ID: <4000d0c9-493c-3e14-f070-f35555e240dd@ralfj.de> References: <559F9FAF.8090708@live.com> <83innbc122.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1489516942 24853 195.159.176.226 (14 Mar 2017 18:42:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 14 Mar 2017 18:42:22 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cc: 21028@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 14 19:42:16 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnrOd-0004me-GB for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Mar 2017 19:42:11 +0100 Original-Received: from localhost ([::1]:32999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnrOe-0001oA-O6 for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Mar 2017 14:42:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnrOY-0001nv-7d for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2017 14:42:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnrOV-0003A3-1I for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2017 14:42:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57748) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cnrOU-00039n-TV for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2017 14:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cnrOU-000150-Fx for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2017 14:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ralf Jung Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Mar 2017 18:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21028 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21028-submit@debbugs.gnu.org id=B21028.14895168864109 (code B ref 21028); Tue, 14 Mar 2017 18:42:02 +0000 Original-Received: (at 21028) by debbugs.gnu.org; 14 Mar 2017 18:41:26 +0000 Original-Received: from localhost ([127.0.0.1]:55947 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnrNu-00014D-EM for submit@debbugs.gnu.org; Tue, 14 Mar 2017 14:41:26 -0400 Original-Received: from eins.ralfj.de ([85.214.220.216]:55715) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnrNs-000140-4J for 21028@debbugs.gnu.org; Tue, 14 Mar 2017 14:41:25 -0400 Original-Received: from [192.168.1.110] (p54A58A74.dip0.t-ipconnect.de [84.165.138.116]) by mx.ralfj.de (Postfix) with ESMTPSA id DC07817D000F; Tue, 14 Mar 2017 19:41:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ralfj.de; s=mail; t=1489516877; bh=u3AMkYMf7JXPHMMARVnf9A870EwoVUvUba63aqj67xU=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From; b=MrxmblFRMLZvz+6RO9qIF/f9EKfV8CESYp8YCaGxj0BcWAdmTKHCRGKPAWzroM7kx WAyqTZgFg3Fz7fsMWpPq1D8bgF0ooSWrUiLkNaDOkKvuz5lg42V+US+Ihc5NwWXcqq KnxsjBQNDSHMv+nRUMqtJknCd0KfUIwjFKEV+gIM= In-Reply-To: <83innbc122.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:130587 Archived-At: Hi, >> 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. Well, maybe it makes little sense to you -- however, this requires expert knowledge about unicode blocks. I don't have that knowledge, and I think it is a bug if configuring a straight-forward fallback chain of fonts requires such knowledge. *Not* knowing these details about which font supports what, I'd say my setup makes a lot of sense. Well, actually, the following would make even more sense: (set-fontset-font "fontset-default" 'unicode (font-spec :name "Monospace" :size 11.0)) (set-fontset-font "fontset-default" 'unicode (font-spec :name "DejaVu Sans Mono" :size 11.0) nil 'append) I think back then I didn't yet know about 'append, so I used the nil range for the fallback font (the documentation even said something related to fallback for the nil range) and then I had to do this for all fontsets for it to have any effect... Anyway, I just tried the above, and the result is that things are just as slow as with my previous "bad" setup. And this time, I honestly can't think of a clearer / more sensible way to tell emacs that these are the fonts I (mainly) want to use for unicode characters. > What's > more, this is done in all the fontsets, so Emacs will waste many > cycles on futile search through these fonts, multiple times! So the slowdown happens even if I do this in just one fontset. How can searching two fonts take so much time? 95% of the characters in my document are present in Fira Sans, and only about 0.1% of the characters (I am guessing here, I suspect actually it's even less) are present in neither DejaVu nor Fira Sans. So having these two fonts first should result in very quick, successful lookups. > 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) With this configuration, emacs picks STIX to render ∃. It also picks "DejaVu Math TeX Gyre" for ↦. This breaks the monospace grid. Both of these characters are supported by DejaVu Sans Mono. You say these fonts support only Latin, Cyrillic and Greek -- but for example Fira Sans Mono supports → and … and ↑, and DejaVu Mono supports ∃ and ↦ and ▷. Are these all in one of these ranges? > (I'd also drop the :size part, but maybe you have a good reason for > that.) Well, I want to use a smaller font size than the default. If I use the "normal" way to do that through the "Set Default Font" UI, the fonts of most characters changed, but when some fallback font was picked, it used the default size again so the characters were way too big. I fixed this by adding the size to every single fontspec. So, no, no good reason. I was just desperate. > I suggest to look at fontset.el in the Emacs sources for inspiration > on how to set up the fontset correctly. Frankly, I do not plan to figure out which of my fonts support which unicode block, nor do I want to spend hours manually selecting the right font for each individual character. I believe that this is something the machine can figure out for me. With more than two billion instructions per second, it should be capable of querying two (!) fonts for every one of the maybe 1000 characters it has to display at any given time. > Or ask on emacs-devel. Well, yes, I admit I should/could have done that. After spending something like 2 or 3 hours on this issue, I was frustrated and didn't find the motivation any more to describe in detail what I tried and what went wrong. > 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... I had no intention to hang myself, but may have accidentally strangled myself in the 25 ropes that emacs gave me to configure fonts -- where all I wanted was for things to look just like they look in any other editor... Kind regards, Ralf