0

I'm looking for a way to achieve strict monospace alignment in Emacs, even when font fallback happens.

There are various fallback fonts available for displaying icons in terminals, for example https://github.com/sebastiencs/icons-in-terminal. They work by putting glyphs in private use areas. Regular text is displayed using the main font according to the user's choice, but glyphs from this private use area will get displayed using the fallback font, since the main font does not contain them.

The font fallback works fine in Emacs too, but the fallback glyphs have different widths from the glyphs of the main font and Emacs respects their widths, which breaks the alignment/grid of the main monospace font. Here is a screenshot to illustrate the problem:

font width problem

Each line contains exactly 4 characters. The glyph for the folder icon is wider than the glyphs of the main fixed-width font (Inconsolata LGC). Gnome terminal keeps the grid of glyphs by sacrificing glyph width: the folder icon overlaps with the next character. To compensate, one needs to put a space after the icon. Emacs, on the other hand, respects the glyph width, sacrificing the monospace character grid.

Is there a way to achieve strict monospace alignment in Emacs, similar to how terminals behave?

How can I prevent large characters from breaking alignment? is a very similar question, except that the poster wants wide glyphs to occupy exactly two spaces (or more, but a whole multiple), whereas I would always want them to take up a single space regardless of their width. Also that question doesn't have a satisfying answer but I hope that in the 8 years that has passed since then the situation has improved.

Zoltan
  • 231
  • 1
  • 7
  • 1
    If no-ones answers here, I suggest you to send this question to [help-gnu-emacs](https://lists.gnu.org/mailman/listinfo/help-gnu-emacs). Actually, have you looked up the topic at [emacs-devel](https://lists.gnu.org/archive/html/emacs-devel/) and [bug-gnu-emacs](https://lists.gnu.org/archive/html/bug-gnu-emacs/) ? – Y. E. Jul 11 '23 at 08:16

0 Answers0