Subject: Re: bug#73752: 29.4; Ligatures are randomly rendered with extra spaces

From: Tim Ruffing <[email-masked]>
Date: Wed, 06 Nov 2024 13:02:34 +0100

> > If so, I think the code
> > to look at is the end_hb_font method and what it does to the
> hb_font
> > object.  The end_hb_font method is called each time the shaper is
> > called, so whatever it does to the hb_font object is inherited by
> the
> > next call to the shaper.
> 
> This sounds like a plausible cause, but as far as I can tell,
> end_hb_font doesn't do anything to hb_font. The end function is
> simply
> necessary to call cairo_ft_scaled_font_unlock_face().
> 

Okay, I still have no idea what the root cause is, but this hack also
makes the bug disappear for me:

diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index 3700154e44a..4f62873f8c1 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -708,7 +708,6 @@ ftcrhbfont_end_hb_font (struct font *font,
hb_font_t *hb_font)
   struct font_info *ftcrfont_info = (struct font_info *) font;
   cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font;
 
-  cairo_ft_scaled_font_unlock_face (scaled_font);
   ftcrfont_info->ft_size = NULL;
 }

This is consistent with your theory about end_hb_font.