And*_*iak 14 command-line fonts tty console
我正在运行 Ubuntu 15.04 64 位桌面版(基于 Debian 的 Linux)。
我使用sudo dpkg-reconfigure console-setup命令行将默认控制台字体类型更改为 Terminus。紧接着,控制台字体变为看起来更清晰的字体。
然而,在重新启动后Ctrl+ Alt+F1带我到具有原始大块寻找风格字体的脸,不是我选择的选择一个控制台窗口。
该/etc/default/console-setup文件似乎已更改为我的选择。
# CONFIGURATION FILE FOR SETUPCON
# Consult the console-setup(5) manual page.
ACTIVE_CONSOLES="/dev/tty[1-6]"
CHARMAP="UTF-8"
CODESET="guess"
FONTFACE="Terminus"
FONTSIZE="8x16"
VIDEOMODE=
# The following is an example how to use a braille font
# FONT='lat9w-08.psf.gz brl-8x8.psf'
Run Code Online (Sandbox Code Playgroud)
如何永久更改控制台字体以使用我喜欢的字体?
小智 7
请参阅https://askubuntu.com/questions/630118/和https://askubuntu.com/questions/328463/。
这个问题似乎是由控制台设置期望的字体命名与 中的字体不匹配引起的/usr/share/consolefonts/,因此/etc/console-setup/在您选择要使用的字体(使用dpkg-reconfigure console-setup)时
复制到。
如果您转到控制台并执行strace /lib/udev/console-setup-tty fbcon,您可以看到它正在尝试打开这样的字体:
/etc/console-setup/Lat15-TerminusBold11x22.psf
Run Code Online (Sandbox Code Playgroud)
但是,如果您查看/etc/console-setup/,那里只有少数字体(您选择的字体),它们看起来更像这样:
/etc/console-setup/Lat15-TerminusBold22x11.psf.gz
Run Code Online (Sandbox Code Playgroud)
一个有高 x 宽,另一个有宽 x 高。
该问题可以通过几种方式解决。
(1)/lib/udev/console-setup-tty可以修复 - 这是更持久的上游解决方案。
(2) 您可以手动更改/etc/default/console-setup,反转 FONTSIZE 中的高度和宽度。每次使用dpkg-reconfigure console-setup. 但是当机器重新启动时,该首选项被保留。
(3) 您可以安装 console-setup-tty 期望的字体。这就是我所说的“矫枉过正”选项。我是这样做的:
在 /etc/rc.local 中:
# install console fonts and then set up console
/etc/console-setup/fonts.sh install
/lib/udev/console-setup-tty fbcon
Run Code Online (Sandbox Code Playgroud)
创建一个名为 的脚本/etc/console-setup/fonts.sh:
#!/bin/bash
action=$1
srcdir="/usr/share/consolefonts"
parent="/etc/console-setup"
subdir="fonts"
case "$1" in
install)
# console fonts are not named properly in Ubuntu 15.04, compensate
[[ -d $parent/$subdir ]] || mkdir $parent/$subdir
for x in $( cd $srcdir ; ls -1 ) ; do
# rearrange the two numbers from HHxWW to WWxHH
y=$(echo "$x" | sed -e 's/^\([^-]*\)-\([^0-9]*\)\([0-9]*\)x\([0-9]*\).psf.gz/\1-\2\4x\3.psf.gz/g')
# whether the pattern above matches or not, we'll be uncompressing here
z=${y/.psf.gz/.psf}
[[ ! -f $parent/$subdir/$z ]] && zcat $srcdir/$x > $parent/$subdir/$z
[[ ! -L $parent/$z ]] && ln -sv $subdir/$z $parent/$z
done
;;
uninstall)
rm -rf $parent/$subdir
# only remove broken links (links to the fonts we removed above)
rm $(find -L $parent -type l)
;;
*)
echo "$(basename $0) install|uninstall"
;;
esac
exit 0
Run Code Online (Sandbox Code Playgroud)
对于快速实用的解决方案,我会做#2,在文件中添加一条注释,如果您选择不同的字体,则可能需要重新完成(假设注释也不会被覆盖)。
但是 #3 可以很好地工作,尽量减少大惊小怪或混乱。
小智 6
我最近在我的 Ubuntu 15.04 64 位机器上遇到了这个问题。该setupcon命令将字体设置为我用dpkg-reconfigure console-setup.
我添加setupcon到我的 rc.local 中,但留下了字体仍然错误的空白(因为 rc.local 在设置控制台后执行),所以这对我来说还不够好。
所以,我决定深入研究。我编辑了我的/lib/systemd/system/console-setup.service文件并附ExecStart=/bin/setupcon加到文件的末尾。这将setupcon在设置控制台时调用,在没有时间间隔的情况下在启动时更正字体。