diff options
| author | Robert Pluim <rpluim@gmail.com> | 2021-10-18 11:51:10 +0200 |
|---|---|---|
| committer | Robert Pluim <rpluim@gmail.com> | 2021-10-19 14:40:26 +0200 |
| commit | 9bd2f59db608def1b588b03eff846d3fe8a7fa00 (patch) | |
| tree | 39a768d3990701aef8461a40f7c595c424382766 /src | |
| parent | e55e2d4a110447540db6bbdb9cb1c12313b4b8ad (diff) | |
Handle VS-16 correctly for non-emoji codepoints
* admin/unidata/blocks.awk: Remove emoji overrides for codepoints with
Emoji_Presentation = No, they're no longer necessary.
* lisp/composite.el: Remove #xFE0F (VS-16) from the range handled by
`compose-gstring-for-variation-glyph' so it can be handled by
`font_range'.
* src/composite.c (syms_of_composite): New variable
`auto-composition-emoji-eligible-codepoints'.
* admin/unidata/emoji-zwj.awk: Generate value for
`auto-composition-emoji-eligible-codepoints'. Add
`composition-function-table' entries for 'codepoint + U+FE0F' for
them.
* src/font.c (codepoint_is_emoji_eligible): New function to check if
we should try to use the emoji font for a codepoint.
(font_range): Use it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/composite.c | 11 | ||||
| -rw-r--r-- | src/font.c | 20 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/composite.c b/src/composite.c index f456e7a835d..c170805d9dd 100644 --- a/src/composite.c +++ b/src/composite.c @@ -2124,6 +2124,17 @@ GSTRING, or modify GSTRING itself and return it. See also the documentation of `auto-composition-mode'. */); Vcomposition_function_table = Fmake_char_table (Qnil, Qnil); + DEFVAR_LISP ("auto-composition-emoji-eligible-codepoints", Vauto_composition_emoji_eligible_codepoints, + doc: /* List of codepoints for which auto-composition will check for an emoji font. + +These are codepoints which have Emoji_Presentation = No, and thus by +default are not displayed as emoji. In certain circumstances, such as +when followed by U+FE0F (VS-16) the emoji font should be used for +them anyway. + +This list is auto-generated, you should not need to modify it. */); + Vauto_composition_emoji_eligible_codepoints = Qnil; + defsubr (&Scompose_region_internal); defsubr (&Scompose_string_internal); defsubr (&Sfind_composition_internal); diff --git a/src/font.c b/src/font.c index 83f0f8296ad..6cd4a6b5c11 100644 --- a/src/font.c +++ b/src/font.c @@ -3860,6 +3860,23 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w, #ifdef HAVE_WINDOW_SYSTEM +/* Check if CH is a codepoint for which we should attempt to use the + emoji font, even if the codepoint itself has Emoji_Presentation = + No. Vauto_composition_emoji_eligible_codepoints is filled in for + us by admin/unidata/emoji-zwj.awk. */ +static bool +codepoint_is_emoji_eligible (int ch) +{ + if (EQ (CHAR_TABLE_REF (Vchar_script_table, ch), Qemoji)) + return true; + + if (! NILP (Fmemq (make_fixnum (ch), + Vauto_composition_emoji_eligible_codepoints))) + return true; + + return false; +} + /* Check how many characters after character/byte position POS/POS_BYTE (at most to *LIMIT) can be displayed by the same font in the window W. FACE, if non-NULL, is the face selected for the character at POS. @@ -3907,8 +3924,7 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit, /* If the composition was triggered by an emoji, use a character from 'script-representative-chars', rather than the first character in the string, to determine the font to use. */ - if (EQ (CHAR_TABLE_REF (Vchar_script_table, ch), - Qemoji)) + if (codepoint_is_emoji_eligible (ch)) { Lisp_Object val = assq_no_quit (Qemoji, Vscript_representative_chars); if (CONSP (val)) |
