GNU bug report logs - #69384
30.0.50; :align-to and bidi-paragraph-direction interaction

Previous Next

Package: emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Sun, 25 Feb 2024 16:24:02 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#69384: closed (30.0.50; :align-to and bidi-paragraph-direction
 interaction)
Date: Tue, 27 Feb 2024 07:48:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Tue, 27 Feb 2024 09:44:36 +0200
with message-id <867ciquza3.fsf <at> gnu.org>
and subject line Re: bug#69384: 30.0.50; :align-to and bidi-paragraph-direction interaction
has caused the debbugs.gnu.org bug report #69384,
regarding 30.0.50; :align-to and bidi-paragraph-direction interaction
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
69384: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69384
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stephen Berman <stephen.berman <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; :align-to and bidi-paragraph-direction interaction
Date: Sun, 25 Feb 2024 17:22:45 +0100
[Message part 3 (text/plain, inline)]
In a buffer that contains bidirectional text, setting
bidi-paragraph-direction to 'left-to-right aligns the RTL text with the
left margin like the LTR text; see the first sexp below and the top
buffer in the attached screenshot.

Another alternative to get this alignment is to leave
bidi-paragraph-direction at its default value of nil and use a space
display specification with a suitable value for the :align-to property,
but this requires a calculation that seems to depend at least on the
font used and the values of `window-width' and `string-width' for the
string used (or the corresponding pixel-width values); see the second
sexp below and the middle buffer in the attached screenshot.

It's also possible to avoid this calculation and use an :align-to value
of 0 in combination with setting bidi-paragraph-direction to
'left-to-right; see the third sexp below and the bottom buffer in the
attached screenshot.  However, as the screenshot shows, this last
alternative breaks Arabic text shaping, at least for the fonts I tried
(Noto Naskh Arabic, DejaVu Sans and Amiri).  If this is not an Emacs bug
but a limitation of the current display engine or a HarfBuzz bug,
perhaps it should be noted in etc/PROBLEMS.

(let* ((a "السّلام عليكم")
       (b "Hello")
       (buf (get-buffer-create "Test1")))
  (with-current-buffer buf
    (erase-buffer)
    (setq bidi-paragraph-direction 'left-to-right)
    (insert a "\n\n" b)
    (switch-to-buffer buf)))

(let* ((a "السّلام عليكم")
       (wa (+ (- (window-width) (string-width a)) 0.75))
       (b "Hello")
       (buf (get-buffer-create "Test2")))
  (with-current-buffer buf
    (erase-buffer)
    (insert (propertize " " 'display `(space :align-to ,wa)) a "\n\n" b)
    (switch-to-buffer buf)))

(let* ((a "السّلام عليكم")
       (b "Hello")
       (buf (get-buffer-create "Test3")))
  (with-current-buffer buf
    (erase-buffer)
    (setq bidi-paragraph-direction 'left-to-right)
    (insert (propertize " " 'display `(space :align-to 0)) a "\n\n" b)
    (switch-to-buffer buf)))

[Screenshot_2024-02-25_15-28-01.png (image/png, attachment)]
[Message part 5 (text/plain, inline)]
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.18.0) of 2024-02-20 built on strobelfs2
Repository revision: d9afa1f30fdf9d00b447fea0a8343397333e172f
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101009
System Description: Linux From Scratch r12.0-112

Configured using:
 'configure -C --with-xwidgets 'CFLAGS=-Og -g3'
 PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER
PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB
[Message part 6 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 69384-done <at> debbugs.gnu.org
Subject: Re: bug#69384: 30.0.50; :align-to and bidi-paragraph-direction
 interaction
Date: Tue, 27 Feb 2024 09:44:36 +0200
> From: Stephen Berman <stephen.berman <at> gmx.net>
> Cc: 69384 <at> debbugs.gnu.org
> Date: Mon, 26 Feb 2024 22:46:50 +0100
> 
> On Mon, 26 Feb 2024 19:28:09 +0200 Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
> >> Cc: 69384 <at> debbugs.gnu.org
> >> Date: Sun, 25 Feb 2024 19:35:22 +0200
> >> From: Eli Zaretskii <eliz <at> gnu.org>
> >>
> >> > Sorry for not being clearer in my report: the bug is the broken shaping
> >> > with the combination of setting bidi-paragraph-direction and using
> >> > :align-to
> >>
> >> OK, I will look into that when I have time.
> >
> > It's a relatively recent regression on the master branch, caused by
> > yours truly.  I hope I've fixed it now.
> 
> I updated and rebuilt, and confirm that with the code I posted that
> resulted in broken Arabic shaping, the shaping is now correct.  Thanks!

Thanks, I'm therefore closing this bug.


This bug report was last modified 1 year and 88 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.