Subject: Re: bug#57976: 29.0.50; Complex emoji have extra spacing

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Thu, 22 Sep 2022 11:00:15 +0900

On Wed, 21 Sep 2022 22:46:32 +0900,
Protesilaos Stavrou wrote:
> 
> > From: Lars Ingebrigtsen <[email-masked]>
> > Date: Wed, 21 Sep 2022 15:35:02 +0200
> >
> > Protesilaos Stavrou <[email-masked]> writes:
> >
> >> I have no reproducible recipe with harfbuzz 5.2.0 beside Emacs.  I wrote
> >> the M-x emoji-list buffer to a file and visited it with a generic text
> >> editor: the display looks fine.
> >
> > If you take one of the emojis that displayed correctly and one that was
> > wrong and then say
> >
> > (string-pixel-width "😶‍🌫️")
> >
> > on both -- what does that return?  From the display, it kinda looked
> > like Emacs thought that some of the glyphs were really wide.
> 
> I get these:
> 
>     (string-pixel-width "😶‍🌫️")
>     ;; => 136
> 
>     (string-pixel-width "🤣")
>     ;; => 16

Hmm, the fix for Bug#57066 needs to be undone for HarfBuzz 5.2.0.

				     YAMAMOTO Mitsuharu
				[email-masked]

diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index e089f9dea8..a02ff99870 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -679,8 +679,12 @@ ftcrhbfont_begin_hb_font (struct font *font, double *position_unit)
   hb_font_t *hb_font = fthbfont_begin_hb_font (font, position_unit);
   /* HarfBuzz 5 correctly scales bitmap-only fonts without position
      unit adjustment.
-     (https://github.com/harfbuzz/harfbuzz/issues/489) */
-  if (!hb_version_atleast (5, 0, 0)
+     (https://github.com/harfbuzz/harfbuzz/issues/489)
+
+     Update: HarfBuzz 5.2.0 no longer does this for an hb_font_t font
+     object created from a given FT_Face.
+     (https://github.com/harfbuzz/harfbuzz/issues/3788) */
+  if ((hb_version_atleast (5, 2, 0) || !hb_version_atleast (5, 0, 0))
       && ftcrfont_info->bitmap_position_unit)
     *position_unit = ftcrfont_info->bitmap_position_unit;