Custom font with dmenu

The standard version of dmenu doesn't include support for xft fonts. To use fonts like Inconsolata you'll need to build a patched version of dmenu.

  1. Download the source code and the patch.
  2. Open up a terminal, cd to the directory containing both the source code and the patch.
  3. Run the following commands to apply the patch:

    tar zxvf dmenu-4.5.tar.gz
    cd dmenu-4.5
    mv ../dmenu-4.5-xft.diff .
    patch -p1 < dmenu-4.5-xft.diff
    
  4. To build the modified version of dmenu, you'll need to have the following packages installed: libxft-dev libxft2 libxinerama-dev

  5. UPDATE on UBUNTU 14.04 the build fails with

    fatal error: ft2build.h: No such file or directory

    to fix this edit the config.mk File and change

    XFTINC = -I/usr/local/include/freetype2

    to

    XFTINC = -I/usr/include/freetype2

  6. Run the following commands to build and install the modified version of dmenu:

    make
    sudo make install
    

You must to use the X Logical Font Description (XLFD) full name for the font provided by xfontsel. For example, you can use something like this : -bitstream-*-*-*-*-*-12-*-*-*-*-*-*-*:

dmenu_run -b -fn -bitstream-*-*-*-*-*-12-*-*-*-*-*-*-*

xfontsell tool allows you to preview the different settings.

If you want to use a syntax like:

dmenu_run -b -fn <family>-<size>:<name>=<value>

which is closer to what you asked, you can use Xft support patch. See here the instructions about how to use a patch for dmenu.


Since dmenu 4.6 (released in Nov 2015), XFT font rendering is enabled by default (4.6 Release Notes) and this just works:

dmenu_run -fn 'Inconsolata 12'

Tags:

Fonts