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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 02 Nov 2024 18:47:18 +0200

> From: Visuwesh <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Sat, 02 Nov 2024 18:59:03 +0530
> 
> [சனி நவம்பர் 02, 2024] Eli Zaretskii wrote:
> 
> >> But just loading a file that contains
> >> 
> >>     (set-face-attribute 'default nil
> >>                 :family "Cascadia Code"
> >>                 :height 110
> >>                 :weight 'bold)
> >> 
> >>     (load "/tmp/ligature.el")
> >> 
> >>     (ligature-set-ligatures 'prog-mode '("--" "---" "==" "===" "!=" "!==" "=!="
> >>                                          "=:=" "=/=" "<=" ">=" "&&" "&&&" "&=" "++" "+++" "***" ";;" "!!"
> >>                                          "??" "???" "?:" "?." "?=" "<:" ":<" ":>" ">:" "<:<" "<>" "<<<" ">>>"
> >>                                          "<<" ">>" "||" "-|" "_|_" "|-" "||-" "|=" "||=" "##" "###" "####"
> >>                                          "#{" "#[" "]#" "#(" "#?" "#_" "#_(" "#:" "#!" "#=" "^=" "<$>" "<$"
> >>                                          "$>" "<+>" "<+" "+>" "<*>" "<*" "*>" "</" "</>" "/>" "<!--" "<#--"
> >>                                          "-->" "->" "->>" "<<-" "<-" "<=<" "=<<" "<<=" "<==" "<=>" "<==>"
> >>                                          "==>" "=>" "=>>" ">=>" ">>=" ">>-" ">-" "-<" "-<<" ">->" "<-<" "<-|"
> >>                                          "<=|" "|=>" "|->" "<->" "<~~" "<~" "<~>" "~~" "~~>" "~>" "~-" "-~"
> >>                                          "~@" "[||]" "|]" "[|" "|}" "{|" "[<" ">]" "|>" "<|" "||>" "<||"
> >>                                          "|||>" "<|||" "<|>" "..." ".." ".=" "..<" ".?" "::" ":::" ":=" "::="
> >>                                          ":?" ":?>" "//" "///" "/*" "*/" "/=" "//=" "/==" "@_" "__" "???"
> >>                                          "<:<" ";;;"))
> >>     (global-ligature-mode t)
> >> 
> >> was enough to trigger the breakpoint for me.  This is, of course, before
> >> I got a chance to even reproduce the misalignment.
> >> 
> >> Here's what the gdb buffer looks like:
> >> 
> >>     (gdb) source .gdbinit
> >>     SIGINT is used by the debugger.
> >>     Are you sure you want to change it? (y or n) [answered Y; input not from terminal]
> >>     DISPLAY = :0.0
> >>     TERM = dumb
> >>     Breakpoint 1 at 0x20b4b7: file emacs.c, line 432.
> >>     Breakpoint 2 at 0x1cfa8a: file xterm.c, line 27102.
> >>     (gdb) break hbfont.c:598 if xoff == 0 && yoff == 0 && wadjust == metrics.width && LGLYPH_ADJUSTMENT(lglyph) != Qnil
> >>     Breakpoint 3 at 0x3c3ad7: file hbfont.c, line 598.
> >>     (gdb) run -Q
> >>     Starting program: /home/viz/lib/ports/emacs/src/emacs -Q
> >>     [Thread debugging using libthread_db enabled]
> >>     Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> >>     [New Thread 0x7ffff1b8f6c0 (LWP 198125)]
> >>     [New Thread 0x7ffff118f6c0 (LWP 198126)]
> >>     [New Thread 0x7fffebf8f6c0 (LWP 198127)]
> >>     [New Thread 0x7fffeb58f6c0 (LWP 198128)]
> >>     Error in testing condition for breakpoint 3:
> >>     Attempt to take address of value not located in memory.
> >> 
> >>     Thread 1 "emacs" hit Breakpoint 3, hbfont_shape (lgstring=XIL(0x7ffff2a9c745), direction=XIL(0x33c0)) at hbfont.c:598
> >>     598	      if (xoff || yoff || wadjust != metrics.width)
> >
> > Good.  Now please do this:
> >
> >   (gdb) pp lgstring
> >   (gdb) p wadjust
> >   (gdb) p metrics.width
> >   (gdb) bt
> >
> > And post the results here.
> 
>     (gdb) pp lgstring
>     [[#<font-object "-SAJA-Cascadia Code-bold-normal-normal-*-15-*-*-*-m-0-iso10646-1"> 59 59] nil [0 0 59 1935 9 4 14 8 4 nil] [1 1 59 1865 9 2 6 8 4 nil] nil nil nil nil nil nil]
>     (gdb) p wadjust
>     $1 = 9
>     (gdb) p metrics.width
>     $2 = 9

Thanks, but this is a false alarm: the lgstring's glyphs don't have
the [XOFF YOFF WADJUST] component.  So either my breakpoint condition
is somehow wrong, or you mistyped it, or something else.  What does
GDB show if you type

  (gdb) p LGLYPH_ADJUSTMENT(lglyph)
  (gdb) p Qnil