From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#63731: [PATCH] Support Emoji Variation Sequence 16 (FE0F) where appropriate Date: Mon, 05 Jun 2023 15:36:52 +0200 Message-ID: <87wn0ihvyj.fsf@gmail.com> References: <87a5xrzsph.fsf@stebalien.com> <87sfbfazfp.fsf@gmail.com> <837csrgioe.fsf@gnu.org> <87jzwqb7r3.fsf@gmail.com> <83ttvuf29m.fsf@gnu.org> <87a5xmaqul.fsf@gmail.com> <83r0qxg4q0.fsf@gnu.org> <875y88bhvr.fsf@gmail.com> <83ilc8eapd.fsf@gnu.org> <83edmvcpzl.fsf@gnu.org> <87wn0n9uol.fsf@gmail.com> <83a5xjcgev.fsf@gnu.org> <87sfbb9m4y.fsf@gmail.com> <87o7ly9t6b.fsf@gmail.com> <83edmuax13.fsf@gnu.org> <87fs7a9hl3.fsf@gmail.com> <834jnqaun6.fsf@gnu.org> <878rd29d9u.fsf@gmail.com> <83leh19kec.fsf@gnu.org> <877csijbuv.fsf@gmail.com> <83fs763vez.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27339"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 63731@debbugs.gnu.org, steven@stebalien.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 05 15:37:09 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6AOT-0006us-K4 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jun 2023 15:37:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6AON-0002DT-OC; Mon, 05 Jun 2023 09:37:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6AOM-0002DK-LN for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 09:37:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6AOM-000821-CQ for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 09:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q6AOM-0007yQ-0t for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 09:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Jun 2023 13:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63731 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch fixed Original-Received: via spool by 63731-submit@debbugs.gnu.org id=B63731.168597222130647 (code B ref 63731); Mon, 05 Jun 2023 13:37:01 +0000 Original-Received: (at 63731) by debbugs.gnu.org; 5 Jun 2023 13:37:01 +0000 Original-Received: from localhost ([127.0.0.1]:48496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6AOL-0007yC-0f for submit@debbugs.gnu.org; Mon, 05 Jun 2023 09:37:01 -0400 Original-Received: from mail-wr1-f44.google.com ([209.85.221.44]:53632) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6AOJ-0007xv-Dd for 63731@debbugs.gnu.org; Mon, 05 Jun 2023 09:37:00 -0400 Original-Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-30c2bd52f82so4977362f8f.3 for <63731@debbugs.gnu.org>; Mon, 05 Jun 2023 06:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685972213; x=1688564213; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6LUiqQTIWxvTORfKzCHuPr4Zm94+78nCOzmbylWJaK8=; b=AY4R1n6NEGOC2hr9wjzs4khaFmDv/KZAKGLoKJjoLLeyC86JsHamd9VzxWrJ3mcxHO znkuHwYuebJtRMBJc2NFIWNkY+L/sXaVfF7RurIGADnxIK0W/xMehmZrEDvYfhCqRHhJ HEHR3FRg46YqVP/uOdFweLjg5s+HkT61JkvOVsdEs5FcN/fyc/CmU6PqOyXN4nQ49Inj aXbHIYLODgAcbcONLwzkiAX2brKaOn+NxfpgCLksXTQyPQSdeOImYxn7xU/EgQRxCrUm Ux9ghhfg/EmvN1sCrnCjOmmkM2EgAi2CIgl9npeMRhrLDwL7zIWRFvoefVsfUuLQRbJr xYyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685972213; x=1688564213; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6LUiqQTIWxvTORfKzCHuPr4Zm94+78nCOzmbylWJaK8=; b=ZBfRIjX2/f965q51KwV3wsJ2/vdp13T4b5rUSYePz96zwkXI5ZtbEOZQO5oRcutBXe mFn9jtqKqOBDDxY2dieQxnrygo+9CEpelguT9QSygXnVdvBVhqIEBdt5tFkXEEX55Ucg X61vscQJH2LbjoTBYrlYN5QQpDylYUz01XpxPNZ/VWPcaEnDO4ia0NW+eJ6wy5E6dXto t0wVfdSYUvNrvnEOVdPYw5CNU77GFvDF0FBkcfo10JIYsHIAsFloHd2z0JZ/EJX2zCzC gqIEi/4yzyGIqF7IjM4yKVOilkXHsGGC99gbCXxAikfratfjo9oxs1uzhpkAhkeP89WO ghcA== X-Gm-Message-State: AC+VfDwAKuWjqZRWJqPh+MVzKKd/hbQus7KYfM7of7XDUb/vt3iKUQbS gkg0UAj7gSkhPDqPMdESBfDvkssGyM0= X-Google-Smtp-Source: ACHHUZ6gcVuCbSd7vemj2CjlfdaKWgfyvb3Xi/vDjxJEb9Y1RATOySzQGb2j5FXeBktBl0oS4t4WRA== X-Received: by 2002:adf:dbc5:0:b0:30a:8995:1dbc with SMTP id e5-20020adfdbc5000000b0030a89951dbcmr6483062wrj.26.1685972213292; Mon, 05 Jun 2023 06:36:53 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id y5-20020adfd085000000b003095bd71159sm9940540wrh.7.2023.06.05.06.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 06:36:52 -0700 (PDT) In-Reply-To: <83fs763vez.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 05 Jun 2023 16:12:20 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263008 Archived-At: >>>>> On Mon, 05 Jun 2023 16:12:20 +0300, Eli Zaretskii said: >> From: Robert Pluim >> Cc: 63731@debbugs.gnu.org, steven@stebalien.com >> Date: Mon, 05 Jun 2023 15:08:08 +0200 >>=20 >> >>>>> On Sat, 03 Jun 2023 08:36:59 +0300, Eli Zaretskii said: >>=20 >> >> Sequence Font Result >> >> 23e9 fe0e system black box >> >> 23e9 fe0e Symbola correct text representation >> >> 23e9 fe0e NotoEmoji correct text representation >> >> 23e9 fe0e NotoColorEmoji blank >> >>=20 >> >> And on emacs-29, Symbola and NotoEmoji compose that sequence >> >> correctly. Now I just need to persuade emacs-30 to use one of the= m. >>=20 Eli> So you are saying that, in our default fontset, we should specify = that Eli> #xFE0E should be displayed by Noto Emoji (with Symbola as fallback= ), Eli> and then make sure that font_range uses the same font for the like= s of Eli> #x23E9? IOW, specify a different font for VS-15 even though is sc= ript Eli> is 'emoji'? >>=20 >> Yes, that works (and we can remove VS-15 and VS-16 from the emoji >> script, so that they=CA=BCll then be displayed via >> `glyphless-char-display-control' when they=CA=BCre on their own). Eli> What about the rest of VS-nn? do they need to stay in 'emoji' scri= pt, Eli> and if so, why? They were never in the 'emoji' script anyway. >> Thanks for the suggestion Eli, I was looking at it from the wrong >> direction. Eli> You are the one who did most of the footwork, so kudos to you. Eli> This is simple enough to install on emacs-29, I think? The main change is in font.c, and looks like this. I think it=CA=BCs too big for emacs-29 (breaking composition is very easy, it=CA=BCs entirely possible I=CA=BCve missed a few cases :-) ) diff --git a/src/font.c b/src/font.c index e586277a5d3..30b088c818e 100644 --- a/src/font.c +++ b/src/font.c @@ -3633,10 +3633,14 @@ font_at (int c, ptrdiff_t pos, struct face *face, s= truct window *w, /* Check if CH is a codepoint for which we should attempt to use the emoji font, even if the codepoint itself has Emoji_Presentation =3D No. Vauto_composition_emoji_eligible_codepoints is filled in for - us by admin/unidata/emoji-zwj.awk. */ + us by admin/unidata/emoji-zwj.awk. We also check if there's a + VS-15 or VS-16 following CH, and select text/emoji presentation + respectively if so. */ static bool -codepoint_is_emoji_eligible (int ch) +codepoint_is_font_change_eligible (int ch, int next_c) { + if (next_c =3D=3D 0xFE0E || next_c =3D=3D 0xFE0F) + return true; if (EQ (CHAR_TABLE_REF (Vchar_script_table, ch), Qemoji)) return true; =20 @@ -3690,21 +3694,43 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrd= iff_t *limit, } face =3D FACE_FROM_ID (f, face_id); } - - /* 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 (codepoint_is_emoji_eligible (ch)) + int next_c =3D 0; + { + ptrdiff_t p =3D pos; + ptrdiff_t p_b =3D pos_byte; + int c; + c =3D (NILP (string) + ? fetch_char_advance_no_check (&p, &p_b) + : fetch_string_char_advance_no_check (string, &p, &p_b)); + if (p < *limit) + { + c =3D (NILP (string) + ? fetch_char_advance_no_check (&p, &p_b) + : fetch_string_char_advance_no_check (string, &p, &p_b)); + next_c =3D c; + } + } + if (codepoint_is_font_change_eligible (ch, next_c)) { - Lisp_Object val =3D assq_no_quit (Qemoji, Vscript_representative_cha= rs); - if (CONSP (val)) + if (next_c =3D=3D 0xFE0E) { - val =3D XCDR (val); + font_object =3D font_for_char (face, 0xFE0E, pos, string); + } + else + { + /* 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. */ + Lisp_Object val =3D assq_no_quit (Qemoji, Vscript_representative_chars); if (CONSP (val)) - val =3D XCAR (val); - else if (VECTORP (val)) - val =3D AREF (val, 0); - font_object =3D font_for_char (face, XFIXNAT (val), pos, string); + { + val =3D XCDR (val); + if (CONSP (val)) + val =3D XCAR (val); + else if (VECTORP (val)) + val =3D AREF (val, 0); + font_object =3D font_for_char (face, XFIXNAT (val), pos, string); + } } } =20 Robert --=20