Italics in Emacs on Text Terminal (rxvt-unicode) – Font Configuration

emacsfontsrxvt

I am using Emacs running in an urxvt, and I cannot get italics to work in Emacs although the terminal supports it.

Here’s my current setup:

  • I haven’t set $TERM, so it is the default rxvt-unicode-256color.
  • My ~/.Xdefaults defines URxvt.font: xft:Inconsolata:size=15 as the terminal font.
  • Running echo "\e[3mitalics\e[m" in the shell indeed yields italics, so italics in the terminal do work, basically.

When customizing the “Italic” face, it doesn’t make any difference whether I select italic, oblique, normal, or roman as the value for the Slant attribute, nor does it if I don’t set the Slant attribute at all. I also tried this in combination with explicitly defining URxvt.italicFont in my ~/.Xdefaults, but to no avail.

Bold works fine, italic doesn’t work at all. Any ideas?

Best Answer

In short: you cannot with the current version of Emacs (checked with 23.2), but see below for a possible workaround.

Longer story: support for italics is encoded in the terminfo database as the sitm (enter italics) and ritm (exit italics) capabilities (also called ZH and ZR for termcap compatibility); you can check that your terminal supports them via:

infocmp $TERM | egrep '(sitm|ritm)'

If those are not present, then your rxvt-unicode-256color terminal description does not provide information to the ncurses library about the italics capabilities of the terminal and you might want to add them, otherwise no TTY application can use italics.

However, function turn_on_face (in the Emacs sources, file src/term.c at line 1919--2012), which manages the terminal display, does not provide support for italics: it checks for bold/dim/blinking/underline attributes of a face. Actually, there is no "italics" attribute encoded in struct face.

Indeed, my Emacs (version 23.1 on Ubuntu 11.04 natty) shows italicized faces (which display correctly in X11) as underlined in a TTY. (Which means that, if you do not care about underlining, you can just change the terminfo description of your terminal to use the enter/exit italics escape sequences instead of the enter/exit underline ones and get italics.)

Related Question