「setfont」

  LINUX MANUAL PAGES

setfont,加载EGA/VGA控制台屏幕字体。

命令行语法格式

setfont [-O font+umap.orig]

[
-o font.orig]

[
-om cmap.orig]

[
-ou umap.orig]

[-N] [font.new …]

[
-m cmap]

[-u umap]

[
-C console]

[
-hH]

[
-v]

[
-V]

命令简述(DESCRIPTION)

setfont从文件font.new读取字体并将其加载到EGA/VGA字符生成器中,并可选择输出以前的字体。它还可以加载各种映射表,并输出以前的版本。

如果没有给出任何参数(或者只有一个指定了数值的-N选项),则加载默认的(8xN)字体(见下文)。
一个可能会提供几个小字体,全部的会包含一个Unicode表,而setfont将会结合它们,并加载联合后的。

下面是一些典型的使用方法:

setfont
加载默认字体。

setfont drdos8x16
加载给定字体。这里是448-glyph drdos字体。

setfont cybercafe -u cybercafe
加载一个没有Unicode映射的字体,并明确指定一个。

setfont LatArCyrHeb-19 -m 8859-2
加载一个给定的字体(这里是结合了几个字符集的512-glyph字体),并指出一个的本地字符集是ISO 8859-2。

注意:如果字体超过256个字形,则只可以同时使用16种颜色中的8种。它可以使控制台感觉更糟(强度损失,甚至一些颜色)。

字体格式(FONT FORMATS)

标准的Linux字体格式是PSF字体。它具有描述字体属性(如字符大小)的头部,后跟「字形位图(glyph bitmap)」,后跟一个可选的Unicode映射表,给出每个字形的Unicode值。识别了其他几种(过时)字体的格式。如果输入文件具有代码页格式(可能是后缀.cp),其中包含三个字体大小,例如。 8×8,8×14和8×16,则必须使用选项-8或-14或-16之一来选择一个。原始字体文件是大小256 * N字节的二进制文件,包含256个字符,每个扫描行一个字节和每个字符N个字节(0 <N <= 32)的位图。大多数字体的宽度为8位,但是使用帧缓冲设备(fb)可以使用其他宽度。

If the input file has code page for‐
mat (probably with suffix .cp), containing three fonts with sizes e.g. 8×8, 8×14 and 8×16, then one of the
options -8 or -14 or -16 must be used to select one. Raw font files are binary files of size 256*N bytes,
containing bit images for each of 256 characters, one byte per scan line, and N bytes per character (0 < N <=
32). Most fonts have a width of 8 bits, but with the framebuffer device (fb) other widths can be used.

FONT HEIGHT

The program setfont has no built-in knowledge of VGA video modes, but just asks the kernel to load the char‐
acter ROM of the video card with certain bitmaps. However, since Linux 1.3.1 the kernel knows enough about
EGA/VGA video modes to select a different line distance. The default character height will be the number N
inferred from the font or specified by option. However, the user can specify a different character height H
using the -h option.

CONSOLE MAPS

Several mappings are involved in the path from user program output to console display. If the console is in
utf8 mode (see unicode_start(1)) then the kernel expects that user program output is coded as UTF-8 (see
utf-8(7)), and converts that to Unicode (ucs2). Otherwise, a translation table is used from the 8-bit pro‐
gram output to 16-bit Unicode values. Such a translation table is called a Unicode console map. There are
four of them: three built into the kernel, the fourth settable using the -m option of setfont. An escape
sequence chooses between these four tables; after loading a cmap, setfont will output the escape sequence Esc
( K that makes it the active translation.

Suitable arguments for the -m option are for example 8859-1, 8859-2, …, 8859-15, cp437, …, cp1250.

Given the Unicode value of the symbol to be displayed, the kernel finds the right glyph in the font using the
Unicode mapping info of the font and displays it.

Old fonts do not have Unicode mapping info, and in order to handle them there are direct-to-font maps (also
loaded using -m) that give a correspondence between user bytes and font positions. The most common corre‐
spondence is the one given in the file trivial (where user byte values are used directly as font positions).
Other correspondences are sometimes preferable since the PC video hardware expects line drawing characters in
certain font positions.

Giving a -m none argument inhibits the loading and activation of a mapping table. The previous console map
can be saved to a file using the -om file option. These options of setfont render mapscrn(8) obsolete. (How‐
ever, it may be useful to read that man page.)

UNICODE FONT MAPS

The correspondence between the glyphs in the font and Unicode values is described by a Unicode mapping table.
Many fonts have a Unicode mapping table included in the font file, and an explicit table can be indicated
using the -u option. The program setfont will load such a Unicode mapping table, unless a -u none argument is
given. The previous Unicode mapping table will be saved as part of the saved font file when the -O option is
used. It can be saved to a separate file using the -ou file option. These options of setfont render load‐
unimap(8) obsolete.

The Unicode mapping table should assign some glyph to the `missing character’ value U+fffd, otherwise missing
characters are not translated, giving a usually very confusing result.

Usually no mapping table is needed, and a Unicode mapping table is already contained in the font (sometimes
this is indicated by the .psfu extension), so that most users need not worry about the precise meaning and
functioning of these mapping tables.

One may add a Unicode mapping table to a psf font using psfaddtable(1).

命令支持的选项及含义

-h H
Override font height.

-m file
Load console map or Unicode console map from file.

-o file
Save previous font in file.

-O file
Save previous font and Unicode map in file.

-om file
Store console map in file.

-ou file
Save previous Unicode map in file.

-u file
Load Unicode table describing the font from file.

-C console
Set the font for the indicated console. (May require root permissions.)

-v
Be verbose.

-V
Print version and exit.

注意事项

PC video hardware allows one to use the “intensity” bit either to indicate brightness, or to address 512
(instead of 256) glyphs in the font. So, if the font has more than 256 glyphs, the console will be reduced to
8 (instead of 16) colors.

相关文件

/usr/share/consolefonts
字体的默认目录。

/usr/share/unimaps
Unicode映射的默认目录。

/usr/share/consoletrans
屏幕映射的默认目录。

默认的字体是一个default文件(如果-N选项给定数字N,则为default8xN),也许带有合适的扩展名(如.psf)。

相关文档

psfaddtable(1), unicode_start(1), loadunimap(8), utf-8(7), mapscrn(8)

有关控制台字体的内容,参考:Console Fonts

参考文献