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#39799: 28.0.50; Most emoji sequences =?UTF-8?Q?don=E2=80=99t?= render correctly Date: Tue, 21 Sep 2021 19:43:05 +0200 Message-ID: <87wnn9g6za.fsf@gmail.com> References: <83lfongp4p.fsf@gnu.org> <835zfrglu5.fsf@gnu.org> <83wo86g8pg.fsf@gnu.org> <83h7zafzwh.fsf@gnu.org> <838skmfox6.fsf@gnu.org> <87h7efhtiz.fsf@gmail.com> <83o88mz3t5.fsf@gnu.org> <87y27qgqt6.fsf@gmail.com> <837dfayzat.fsf@gnu.org> <8335pyyxkx.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11683"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rgm@gnu.org, 39799@debbugs.gnu.org, mfabian@redhat.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 21 19:44:14 2021 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 1mSjoU-0002o0-5S for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Sep 2021 19:44:14 +0200 Original-Received: from localhost ([::1]:53996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSjoS-0003pw-4u for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Sep 2021 13:44:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSjoI-0003po-UX for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2021 13:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mSjoI-0005wc-KR for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2021 13:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mSjoI-0003a3-GZ for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2021 13:44: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: Tue, 21 Sep 2021 17:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39799 X-GNU-PR-Package: emacs Original-Received: via spool by 39799-submit@debbugs.gnu.org id=B39799.163224619513694 (code B ref 39799); Tue, 21 Sep 2021 17:44:02 +0000 Original-Received: (at 39799) by debbugs.gnu.org; 21 Sep 2021 17:43:15 +0000 Original-Received: from localhost ([127.0.0.1]:47892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mSjnW-0003Ym-Cf for submit@debbugs.gnu.org; Tue, 21 Sep 2021 13:43:14 -0400 Original-Received: from mail-wr1-f47.google.com ([209.85.221.47]:43969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mSjnU-0003YY-H4 for 39799@debbugs.gnu.org; Tue, 21 Sep 2021 13:43:13 -0400 Original-Received: by mail-wr1-f47.google.com with SMTP id w17so33539874wrv.10 for <39799@debbugs.gnu.org>; Tue, 21 Sep 2021 10:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :mime-version; bh=YB3VCNyFQSor8ArLl2kXJ0G4b33nCVILxlzxntdJWFA=; b=UQTLyDbh/vUTszmAXcyVo+PIXvLtUmZ24LpfOLHCbsaWxhp1KGweT/93/I2scd8CuL Ztm7h16MrasP0wrtkuP6yMMqUK7Vn7fiWVHvP7WiBOo2ucANFhZ/794mMJRcxgqYq+bW iskuCEWVJQ+ceD1TbJGRToIYgXD2wvz45Eavt0leubgSVbDFPMvqAnLtRZ1zml23RMkk Z1QDGRdqSsFSPhYyRbRSTtmIYhfEIRubTD6HVHKBSYfPqqd7Jlu9e2GoH6XNYfAsuU2g ju1I4TnZSPbRqvGszHMIvETbksQvV0XM/fd0aQvAx55dQPXq6WecDGrMth4FX/l3uUMT Fz1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version; bh=YB3VCNyFQSor8ArLl2kXJ0G4b33nCVILxlzxntdJWFA=; b=7NnNJwj+CI/OPlTR+iyKZUk0Dwet3hpx/E8ZKVFLHuv9mJkJ3BlBFW/kXhwKkqtk9K ouZbb89ICQRcN3EgNhciNld6MzGMwDYLRy2s2aR1atBk7ebCJjZ3q+M8wewAMVHCkrRK J5k1FEeV1k5U4x8zo8CvmLqDqjXqbgdERZ0pxs+pNuXvfJ1An6NtWYw+xzJGbiAjv0X4 e4ueogYgn8U8jA7eh1uGwF8KdQ9+4JDhkdALPehVDlqFfOjaHQZ8nUdXnil9R6Mkgodb 6er6WToixiBat5UQTG47izLVXl5kMYzK1ec63XPk0WGf/+ZCb4Uuj/tH8ZGmapzgoUlY niPw== X-Gm-Message-State: AOAM531IQZiPLxDv6GqR2X0b3/1rO4ucm5EY8X2IROj4iquGOV50kdAA Avz5vipW7BDlWH34E2vikxU= X-Google-Smtp-Source: ABdhPJy52MGeuXCxR1ESmsZs0x1A5LlwggqYv8U/StT3VLux25G6E4a+HaSgLFipGVx+/2iMheUO4g== X-Received: by 2002:a1c:7fd0:: with SMTP id a199mr6230754wmd.20.1632246186513; Tue, 21 Sep 2021 10:43:06 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id z13sm23325663wrs.90.2021.09.21.10.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 10:43:06 -0700 (PDT) In-Reply-To: <8335pyyxkx.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 21 Sep 2021 14:31:10 +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" Xref: news.gmane.io gmane.emacs.bugs:215007 Archived-At: >>>>> On Tue, 21 Sep 2021 14:31:10 +0300, Eli Zaretskii said: >> Date: Tue, 21 Sep 2021 13:54:02 +0300 >> From: Eli Zaretskii >> Cc: rgm@gnu.org, 39799@debbugs.gnu.org, mfabian@redhat.com >> >> > I think this means you'd have to add the Variation Selectors to the >> > emoji script >> >> Yes, of course. Eli> Btw, we could recognize VS-16 explicitly in font_range, and avoid Eli> putting them into the 'emoji' script. But that would be too kludgey, Eli> I guess. FE0F is already in script-representative-chars for emoji :-) Eli, is this the kind of thing you were thinking of? Seems to work so far (with a small addition to blocks.awk). We'll need to find a better name for the new arg than 'trigger' though. diff --git a/src/composite.c b/src/composite.c index e97f8e2b4c..85485e9358 100644 --- a/src/composite.c +++ b/src/composite.c @@ -882,14 +882,15 @@ fill_gstring_body (Lisp_Object gstring) /* Try to compose the characters at CHARPOS according to composition rule RULE ([PATTERN PREV-CHARS FUNC]). LIMIT limits the characters to compose. STRING, if not nil, is a target string. WIN is a - window where the characters are being displayed. If characters are + window where the characters are being displayed. TRIGGER is the + character that triggered the composition check. If characters are successfully composed, return the composition as a glyph-string object. Otherwise return nil. */ static Lisp_Object autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t limit, struct window *win, struct face *face, - Lisp_Object string, Lisp_Object direction) + Lisp_Object string, Lisp_Object direction, int trigger) { ptrdiff_t count = SPECPDL_INDEX (); Lisp_Object pos = make_fixnum (charpos); @@ -920,7 +921,7 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, struct frame *f = XFRAME (font_object); if (FRAME_WINDOW_P (f)) { - font_object = font_range (charpos, bytepos, &to, win, face, string); + font_object = font_range (charpos, bytepos, &to, win, face, string, trigger); if (! FONT_OBJECT_P (font_object) || (! NILP (re) && to < limit @@ -1269,7 +1270,7 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, if (XFIXNAT (AREF (elt, 1)) != cmp_it->lookback) goto no_composition; lgstring = autocmp_chars (elt, charpos, bytepos, endpos, - w, face, string, direction); + w, face, string, direction, cmp_it->ch); if (composition_gstring_p (lgstring)) break; lgstring = Qnil; @@ -1307,7 +1308,7 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, else direction = QR2L; lgstring = autocmp_chars (elt, cpos, bpos, charpos + 1, w, face, - string, direction); + string, direction, cmp_it->ch); if (! composition_gstring_p (lgstring) || cpos + LGSTRING_CHAR_LEN (lgstring) - 1 != charpos) /* Composition failed or didn't cover the current @@ -1676,7 +1677,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, ptrdiff_t backlim, for (check = cur; check_pos < check.pos; ) BACKWARD_CHAR (check, stop); *gstring = autocmp_chars (elt, check.pos, check.pos_byte, - tail, w, NULL, string, Qnil); + tail, w, NULL, string, Qnil, c); need_adjustment = 1; if (NILP (*gstring)) { diff --git a/src/font.c b/src/font.c index e043ef8d01..74a1214b38 100644 --- a/src/font.c +++ b/src/font.c @@ -3866,6 +3866,9 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w, If STRING is not nil, it is the string to check instead of the current buffer. In that case, FACE must be not NULL. + TRIGGER is the character that actually caused the composition + process to start, it may be different from the character at POS. + The return value is the font-object for the character at POS. *LIMIT is set to the position where that font can't be used. @@ -3873,15 +3876,16 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w, Lisp_Object font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit, - struct window *w, struct face *face, Lisp_Object string) + struct window *w, struct face *face, Lisp_Object string, + int trigger) { ptrdiff_t ignore; int c; Lisp_Object font_object = Qnil; + struct frame *f = XFRAME (w->frame); if (!face) { - struct frame *f = XFRAME (w->frame); int face_id; if (NILP (string)) @@ -3912,6 +3916,23 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit, continue; if (NILP (font_object)) { + if (EQ (CHAR_TABLE_REF (Vchar_script_table, trigger), + Qemoji)) + { + Lisp_Object val = assq_no_quit (Qemoji, Vscript_representative_chars); + if (CONSP (val)) + { + int face_id; + val = XCDR (val); + if (CONSP (val)) + val = XCAR (val); + else if (VECTORP (val)) + val = AREF (val, 0); + c = XFIXNAT (val); + face_id = FACE_FOR_CHAR (f, face, c, pos - 1, string); + face = FACE_FROM_ID (f, face_id); + } + } font_object = font_for_char (face, c, pos - 1, string); if (NILP (font_object)) return Qnil; @@ -5423,6 +5444,7 @@ syms_of_font (void) DEFSYM (Qiso8859_1, "iso8859-1"); DEFSYM (Qiso10646_1, "iso10646-1"); DEFSYM (Qunicode_bmp, "unicode-bmp"); + DEFSYM (Qemoji, "emoji"); /* Symbols representing keys of font extra info. */ DEFSYM (QCotf, ":otf"); diff --git a/src/font.h b/src/font.h index d3e1530642..1da72cca07 100644 --- a/src/font.h +++ b/src/font.h @@ -885,7 +885,7 @@ valid_font_driver (struct font_driver const *d) extern Lisp_Object font_update_drivers (struct frame *f, Lisp_Object list); extern Lisp_Object font_range (ptrdiff_t, ptrdiff_t, ptrdiff_t *, struct window *, struct face *, - Lisp_Object); + Lisp_Object, int); extern void font_fill_lglyph_metrics (Lisp_Object, struct font *, unsigned int); extern Lisp_Object font_put_extra (Lisp_Object font, Lisp_Object prop,