GNU bug report logs - #81216
"Attempt to shape zero-length text" when displaying unsupported combining character

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Pip Cet <pipcet@HIDDEN>; dated Wed, 10 Jun 2026 14:53:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 81216 <at> debbugs.gnu.org:


Received: (at 81216) by debbugs.gnu.org; 10 Jun 2026 15:47:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 10 11:47:00 2026
Received: from localhost ([127.0.0.1]:49745 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wXL8t-00058V-Ii
	for submit <at> debbugs.gnu.org; Wed, 10 Jun 2026 11:47:00 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:37502)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1wXL8q-00058G-C7
 for 81216 <at> debbugs.gnu.org; Wed, 10 Jun 2026 11:46:57 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1wXL8k-0004g8-Q8; Wed, 10 Jun 2026 11:46:50 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=XF2MWd07TMpEGDYVddAcUYIvs6yyPO0qYANXCbg/gVk=; b=KSY0yHsK3LQM
 +m8EzQPjKkPfUz/KSbo6Pb59E7sibvnpY94vTHWo1ZztMHMccXdCSZlQXpvNlMC8yhFZNjW2Aimi/
 /gN/WutY1/BaYf6TT3cRRWmrbgR9XgT/PDWzVkGpr3AARRfMrp1dAbZpa2KRHnbdZZSYlT6SqXo18
 cjBiWbs2Vyqtto+KvQ9kQ1DnB+XCKpzER79e+/7bq3lPJZiS6v83Gu+XONf9vFO/71BvRBbqItZWK
 6oTqjxgfj/gFK4x8EyiizJBiTO9E1WLbu9hj+Puddy7k7ut7cByNoZBb2mJDw3mH+SlmRuk2+CEkE
 AszhHjtpPucWRMViclJoRg==;
Date: Wed, 10 Jun 2026 18:46:47 +0300
Message-Id: <86ldcmpfdk.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Pip Cet <pipcet@HIDDEN>
In-Reply-To: <871peev45q.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#81216: "Attempt to shape zero-length text" when displaying
 unsupported combining character
References: <871peev45q.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81216
Cc: 81216 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 10 Jun 2026 14:51:45 +0000
> From: Pip Cet via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> On my system, which uses GNU Unifont, attempting to display an invalid
> combining keycap sign using
> 
>     emacs -Q --eval '(insert #x20e3)'
> 
> results in a somewhat unusable buffer; any interaction with it triggers
> the error message
> 
>     Attempt to shape zero-length text
> 
> and consequently fails.

I cannot reproduce this, but I don't have Unifont (and don't like that
font at all, so won't be installing it).  Can you tell what are the
font attributes or traits that trigger this, so I could try looking
for a different font with the same effects?

> The problem is that autocmp_chars assumes that if font_range returns a
> font_object, we have found a valid composition.  This corresponds to the
> documentation of font_range:
> 
>    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.
> 
> If font_range fails to encode the first char of the "composition", it
> still returns a non-nil font_object, but also updates *LIMIT to be the
> same as the initial POS, indicating that we have found a font_object to
> display the next 0 chars with.
> 
> This patch illustrates a potential solution, but I'm not sure it does
> the right thing in the emoji case: maybe *LIMIT can be legitimately
> equal to POS in this case?  If so, we can check callers of font_range to
> ensure they handle non-nil zero-length return values.

There are a lot of emoji-related test files in the source tree, see
admin/unidata/emoji-*.txt.  Visiting all of them should let you see if
this change has any adverse effects on emoji display.  If it does, we
could always adjust the condition in composite.c that decides whether
the values returned by font_range are okay.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81216; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Jun 2026 14:52:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 10 10:52:19 2026
Received: from localhost ([127.0.0.1]:49337 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wXKHy-00028P-R8
	for submit <at> debbugs.gnu.org; Wed, 10 Jun 2026 10:52:19 -0400
Received: from lists1p.gnu.org ([2001:470:142::17]:59046)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1wXKHx-00027d-AG
 for submit <at> debbugs.gnu.org; Wed, 10 Jun 2026 10:52:17 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <pipcet@HIDDEN>)
 id 1wXKHg-0006eT-KK
 for bug-gnu-emacs@HIDDEN; Wed, 10 Jun 2026 10:52:01 -0400
Received: from mail-05.mail-europe.com ([85.9.206.169])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <pipcet@HIDDEN>)
 id 1wXKHd-0006ZN-HF
 for bug-gnu-emacs@HIDDEN; Wed, 10 Jun 2026 10:51:59 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1781103109; x=1781362309;
 bh=U0tZmsaMIc3lb0w0W800FdX37vKd5DpqwTGDd4QTmRY=;
 h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date:
 Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector;
 b=jFr94wwIgbP081D6+9n0AEsTg4MYd6ouFjlWSvYvv6c3QakgZSCkmNq+QMXZsDVik
 XQ7g78KlGhIEpuT0DvQ2ehrn0odk5ksnh/9Gm5HG3DSZzlZ8JQUPX/HIgXh28NxziQ
 pW9Hmxzd7P1hvmeVm219El7j8qnTFSUDoB6wjn0Jk+CheiwP2CXrK8nSYsEFgBh8Cw
 CthjnNpN/HLvLYxXfe5sIYSlaz4uGovijCk1kylJ67ZAEtb+APyBz3BO+0OiZesLQ9
 auyg+gHki7ynHE9UnTlL8bjwlj4bN/fGGHw6bIYszO70GJtkhT3JFyrRuLrbI9WTUa
 JU2YUaceF1zzg==
Date: Wed, 10 Jun 2026 14:51:45 +0000
To: bug-gnu-emacs@HIDDEN
From: Pip Cet <pipcet@HIDDEN>
Subject: "Attempt to shape zero-length text" when displaying unsupported
 combining character
Message-ID: <871peev45q.fsf@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: c293eef91dfed81caf9d1b0e554cf04bcb530d5a
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=85.9.206.169; envelope-from=pipcet@HIDDEN;
 helo=mail-05.mail-europe.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.7 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  On my system, which uses GNU Unifont, attempting to display
 an invalid combining keycap sign using emacs -Q --eval '(insert #x20e3)'
 results in a somewhat unusable buffer; any interaction with it triggers the
 error message 
 Content analysis details:   (1.7 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org]
 1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (pipcet[at]protonmail.com)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.7 SPOOFED_FREEMAIL       No description available.
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

On my system, which uses GNU Unifont, attempting to display an invalid
combining keycap sign using

    emacs -Q --eval '(insert #x20e3)'

results in a somewhat unusable buffer; any interaction with it triggers
the error message

    Attempt to shape zero-length text

and consequently fails.

The problem is that autocmp_chars assumes that if font_range returns a
font_object, we have found a valid composition.  This corresponds to the
documentation of font_range:

   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.

If font_range fails to encode the first char of the "composition", it
still returns a non-nil font_object, but also updates *LIMIT to be the
same as the initial POS, indicating that we have found a font_object to
display the next 0 chars with.

This patch illustrates a potential solution, but I'm not sure it does
the right thing in the emoji case: maybe *LIMIT can be legitimately
equal to POS in this case?  If so, we can check callers of font_range to
ensure they handle non-nil zero-length return values.

From 2a6446b6929c3b1ad2e547bede829c0544d4cc13 Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@HIDDEN>
Date: Wed, 10 Jun 2026 14:45:14 +0000
Subject: [PATCH] WIP: Avoid "Attempt to shape zero-length text" error

* src/font.c (font_range): Return Qnil if we fail to encode even a
single character.
---
 src/font.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/font.c b/src/font.c
index ad46fb1904d..aae097c56d2 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3931,6 +3931,7 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdif=
f_t *limit,
   int c;
   Lisp_Object font_object =3D Qnil;
   struct frame *f =3D XFRAME (w->frame);
+  bool success =3D false;
=20
   if (!face)
     {
@@ -3988,8 +3989,10 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdi=
ff_t *limit,
 =09}
       if (font_encode_char (font_object, c) =3D=3D FONT_INVALID_CODE)
 =09*limit =3D pos - 1;
+      else
+=09success =3D true;
     }
-  return font_object;
+  return success ? font_object : Qnil;
 }
 #endif
=20
--=20
2.54.0





Acknowledgement sent to Pip Cet <pipcet@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#81216; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 10 Jun 2026 16:00:03 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.