Subject: Re: bug#42603: EWW shows chars > #xFF with font set by "set-fontset-font"

From: Sebastian Urban <[email-masked]>
Date: Fri, 31 Jul 2020 18:10:06 +0200

>> My use case is not related to EWW, but to fonts overall.  I use it to
>> "prevent" Emacs from searching for fonts, and to display codes of
>> characters instead of glyphs, to speed up loading text in situations
>> like in case of view-hello-file.
> 
> In that case, you should indeed use set-fontset-font, but instead of
> telling Emacs that each of the fonts covers all of the Unicode, you
> should tell Emacs which ranges of characters, or which scripts, should
> be rendered by what fonts.
> (...)
>>     (set-fontset-font "fontset-default" 'unicode "Consolas")
>>     (set-fontset-font "fontset-default" 'unicode "Symbola" nil 'append)
> 
> Instead of using 'unicode' in the above 2 lines, use either symbols of
> scripts you want to render with each font, or explicit ranges of
> character codepoints.

And if I want some characters to be rendered, and the rest not to be
rendered - to which font I should assign "the rest"?

My reasoning was:
- use Consolas as default and for as much Unicode as it covers,
- then additionally use Symbola,
- then use fonts from noto-fonts.elc according to the script,
- everything else - don't show.

>> When I type C-u C-x = on any of above letters, it says:
>>     There are text properties here:
>>       face                 variable-pitch
>> and the variable-pitch says Arial, but it's not Arial.
> 
> You countermanded that with you over-optimistic set-fontset-font
> setting, I think.

I guess I underestimated the power of set-fontset-font, it was good as
long as it was used in buffer with default font and had the same value
as default font.

Anyway, I think I found a better way to use set-fontset-font in my case:
-(set-fontset-font "fontset-default" 'unicode "Consolas")
+(set-fontset-font "fontset-default" 'unicode "nil")
I don't think I have "nil" font, and it seems to work in both HELLO file
(it loads faster, codes for some chars instead of glyphs) and in EWW buffer.

>> I DON'T want to change whole text to TNR, or any other font, with this
>> command, quite the opposite, I don't want IT to change chars above
>> 256, in EWW buffer that uses variable-pitch font, which is Arial.
> 
> Then why did you use this:
> 
>   (set-fontset-font t 'unicode "Times New Roman")
> 
> ?  It tells Emacs the opposite: to use Times New Roman for _any_
> character (because the 'unicode' script spans all the characters you
> can possibly have).

With background info about how I set fonts, I think it is easier to see
"why". I should have describe this "bug" from perspective of my init.el
instead of out of context setting TNR.

S. U.