Subject: Re: bug#50951: 28.0.50; Urdu text is not displayed correctly

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Wed, 07 Sep 2022 15:18:21 +0900

On Mon, 05 Sep 2022 22:03:47 +0900,
Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote:
> 
> At your suggestion, I tried hb-view and it renders Noto Nastaliq fine.
> Similarly Libre Office which also uses harfbuzz as far as I understand,
> also renders it fine. Which is why I said that the problem is limited to
> emacs.

Probably the following change will fix the problem:

diff --git a/src/hbfont.c b/src/hbfont.c
index 2721a66120..01db522909 100644
--- a/src/hbfont.c
+++ b/src/hbfont.c
@@ -598,6 +598,8 @@ hbfont_shape (Lisp_Object lgstring, Lisp_Object direction)
 					      make_fixnum (xoff),
 					      make_fixnum (yoff),
 					      make_fixnum (wadjust)));
+      else
+	LGLYPH_SET_ADJUSTMENT (lglyph, Qnil);
     }
 
   return make_fixnum (glyph_len);

The other shapers except uniscribe_shape need to be changed, too.

Alternatively, one could clear garbage entries at the caller side:

diff --git a/src/composite.c b/src/composite.c
index 22422cca09..249d7587f6 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -876,7 +876,8 @@ fill_gstring_body (Lisp_Object gstring)
 	}
       LGLYPH_SET_ADJUSTMENT (g, Qnil);
     }
-  if (i < LGSTRING_GLYPH_LEN (gstring))
+  len = LGSTRING_GLYPH_LEN (gstring);
+  for (; i < len; i++)
     LGSTRING_SET_GLYPH (gstring, i, Qnil);
 }

				     YAMAMOTO Mitsuharu
				[email-masked]