all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#69384: 30.0.50; :align-to and bidi-paragraph-direction interaction
@ 2024-02-25 16:22 Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-02-25 16:47 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-02-25 16:22 UTC (permalink / raw)
  To: 69384

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

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)))


[-- Attachment #2: Screenshot_2024-02-25_15-28-01.png --]
[-- Type: image/png, Size: 31934 bytes --]

[-- Attachment #3: Type: text/plain, Size: 744 bytes --]


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-02-27  7:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-25 16:22 bug#69384: 30.0.50; :align-to and bidi-paragraph-direction interaction Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-25 16:47 ` Eli Zaretskii
2024-02-25 17:17   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-25 17:35     ` Eli Zaretskii
2024-02-25 18:26       ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-25 19:45         ` Eli Zaretskii
2024-02-25 21:18           ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-26 12:41             ` Eli Zaretskii
2024-02-26 14:12               ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-26 17:28       ` Eli Zaretskii
2024-02-26 21:46         ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-27  7:44           ` Eli Zaretskii

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.