Indic ligatures in terminal emulators

Posted on November 11, 2022 by natto
Tags: ,


I have been using the simple terminal, or st, by for almost two years now, and it has been great. Unfortunately it has fixed width unicode support and hence hindi ligatures cannot be rendered properly. There is a ligatures patch available but all it does it combine fixed width LTR ligatures. So I spent the last 8 hours or so looking for a way to implement it. Here is what I learnt.

The problem

The only problem with rendering indic fonts on terminal is that they cannot be monospace and has have variable widths, which are much harder to implement than one realises. The ligature combining stuff can be done using harfbuzz, pango, fribidi / ubidi(ICU) or their combination without any problem. The problem is the varying widths and how the terminal is supposed to be a grid of rows and $COLUMNS. Also I need perfect input for indic languages with fcitx4 (I use m17n methods just for the context). These problems have haunted me for months now, and I finally decided to confront them.

The candidates

  • mlterm promises to solve these issues but its primary focus is arabic languages from what I understand, and Indic languages are not rendered correctly.
  • konsole by KDE solves the rendering stuff beautifully, however it has problem with inputting halant and the following character. Another problem it has is incorrect cursor rendering position when inputting. However it is good enough for displaying Indic text in terminal.
  • Emacs eshell is perfect when it comes to rendering, inputting and navigating the text with not just indic languages but many other languages as well, however it requires GNU Emacs. And as obvious as it is, GUI stuff usually does render ligatures properly, so nothing surprising there.

The compromise

I wil use Emacs for any Indic language related stuff and st for everything else, but I guess that is fine since English is the lingua franca when it comes to computers.