I built and tested a patch against Ubuntu 26.04 (`vte2.91 0.84.0-2`,
affecting both Ptyxis / GTK 4 and GNOME Terminal / GTK 3) that addresses
both issues reported here:

1. **Contiguous Pango + HarfBuzz shaping for RTL Arabic/Persian runs (addresses 
Bug 1 & Egmont's note in comment #2):**
   - Currently VTE shapes Arabic/Persian cell-by-cell via 
`fribidi_shape_arabic` (with `~FRIBIDI_FLAG_SHAPE_ARAB_LIGA`) and draws each 
cell separately. Whenever a fallback font (e.g., proportional UI fonts when a 
Nerd Font or coding font lacks Arabic/Persian glyphs) is narrower than the grid 
cell width, visible gaps appear between connected letters and `لا` ligatures 
break.
   - The attached patch adds `DrawingContext::find_rtl_shaping_run()` and 
`FontInfo::shape_rtl_utf8()` (`PANGO_DIRECTION_RTL`) in both `DrawingGsk` (GTK 
4) and `DrawingCairo` (GTK 3). Contiguous visual RTL Arabic-script word runs 
are shaped as a single Pango/HarfBuzz run (preserving `لا` ligatures, ZWNJ 
`U+200C`, and diacritics with zero inter-letter gaps) and centered within their 
exact grid span, while single-cell `paint_cursor()` redraws continue using 
FriBidi's contextual form.
   - Even with proportional fallback fonts like `Vazirmatn`, words remain 
seamlessly connected; paired with a monospace Persian fallback rule (e.g., 
`Vazir Code Hack` for Nerd Fonts), spacing matches the terminal grid 1:1.

2. **Automatic paragraph direction (`VTE_BIDI_AUTO` / `?2501`):**
   - The patch also enables `VTE_BIDI_AUTO` by default (`src/modes.py`, 
`src/modes.hh`) so pure RTL and mixed RTL-leading lines resolve RTL while LTR 
prompts and English lines stay LTR. (This two-line change can easily be dropped 
or kept separate from the HarfBuzz run-shaping hunks depending on maintainer 
preference.)

Verified on Ubuntu 26.04 (`vte2.91 0.84.0-2`) with all 19 upstream VTE
unit tests passing (`Ok: 19, Fail: 0`) and tested visually in Ptyxis
(`libvte-2.91-gtk4-0`).

- Source repo, fontconfig rule & packaging scripts: 
https://github.com/sorenammd/parsi-vte
- Prebuilt Ubuntu 26.04 `amd64` `.deb` release: 
https://github.com/sorenammd/parsi-vte/releases/tag/v0.84.0-2-persian1

** Patch added: "0001-persian-harfbuzz-shaping-and-bidi-autodetect.patch 
(vte2.91 0.84.0)"
   
https://bugs.launchpad.net/ubuntu/+source/vte2.91/+bug/2002290/+attachment/6022186/+files/0001-persian-harfbuzz-shaping-and-bidi-autodetect.patch

-- 
You received this bug notification because you are a member of Ubuntu
Desktop Bugs, which is subscribed to gnome-terminal in Ubuntu.
https://bugs.launchpad.net/bugs/2002290

Title:
  Poor Arabic rendering in VTE

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/2002290/+subscriptions


-- 
desktop-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/desktop-bugs

Reply via email to