如何在Linux中安装字体,以便xterm使用它?

今天我遇到了一个问题 ,要求提供良好的Linux xterm字体,而且答案就是build议一个名为Terminus的问题。 我一直在寻找一种新的terminal字体,所以我下载了它 (顺便说一句,我正在运行Ubuntu Intrepid)并阅读README:

1.1. Quick installation. The commands: $ ./configure [--prefix=PREFIX] $ make # make install compile and install the Linux console and X11 Window System fonts, and # make fontdir updates fonts.dir for X11 (if you don't know what fonts.dir is, execute the command). 1.2. Legend. The file names are structured as follows: ter-u<SIZE><STYLE>.bdf where <SIZE> is 12, 14, 16, 20, 24, 28 or 32, and <STYLE> is n for normal (all sizes), b for bold (all sizes except 6x12) and v for EGA/VGA bold (8x14 and 8x16 only, makes use of the eight character matrix column). 

所以我跑了:

 $ ./configure $ make $ sudo make install $ sudo make fontdir 

…我重新启动了X11,以确保新字体无处可寻:

 $ xterm -font ter-u14n xterm: unable to open font "ter-u14n", trying "fixed".... 

叹。 回到自述文件。 后来在这个文件中,我看到:

 4. X11 Window System. 4.1. Installation. $ ./configure [--prefix=PREFIX | --x11dir=DIRECTORY] $ make pcf # make install-pcf 

那么,我知道“xterm -font 8×16”的作品,所以我跑了“定位8×16”,看到这个字体似乎居住在/ usr / share / fonts / X11 / misc,所以这看起来像一个很好的–x11dir使用。 所以我跑了:

 $ ./configure --x11dir=/usr/share/fonts/X11/misc $ make pcf $ make install-pcf $ sudo make fontdir 

…我又重新启动了X11,甚至是整个计算机,但是我甚至证实现在有一堆文件,如/usr/share/fonts/X11/misc/ter-u14n.pcf.gz在我的系统上,但仍然:

 $ xterm -font ter-u14n xterm: unable to open font "ter-u14n", trying "fixed".... 

为了使这个字体与xterm一起工作,我必须执行什么神奇的咒语?

Ubuntu有一个包:

 apt-get install xfonts-terminus xfonts-terminus-oblique 

请注意,这是在universe存储库中,因此您可能需要将其添加到/etc/apt/sources.list

在Debian Wheezy中安装xfonts-terminus之后,我需要:

 $ xset fp rehash 

另外,我的~/.Xresources说:

 xterm*utf8: 1 xterm*font: -xos4-terminus-medium-r-normal--20-200-72-72-c-100-iso10646-1 

其中-xos4-terminus-medium-r-normal--20-200-72-72-c-100-iso10646-1取自安装字体的fonts.dir文件。 在我的情况下,它是/usr/share/fonts/X11/misc/fonts.dir

你使用xterm*utf8: 1 ,如果你想要utf-8,selectiso10646-1 。 您可能还需要调用包装脚本uxterm而不是xterm以使utf-8在您的terminal中正常工作。

~/.Xresources所有更改都要求您执行以下操作:

 $ xrdb ~/.Xresources 

让他们在当前的X会话中注册。

xterm*font规则也可以用通配符星号来写:

 xterm*font: -xos4-terminus-medium-r-*--20-*-*-*-*-*-iso10646-* 

我希望这对任何一个遇到类似问题的人都有帮助。

是/ usr / share / fonts / X11 / misc下的encodings.dir,fonts.alias和fonts.dir文件中列出的字体吗?

由于我需要在linux主机上添加字体,所以有一段时间了,但是有一些helper utils,默认情况下应该安装它们,分别是mkfontdir,update-fonts-alias,update-fonts-dir和update-fonts-scale。 他们处理更新metainfo,告诉X服务器有关安装在系统上的字体。 看到他们的手册页。

在基于Debian的系统上(Ubuntu有Debian遗产),当添加字体.deb包时,帮助者通常会自动调用mkfontdirs。 使用make安装字体可能没有设置您的系统预期的方式。