all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim Ruffing <dev@real-or-random.org>
To: Eli Zaretskii <eliz@gnu.org>,
	dev@real-or-random.org, visuweshm@gmail.com
Cc: 73752@debbugs.gnu.org, xuan@xlk.me
Subject: bug#73752: 29.4; Ligatures are randomly rendered with extra spaces
Date: Sat, 02 Nov 2024 04:34:17 +0100	[thread overview]
Message-ID: <79a634db4f76e482038539722aab18fbf10a9251.camel@timruffing.de> (raw)
In-Reply-To: <861pzu28bz.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3960 bytes --]

Okay, here's what I think is a breakthrough:

> > There are a few calls to lglyph-set-adjustment in composite.el,
> > which
> > could be responsible for this.  So if the breakpoint inside
> > composition_gstring_adjust_zero_width never breaks in your
> > sessions,
> > either, the next step is to put a watchpoint on the cached
> > composition
> > created by font-shape-gstring and wait for some code to modify the
> > adjustment part.
> 

Neither the critical line in composition_gstring_adjust_zero_width nor
the calls to lglyph-set-adjustment in composite.el are triggered. But
this hack in hbfont_shape means I can't reproduce the bug anymore using
Yixuan's init file:

diff --git a/src/hbfont.c b/src/hbfont.c
index 37ed4132492..6fae513069a 100644
--- a/src/hbfont.c
+++ b/src/hbfont.c
@@ -592,11 +592,12 @@ hbfont_shape (Lisp_Object lgstring, Lisp_Object
direction)
       LGLYPH_SET_ASCENT (lglyph, metrics.ascent);
       LGLYPH_SET_DESCENT (lglyph, metrics.descent);
 
       xoff = lround (pos[i].x_offset * position_unit);
       yoff = - lround (pos[i].y_offset * position_unit);
-      wadjust = lround (pos[i].x_advance * position_unit);
+      /* wadjust = lround (pos[i].x_advance * position_unit); */
+      wadjust = metrics.width;
       if (xoff || yoff || wadjust != metrics.width)
 	LGLYPH_SET_ADJUSTMENT (lglyph, CALLN (Fvector,
 					     make_fixnum (xoff),
 					     make_fixnum (yoff),
 					     make_fixnum (wadjust)));


Without this patch, what I see with his init file matches his
screenshots in the initial bug report (with the same ligatures
affected, as far as I can see), namely a single additional "space" at
the end of the ligature. Let me note again that this is different from
I typically see when I use emacs daily, namely a space after (almost?)
every character which is part of the ligature. We may or may not be
chasing multiple bugs here.

Anyway, I tried adding a printf inside the critical "if" in hbfont.c.
This is what I see when the bug triggers:

xoff: 0, yoff: 0, wadjust: 18, metrics.width: 9, pos[i].x_advance * position_unit: 18.000000
xoff: 0, yoff: 0, wadjust: 18, metrics.width: 9, pos[i].x_advance * position_unit: 18.000000
xoff: 0, yoff: 0, wadjust: 18, metrics.width: 9, pos[i].x_advance * position_unit: 18.000000
xoff: 0, yoff: 0, wadjust: 18, metrics.width: 9, pos[i].x_advance * position_unit: 18.000000
xoff: 0, yoff: 0, wadjust: 18, metrics.width: 9, pos[i].x_advance * position_unit: 18.000000
xoff: 0, yoff: 0, wadjust: 18, metrics.width: 9, pos[i].x_advance * position_unit: 18.000000
xoff: 0, yoff: 0, wadjust: 18, metrics.width: 9, pos[i].x_advance * position_unit: 18.000000

So this is not a rounding error at least. ;)

Much more interesting:
I can reproduce this only when "enough" (or I guess, the right)
ligatures are visible in the buffer. With Yixuan's init file, when I
not only load but also visit this init file -- just for testing the
rendering, because it contains relevant ligatures -- then I can trigger
the bug. But I can't trigger it with a reduced version (that notably
doesn't contain arrow ligatures)!

Eli, perhaps this is precise enough already so that you can reproduce
it? See the attached archive: Use it as init-dir. It contains the init
script (but I removed the automatic repeat). Visit bad.el. Press C=# to
initialize the font randomization, and then keep pressing C-RET until
you hopefully hit the bug. And I can't reproduce the bug with good.el
that has fewer ligatures.

So it seems that harfbuzz gives different results for some composition
depending on the "context", i.e., the other characters (and ligatures?)
that appear in the buffer passed to harfbuzz. Is this a bug in
harfbuzz?

If you still can't reproduce, what's a good way to pretty print the
lgstring passed to hbfont_shape? (I'd prefer changing the code, that's
a bit easier than gdb, at least for me.)


[-- Attachment #2: bug-73752.tar.xz --]
[-- Type: application/x-xz-compressed-tar, Size: 6152 bytes --]

  reply	other threads:[~2024-11-02  3:34 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11 16:18 bug#73752: 29.4; Ligatures are randomly rendered with extra spaces xuan
2024-10-12  8:02 ` Eli Zaretskii
2024-10-12 16:09   ` Yixuan Chen
2024-10-27 10:21     ` Eli Zaretskii
2024-10-27 16:19       ` Visuwesh
2024-10-27 17:19         ` Eli Zaretskii
2024-10-27 17:27           ` Eli Zaretskii
2024-10-27 17:39             ` Yixuan Chen
2024-10-27 17:43               ` Eli Zaretskii
2024-10-27 17:46                 ` Yixuan Chen
2024-10-27 19:14                   ` Eli Zaretskii
2024-10-27 19:36                     ` Yixuan Chen
2024-10-27 19:44                       ` Eli Zaretskii
2024-10-27 19:47                         ` Yixuan Chen
2024-10-27 20:11                           ` Eli Zaretskii
2024-10-27 19:41                     ` Yixuan Chen
2024-10-27 20:07                       ` Eli Zaretskii
2024-10-27 20:32                         ` Yixuan Chen
2024-10-28 14:25                           ` Eli Zaretskii
2024-10-28 14:44                             ` Yixuan Chen
2024-10-28 14:47                               ` Yixuan Chen
2024-10-28 15:05                               ` Eli Zaretskii
2024-10-28 15:20                                 ` Yixuan Chen
2024-10-28 17:19                                   ` Eli Zaretskii
2024-10-28 17:26                                     ` Eli Zaretskii
2024-10-28 17:28                                     ` Yixuan Chen
2024-10-28 18:41                                       ` Eli Zaretskii
2024-10-28  4:26             ` Visuwesh
2024-10-28 14:59               ` Eli Zaretskii
2024-10-28 15:24                 ` Yixuan Chen
2024-10-28 16:18                 ` Visuwesh
2024-10-28 17:13                   ` Eli Zaretskii
2024-10-29 10:59                     ` Visuwesh
2024-10-29 13:04                       ` Eli Zaretskii
2024-10-29 13:54                         ` Visuwesh
2024-10-29 14:00                           ` Visuwesh
2024-10-29 15:38                           ` Eli Zaretskii
2024-10-29 16:46                             ` Visuwesh
2024-10-29 17:45                               ` Eli Zaretskii
2024-10-30  5:43                                 ` Visuwesh
2024-10-29 16:51                             ` Eli Zaretskii
2024-10-27 17:29           ` Yixuan Chen
2024-10-29 23:14 ` Tim Ruffing
2024-10-30 15:12   ` Eli Zaretskii
2024-10-30 15:45     ` Eli Zaretskii
     [not found]     ` <mvmikt9zkcq.fsf@suse.de>
2024-10-30 15:47       ` Eli Zaretskii
2024-10-30 17:34         ` Tim Ruffing
2024-10-30 17:46           ` Eli Zaretskii
2024-10-30 18:00             ` Tim Ruffing
2024-10-30 18:57               ` Eli Zaretskii
2024-10-31  1:39                 ` Tim Ruffing
2024-10-31  2:36                   ` Yixuan Chen
2024-10-31  2:46                     ` Yixuan Chen
2024-10-31  7:44                       ` Eli Zaretskii
2024-10-31  9:42                   ` Eli Zaretskii
2024-11-01 17:05                     ` Eli Zaretskii
2024-11-02  3:34                       ` Tim Ruffing [this message]
2024-11-02  9:52                         ` Eli Zaretskii
2024-11-02 10:39                           ` Visuwesh
2024-11-02 12:07                             ` Eli Zaretskii
2024-11-02 13:29                               ` Visuwesh
2024-11-02 16:47                                 ` Eli Zaretskii
2024-11-02 17:04                                   ` Visuwesh
2024-11-02 17:18                                     ` Eli Zaretskii
2024-11-02 17:31                                       ` Visuwesh
2024-11-02 17:34                                         ` Eli Zaretskii
2024-11-02 17:39                                           ` Visuwesh
2024-11-02 17:44                                             ` Eli Zaretskii
2024-11-02 17:54                                               ` Visuwesh
2024-11-02 18:02                                                 ` Visuwesh
2024-11-02 18:27                                                   ` Eli Zaretskii
2024-11-04  0:11                                                     ` Tim Ruffing
2024-11-04 17:45                                                       ` Eli Zaretskii
2024-11-04 18:02                                                         ` Visuwesh
2024-11-04 23:33                                                         ` Tim Ruffing
2024-11-04 23:47                                                           ` Tim Ruffing
2024-11-06 12:02                                                           ` Tim Ruffing
2024-11-06 13:11                                                             ` Eli Zaretskii
2024-11-07  2:12                                                               ` Tim Ruffing
2024-11-07  7:05                                                                 ` Eli Zaretskii
2024-11-07 13:45                                                                   ` Visuwesh
2024-11-07 14:40                                                                     ` Eli Zaretskii
2024-11-07 15:13                                                                       ` Visuwesh
2024-11-07 15:49                                                                         ` Eli Zaretskii
2024-11-07 16:00                                                                           ` Visuwesh
2024-11-08  8:08                                                                       ` Eli Zaretskii
2024-11-06 14:50                                                         ` Visuwesh
2024-11-02 10:32                       ` Visuwesh
2024-10-31  8:12             ` Visuwesh
2024-10-31  9:43               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=79a634db4f76e482038539722aab18fbf10a9251.camel@timruffing.de \
    --to=dev@real-or-random.org \
    --cc=73752@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=visuweshm@gmail.com \
    --cc=xuan@xlk.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.