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

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

bug#21028: Performance regression in revision af1a69f4d17a482c359d98c00e


From: Clément Pit--Claudel
Subject: bug#21028: Performance regression in revision af1a69f4d17a482c359d98c00ef86fac835b5fac (Apr 2014).
Date: Wed, 15 Mar 2017 16:46:33 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

On 2017-03-15 11:36, Eli Zaretskii wrote:
> The problem here is that opening a font and looking up a character is
> very expensive, certainly when there are hundreds of fonts installed.
> So Emacs filters the fonts according to the scripts they claim to
> support, and only opens those which appear to be valid candidates for
> the script of the character it needs to display.  By using 'unicode as
> the script when you set up your fontset, you actually trip Emacs by
> telling it to try this font for every character it needs to display.
> You should instead specify the scripts which the fonts supports well.

Ok — but why wasn't it slow in 24.3?  And why does the number of fonts matter, 
if I'm only adding one (Symbola) with 'unicode?

> That shouldn't be a problem in Emacs 25: it by default uses the
> default face's font for any punctuation and symbol characters for
> which the font has glyphs, even if the fontset specifies a different
> font for punctuation and symbol blocks.

Neat.  Though of course that doesn't help for Emacs < 24.

> So using more accurate scripts gives a major improvement.  Good.

It also seems to negate the previous conclusion, right? In these fast example 
I'm still adding Symbola with 'unicode — but adding Ubuntu Mono with 'latin.  
Shouldn't that be slow, according to your explanation at the top of this post?

>> For me specifying the registry doesn't seem to do anything
> 
> That could sometimes be the case, but I have found that in some cases
> omitting the registry for characters beyond Latin-1 can be a major
> setback.  So I recommend to always use it.

Ok.  Could Emacs not infer it?  I have no clue what it means.

>>> (set-fontset-font fontset 'unicode base-spec nil)
>>>
>>> This should only specify 'latin, 'greek, and 'cyrillic (one such
>>> line for each of them), as 'unicode is a blatant lie.
>>
>> But I want more than 'latin, 'greek, and 'cyrillic: I want "any character 
>> that 
>> this font supports".

Ok, noted for Emacs >= 25.

> You can use a font utility, such as Fontforge, to see which blocks the
> font supports, and how many characters from each block it can display.
> My conclusion from looking at Ubuntu Mono is that the above 3 scripts
> are the only ones it supports well; the rest are not covered well at
> all.  You can, of course, add more scripts if you need them, but the
> downside will be that some of those scripts will be displayed by a mix
> of more than one font, which I think will make the display ugly.

I don't care about the display being pretty as much as it being properly align 
(vertically), which means that using Ubuntu Mono helps a lot.

> Moreover, Emacs cannot compose glyphs that come from different fonts,
> so you will sometimes see decomposed display if you request a font for
> scripts where its support is incomplete.  I think this is an important
> factor for users of prettify-symbols-mode in particular.

Why? prettify-symbols-mode composes strings (typically) into single characters, 
so why would this matter?

>>> Can you ask some of those people to show their fontset setup?  I'd 
>>> like to know how different they are from your setup.
>>
>> They essentially use this:
> 
>> (dolist (ft (fontset-list))
>>   (set-fontset-font ft 'unicode (font-spec :name "YOUR-USUAL-FONT"))
>>   (set-fontset-font ft 'unicode (font-spec :name "Symbola") nil 'append))
> 
> Well, maybe with the new insights you have now, you can recommend them
> better setups which don't use 'unicode'.

I think I still have a blurry picture of the whole process, or at least it 
sounds very complicated.  Is it really the following?

* Pick a good monospace font.  Set that as the default Emacs font (this is easy)
* Pick a good math font.  Symbola is easier than others, because Emacs knows 
about it.
* Download and install fontforge.  Figure out which ranges the math font 
support, and all the characters that it supports that are not punctuation or 
symbols, too
* Create a set-fontset-font rule for each range and character.  Figure out the 
font's registry too.  Add all these rules with 'append, though for better 
performance you can use 'prepend, but for that you'll need to know which ranges 
the first font supports, too.

This sounds too complicated, given that the simpler approach used to work in 
Emacs < 24.4.  In CSS, the rule would be 'font-family: "Ubuntu Mono", "XITS 
Math"'.  In Emacs < 24.4, the following worked — and it works in Emacs 25 with 
your patch:

(dolist (ft (fontset-list))
   (set-fontset-font ft 'unicode (font-spec :name "Ubuntu Mono"))
   (set-fontset-font ft 'unicode (font-spec :name "Symbola") nil 'append))

In Emacs 25, given that symbols use the default font,  it looks like the 
following should work, at least with your patch:

  25.1/src/emacs -Q --eval "(set-fontset-font \"fontset-default\" 'unicode 
(font-spec :name \"XITS Math\") nil 'prepend)"

It seems to work ok — but without your patch, it's unbearably slow too.  This 
is better, performance-wise:

  25.1/src/emacs -Q --eval "(set-fontset-font \"fontset-default\" 'unicode 
(font-spec :name \"XITS Math\") nil nil)"

but it causes Emacs to use different fonts in different buffers (the concrete 
example is that when I press C-x 8 RET, type alpha, press TAB, and copy the 
contents of the completion buffer to *scratch*, the symbols don't appear in the 
same font in both buffers.

Cheers,
Clément.

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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