all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Wrestling with set-fontset-font
@ 2019-12-23 18:15 Kévin Le Gouguec
  2019-12-23 20:02 ` Eli Zaretskii
  2019-12-27 18:52 ` use-default-font-for-symbols vs. emojis (was: Wrestling with set-fontset-font) Kévin Le Gouguec
  0 siblings, 2 replies; 8+ messages in thread
From: Kévin Le Gouguec @ 2019-12-23 18:15 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 195 bytes --]

Hello,

I would like to setup Emacs to look at Noto Color Emoji first, then at
Symbola, for characters belonging to the "symbol" script.  For a while I
thought this bit of configuration worked:


[-- Attachment #2: Type: application/emacs-lisp, Size: 153 bytes --]

[-- Attachment #3: Type: text/plain, Size: 331 bytes --]


Then I realized that for some reason, one specific character (⚙ U+2699
GEAR) remains stubbornly displayed with DejaVu Sans Mono.

I think the problem may stem from fontset-startup, but even after
reading everything the manual has to say about fontsets I still feel a
bit out of my depth.  From emacs -Q, after running:


[-- Attachment #4: Type: application/emacs-lisp, Size: 108 bytes --]

(set-fontset-font t ?⚙ "Noto Color Emoji")
(set-fontset-font "fontset-startup" ?⚙ "Noto Color Emoji")

[-- Attachment #5: Type: text/plain, Size: 2044 bytes --]


- the GEAR character is still displayed with DejaVu Sans Mono; C-u C-x =
  says:

>               display: by this font (glyph code)
>     ftcrhb:-PfEd-DejaVu Sans Mono-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1 (#xAE4)

- yet for both fontset-default and fontset-startup, M-x describe-fontset
  says:

> ⚙ (#x2699)
>    -*-Noto Color Emoji-*-*-*-*-*-*-*-*-*-*-*-*

- GEAR characters displayed with an italic face (e.g. with
 (insert (propertize "\n⚙\n" 'font-lock-face 'italic))
 ) are correctly shown with Noto Color Emoji.


So far I've only had this problem with ⚙ U+2699 GEAR, though I suspect
that any character covered by DejaVu Sans Mono would show similar
symptoms.  If instead, I run (set-fontset-font t ?🤷 "Noto Color Emoji")
(i.e. using U+1F937 SHRUG) from emacs -Q, then

- before running set-fontset-font, the character is displayed with
  Symbola; C-u C-x = says

>               display: by this font (glyph code)
>     ftcrhb:-UFAS-Symbola-normal-normal-semicondensed-*-15-*-*-*-*-0-iso10646-1 (#x2630)

- after running set-fonset-font, the character is displayed with Noto
  Color Emoji; C-u C-x = says

>               display: by this font (glyph code)
>     ftcrhb:-GOOG-Noto Color Emoji-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1 (#x9EB)

- and M-x describe-fontset fontset-default says

> 🤷 (#x1F937)
>     -*-Noto Color Emoji-*-*-*-*-*-*-*-*-*-*-*-*
> 	[-GOOG-Noto Color Emoji-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1]

  (Note the third line; if I understand describe-fontset's output
  correctly, this means that no font was opened for U+2699 GEAR?)


At this point, I don't know whether I am misunderstanding something
fundamental about fontsets, or if I am facing a bug.  I'm pretty sure
it's the former.  I don't know what else I should be looking at though…

If anyone has pointers to documentation I might have missed, that would
be greatly appreciated.

Cheers!


(I'm not subscribed to the list; thanks for keeping me CC'ed!)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Wrestling with set-fontset-font
  2019-12-23 18:15 Wrestling with set-fontset-font Kévin Le Gouguec
@ 2019-12-23 20:02 ` Eli Zaretskii
  2019-12-27 18:52 ` use-default-font-for-symbols vs. emojis (was: Wrestling with set-fontset-font) Kévin Le Gouguec
  1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2019-12-23 20:02 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> Date: Mon, 23 Dec 2019 19:15:25 +0100
> 
> I would like to setup Emacs to look at Noto Color Emoji first, then at
> Symbola, for characters belonging to the "symbol" script.  For a while I
> thought this bit of configuration worked:
> 
> (set-fontset-font t 'symbol "Symbola" nil 'prepend)
> (when (>= emacs-major-version 27)
>   (set-fontset-font t 'symbol "Noto Color Emoji" nil 'prepend))
> 
> Then I realized that for some reason, one specific character (⚙ U+2699
> GEAR) remains stubbornly displayed with DejaVu Sans Mono.

Emacs by default prefers using the default font for displaying symbol
and punctuation characters, if that font supports them.  Set
use-default-font-for-symbols to nil to force Emacs always select the
font according to your fontsets, when it needs to display such
characters, even if the default font can display them.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* use-default-font-for-symbols vs. emojis (was: Wrestling with set-fontset-font)
  2019-12-23 18:15 Wrestling with set-fontset-font Kévin Le Gouguec
  2019-12-23 20:02 ` Eli Zaretskii
@ 2019-12-27 18:52 ` Kévin Le Gouguec
  2019-12-27 20:20   ` Eli Zaretskii
  1 sibling, 1 reply; 8+ messages in thread
From: Kévin Le Gouguec @ 2019-12-27 18:52 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Eli Zaretskii <eliz@gnu.org>
> Emacs by default prefers using the default font for displaying symbol
> and punctuation characters, if that font supports them.  Set
> use-default-font-for-symbols to nil to force Emacs always select the
> font according to your fontsets, when it needs to display such
> characters, even if the default font can display them.

Thank you!  (Note to self: when Info and Custom fail, there's always C-h
v *keyword TAB…)

*skims comment in fontset.c:face_for_char*

How interesting!

>          However, these considerations are unlikely to be relevant to
>          punctuation and other symbols, since the latter generally
>          aren't specific to any culture, and don't require
>          sophisticated OTF features.  */

Do emojis challenge this heuristic, since

- they can typically use "sophisticated OTF features" such as color,
- combining sequences[1] are a thing?

If so, could/should there be a way to distinguish "emoji" characters
from the more general "symbol" script, using e.g. data from
<https://unicode.org/Public/emoji/12.1/>?

(I hope at least /some/ of the above makes sense.  My knowledge of
Fonts, the Unicode and Everything is anecdotal at best…)


PS: Sorry for not replying to your message Eli; I'm not subscribed to
    help-gnu-emacs, and I can't find an NNTP feed for it…


[1] E.g. 🧟‍♂️, 🧟‍♀️, 🐕‍🦺, 🏴‍☠️, from
    <https://unicode.org/Public/emoji/12.1/emoji-zwj-sequences.txt>, or
    flag sequences from
    <https://unicode.org/Public/emoji/12.1/emoji-sequences.txt>; none of
    which work inside Emacs yet AFAICT.

    To be more precise: as of commit 9ee5af31, these examples appear
    "decombined".  I have no idea what controls this (Harfbuzz? Cairo?)…

    FWIW, on Debian Buster, these combinations work for some of XFCE's
    applications (e.g. Thunar, Mousepad) but not others (e.g. Terminal).
    (Well, some of these combinations anyway.  No application seems to
    give the faithful U+1F415 U+200D U+1F9BA the love it deserves…)



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: use-default-font-for-symbols vs. emojis (was: Wrestling with set-fontset-font)
  2019-12-27 18:52 ` use-default-font-for-symbols vs. emojis (was: Wrestling with set-fontset-font) Kévin Le Gouguec
@ 2019-12-27 20:20   ` Eli Zaretskii
  2019-12-27 20:32     ` use-default-font-for-symbols vs. emojis Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-12-27 20:20 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> Date: Fri, 27 Dec 2019 19:52:49 +0100
> 
> >          However, these considerations are unlikely to be relevant to
> >          punctuation and other symbols, since the latter generally
> >          aren't specific to any culture, and don't require
> >          sophisticated OTF features.  */
> 
> Do emojis challenge this heuristic, since
> 
> - they can typically use "sophisticated OTF features" such as color,
> - combining sequences[1] are a thing?

We don't yet support these features, so they are largely irrelevant
for Emacs at this point.  And (sadly) I don't see anyone around who
knows enough and has enough motivation and energy to teach Emacs to
support that.

> If so, could/should there be a way to distinguish "emoji" characters
> from the more general "symbol" script, using e.g. data from
> <https://unicode.org/Public/emoji/12.1/>?

If and when we need that, it will be almost trivial.  What's
non-trivial is to add support for color emoji.

> [1] E.g. 🧟‍♂️, 🧟‍♀️, 🐕‍🦺, 🏴‍☠️, from
>     <https://unicode.org/Public/emoji/12.1/emoji-zwj-sequences.txt>, or
>     flag sequences from
>     <https://unicode.org/Public/emoji/12.1/emoji-sequences.txt>; none of
>     which work inside Emacs yet AFAICT.
> 
>     To be more precise: as of commit 9ee5af31, these examples appear
>     "decombined".  I have no idea what controls this (Harfbuzz? Cairo?)…

Could be a simple matter of defining more entries in
composition-function table to support these sequences (assuming the
font supports them).



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: use-default-font-for-symbols vs. emojis
  2019-12-27 20:20   ` Eli Zaretskii
@ 2019-12-27 20:32     ` Eli Zaretskii
  2019-12-27 23:40       ` Kévin Le Gouguec
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-12-27 20:32 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 27 Dec 2019 22:20:57 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> > If so, could/should there be a way to distinguish "emoji" characters
> > from the more general "symbol" script, using e.g. data from
> > <https://unicode.org/Public/emoji/12.1/>?
> 
> If and when we need that, it will be almost trivial.  What's
> non-trivial is to add support for color emoji.

Btw, the original problem was not with emoji, it was with U+2699, for
which I see no reason to use a font different from the default, except
in exceptional cases (for which you have that variable).  Emoji are
usually displayed by specialized fonts anyway, because fonts we use
for the default face are unlikely to cover emoji.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: use-default-font-for-symbols vs. emojis
  2019-12-27 20:32     ` use-default-font-for-symbols vs. emojis Eli Zaretskii
@ 2019-12-27 23:40       ` Kévin Le Gouguec
  2019-12-28  7:40         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Kévin Le Gouguec @ 2019-12-27 23:40 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

> Btw, the original problem was not with emoji,

Right, I admit I changed the topic (though I took care to M-x
message-change-subject first :).

>                                               it was with U+2699, for
> which I see no reason to use a font different from the default, except
> in exceptional cases (for which you have that variable).

In my case, the reason is as trivial as "it wooks pwetty".

I do acknowledge that using e.g. Noto Color Emoji comes with a few
disadvantages though (characters have variable widths; their foreground
color cannot be set…); I plan on using color emoji mainly as mode line
lighters.

>                                                           Emoji are
> usually displayed by specialized fonts anyway, because fonts we use
> for the default face are unlikely to cover emoji.

Mmm… if I'm reading these Unicode documents right,

- the font used for the default face likely covers a few "emoji"[1]
  (e.g. I use DejaVu Sans Mono, which has U+2699 ⚙ and U+26A0 ⚠),

- although some (most?) of those will have their Emoji_Presentation
  property set to "No"[2], so it makes sense to display them with the
  default font.

[1] https://unicode.org/Public/emoji/12.1/emoji-data.txt
[2] http://www.unicode.org/reports/tr51/#Emoji_Presentation




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: use-default-font-for-symbols vs. emojis
  2019-12-27 23:40       ` Kévin Le Gouguec
@ 2019-12-28  7:40         ` Eli Zaretskii
  2019-12-29 16:14           ` Kévin Le Gouguec
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-12-28  7:40 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> Date: Sat, 28 Dec 2019 00:40:00 +0100
> 
> >                                               it was with U+2699, for
> > which I see no reason to use a font different from the default, except
> > in exceptional cases (for which you have that variable).
> 
> In my case, the reason is as trivial as "it wooks pwetty".

Then there's an alternative: change your default font.

> I do acknowledge that using e.g. Noto Color Emoji comes with a few
> disadvantages though (characters have variable widths; their foreground
> color cannot be set…)

That's exactly one of the reasons why Emacs by default prefers the
default font, which is fixed-pitch and its size matches the rest of
the text.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: use-default-font-for-symbols vs. emojis
  2019-12-28  7:40         ` Eli Zaretskii
@ 2019-12-29 16:14           ` Kévin Le Gouguec
  0 siblings, 0 replies; 8+ messages in thread
From: Kévin Le Gouguec @ 2019-12-29 16:14 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 626 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
>> Date: Sat, 28 Dec 2019 00:40:00 +0100
>> 
>> >                                               it was with U+2699, for
>> > which I see no reason to use a font different from the default, except
>> > in exceptional cases (for which you have that variable).
>> 
>> In my case, the reason is as trivial as "it wooks pwetty".
>
> Then there's an alternative: change your default font.

Mmm… if you mean "use Noto Color Emoji as the font family for the
default face", the results are… somewhat less "pwetty".  Also quite
unusable.


[-- Attachment #2: noto-color-emoji-as-default-font.png --]
[-- Type: image/png, Size: 79023 bytes --]

[-- Attachment #3: Type: text/plain, Size: 146 bytes --]


(DejaVu Sans Mono on the left; Noto Color Emoji on the right.)

Apologies if you meant something else…

Anyway, I'm happy with the following:


[-- Attachment #4: Type: application/emacs-lisp, Size: 143 bytes --]

[-- Attachment #5: Type: text/plain, Size: 89 bytes --]


(I'll stop prepending Symbola to fontset-default since fontset.el
already includes it.)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-12-29 16:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-23 18:15 Wrestling with set-fontset-font Kévin Le Gouguec
2019-12-23 20:02 ` Eli Zaretskii
2019-12-27 18:52 ` use-default-font-for-symbols vs. emojis (was: Wrestling with set-fontset-font) Kévin Le Gouguec
2019-12-27 20:20   ` Eli Zaretskii
2019-12-27 20:32     ` use-default-font-for-symbols vs. emojis Eli Zaretskii
2019-12-27 23:40       ` Kévin Le Gouguec
2019-12-28  7:40         ` Eli Zaretskii
2019-12-29 16:14           ` Kévin Le Gouguec

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.