「Linux コンソール」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(→‎実装: 和訳)
(→‎フォント: フォント#コンソールフォントから翻訳済みの内容をコピー)
72行目: 72行目:
 
== フォント ==
 
== フォント ==
   
  +
{{Note|このセクションでは [[Wikipedia:Linux console|Linux コンソール]]について説明しています。(ユニコードフォントや最新のグラフィックアダプタのサポートなど) より多くの機能が備わっているコンソールについては [[fbterm]] や [[KMSCON]] などのページを見て下さい。}}
{{Note|This section is about the [[Wikipedia:Linux console|Linux console]]. For alternative console solutions offering more features (full Unicode fonts, modern graphics adapters etc.), see [[KMSCON]] or similar projects.}}
 
   
  +
[[Wikipedia:ja:仮想コンソール|仮想コンソール]]はカーネルに含まれているフォントと ASCII 文字セットがデフォルトで使用しますが、どちらも簡単に変えることができます。
By default, the [[Wikipedia:Virtual console|virtual console]] uses the kernel built-in font with a [[Wikipedia:CP437|CP437]] character set,<sup>[https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/vt/Makefile#n4]</sup> but this can be easily changed.
 
   
  +
コンソールフォントは 256 か 512 文字に制限されています。利用できるフォントは {{ic|/usr/share/kbd/consolefonts/}} にあります。
The [[Wikipedia:Linux console|Linux console]] uses UTF-8 encoding by default, but because the standard VGA-compatible framebuffer is used, a console font is limited to either a standard 256, or 512 glyphs. If the font has more than 256 glyphs, the number of colours is reduced from 16 to 8. In order to assign correct symbol to be displayed to the given Unicode value, a special translation map, often called ''unimap'', is needed. Nowadays most of the console fonts have the ''unimap'' built-in; historically, it had to be loaded separately.
 
   
  +
押したキーとコンピュータで使われる文字をつなぐ、キーマップは {{ic|/usr/share/kbd/keymaps/}} のサブディレクトリにあります。
The {{Pkg|kbd}} package provides tools to change virtual console font and font mapping. Available fonts are saved in the {{ic|/usr/share/kbd/consolefonts/}} directory, those ending with ''.psfu'' or ''.psfu.gz'' have a Unicode translation map built-in.
 
   
  +
{{Tip|ラテン・ギリシャ文字で書かれたヨーロッパ系言語の場合、{{ic|eurlatgr}} フォントを使うことができます。幅広いラテン・ギリシャ文字と特殊文字が収録されています [https://lists.altlinux.org/pipermail/kbd/2014-February/000439.html]。}}
Keymaps, the connection between the key pressed and the character used by the computer, are found in the subdirectories of {{ic|/usr/share/kbd/keymaps/}}, see [[/Keyboard configuration]] for details.
 
   
  +
=== プレビューとテスト ===
{{Note|Replacing the font can cause issues with programs that expect a standard VGA-style font, such as those using line drawing graphics.}}
 
   
  +
フォントで利用できる記号・文字は {{ic|showconsolefont}} コマンドでテーブル表示できます:
{{Tip|For European based languages written in Latin/Greek letters you can use {{ic|eurlatgr}} font, it includes a broad range of Latin/Greek letter variations as well as
 
special characters [https://lists.altlinux.org/pipermail/kbd/2014-February/000439.html].}}
 
 
=== プレビューと一時的な変更 ===
 
 
{{Tip|An organized library of images for previewing is available: [https://alexandre.deverteuil.net/pages/consolefonts/ Linux console fonts screenshots].}}
 
   
 
$ showconsolefont
 
$ showconsolefont
   
  +
''setfont'' ユーティリティを使うことで一時的にフォントを変えることができます。フォントの名前 ({{ic|/usr/share/kbd/consolefonts/}} にあります) を指定してください:
shows a table of glyphs or letters of a font.
 
   
  +
$ setfont Lat2-Terminus16
{{ic|setfont}} temporarily change the font if passed a font name (in {{ic|/usr/share/kbd/consolefonts/}}) such as
 
   
  +
任意で、使用する文字セットを {{ic|-m}} オプションで指定できます:
$ setfont lat2-16 -m 8859-2
 
   
  +
$ setfont Lat2-Terminus16 -m 8859-2
Font names are case-sensitive. With no parameter, {{ic|setfont}} returns the console to the default font.
 
   
  +
もし新しく変えたフォントに不満ならば、何も引数を付けないで実行することでデフォルトフォントに戻ります (コンソール画面が全く読めなくなってしまったときでも、このコマンドは動作します。なんとかしてコマンドを入力してください):
So to have a '''small 8x8''' font, with that font installed like seen below, use e.g.:
 
 
$ setfont -h8 /usr/share/kbd/consolefonts/drdos8x8.psfu.gz
 
   
  +
$ setfont
To have a '''bigger''' font, the Terminus font ({{Pkg|terminus-font}}) is available in many sizes, such as {{ic|ter-132n}} which is large.
 
   
  +
{{Note|''setfont'' は現在使われているコンソールだけで機能することを覚えておいて下さい。(アクティブだろうとそうでなかろうと)他のコンソールには影響しません。}}
{{Tip|All font changing commands can be typed in "blind".}}
 
   
  +
=== デフォルトフォントを変更 ===
{{Note|''setfont'' only works on the console currently being used. Any other consoles, active or inactive, remain unaffected.}}
 
   
  +
デフォルトフォントを変えるには、{{ic|/etc/vconsole.conf}} (このファイルは新しく作る必要があるかもしれません) の {{ic|FONT}} と {{ic|FONT_MAP}} で設定します。
=== 永続的な設定 ===
 
   
  +
''Č, ž, đ, š'' or ''Ł, ę, ą, ś'' などの文字を表示するために {{ic|lat2-16.psfu.gz}} フォントを使うとします:
The {{ic|FONT}} variable in {{ic|/etc/vconsole.conf}} is used to set the font at boot, persistently for all consoles. See {{man|5|vconsole.conf}} for details.
 
   
  +
FONT=lat2-16
For displaying characters such as ''Č, ž, đ, š'' or ''Ł, ę, ą, ś'' using the font {{ic|lat2-16.psfu.gz}}:
 
   
  +
これで ISO/IEC 8859 の第2部がサイズ16で使われます。他の値にすればフォントサイズを変えられます (例: {{ic|lat2-08}})。8859 によって定められている地域については、[[wikipedia:ja:ISO/IEC_8859#ISO 8859の部|Wikipedia の表]]を見て下さい。X サーバーを使わずコンソールで作業することが多いならば Terminus フォントが推奨です。例えば ter-216b はラテン2、サイズ16、太字です。ter-216n は通常の太さになります。Terminus フォントは32までのサイズが揃っています。
{{hc|/etc/vconsole.conf|2=
 
...
 
FONT=lat2-16
 
FONT_MAP=8859-2
 
}}
 
   
  +
フォントを変えたら、適切なフォントマップを設定します。lat2-16 の場合は:
It means that second part of ISO/IEC 8859 characters are used with size 16. You can change font size using other values (e.g. {{ic|lat2-08}}). For the regions determined by 8859 specification, look at the [[Wikipedia:ISO/IEC 8859#The parts of ISO/IEC 8859]].
 
  +
FONT_MAP=8859-2
   
  +
初期のユーザースペース、つまりブートプロセスでも特定のフォントを使いたい場合は、{{ic|/etc/mkinitcpio.conf}} で {{ic|keymap}} フックを使って下さい。詳しくは [[Mkinitcpio#HOOKS]] を参照してください。
To use the specified font in early userspace, use the {{ic|consolefont}} hook in {{ic|/etc/mkinitcpio.conf}}. See [[Mkinitcpio#HOOKS]] for more information.
 
   
  +
ブート時にフォントが変わっていない、もしくは一時的にしか変わらなかった場合、グラフィックドライバが初期化されコンソールがフレームバッファに切り替わるときにリセットされている可能性があります。これを避けるには、グラフィックドライバを早くロードするようにしてください。[[Kernel Mode Setting#Early KMS start]] のサンプルを見るか他の方法で {{ic|/etc/vconsole.conf}} が適用される前にフレームバッファをセットアップするようにしてください。
If the fonts appear to not change on boot, or change only temporarily, it is most likely that they got reset when graphics driver was initialized and console was switched to framebuffer. To avoid this, load your graphics driver earlier. See for example [[Kernel mode setting#Early KMS start]], [https://bbs.archlinux.org/viewtopic.php?id=145765] or other ways to setup your framebuffer before {{ic|/etc/vconsole.conf}} is applied.
 
   
 
== HiDPI ==
 
== HiDPI ==

2021年5月11日 (火) 00:54時点における版

関連記事

Wikipedia より:

Linux コンソールは、Linux カーネル に内蔵されているシステムコンソールです。Linux コンソールは、カーネルや他のプロセスがテキスト出力をユーザに送信したり、ユーザからのテキスト入力を受信したりするための方法を提供します。ユーザは通常、コンピュータのキーボードでテキストを入力し、出力されたテキストをコンピュータのモニタで読みます。Linux カーネルは仮想コンソールをサポートしています - コンソールは論理的に分離されていますが、同じ物理キーボードとディスプレイにアクセスします。

この記事では、Linux コンソールの基本とフォント表示の設定方法について説明します。キーボードの設定は、コンソールでのキーボード設定 サブページで説明しています。

実装

コンソールは、ユーザーと直接対話するほとんどのサービスとは異なり、カーネルに実装されています。これは、通常のアプリケーションとしてユーザースペースに実装される、Xterm などの端末エミュレーションソフトウェアとは対照的です。コンソールは常にリリースされた Linux カーネルの一部でしたが、その歴史に変化を遂げてきました。最も顕著なのは、framebuffer の使用と、Unicode のサポートへの移行です。

コンソールには多くの改良が施されていますが、レガシーハードウェアとの完全な下位互換性があるため、グラフィカルターミナルエミュレータと比較すると制限があります。

仮想コンソール

The console is presented to the user as a series of virtual consoles. These give the impression that several independent terminals are running concurrently; each virtual console can be logged in with different users, run its own shell and have its own font settings. The virtual consoles each use a device /dev/ttyX, and you can switch between them by pressing Alt+Fx (where x is equal to the virtual console number, beginning with 1). The device /dev/console is automatically mapped to the active virtual console.

See also chvt(1), openvt(1) and deallocvt(1).

テキストモード

Since Linux originally began as a kernel for PC hardware, the console was developed using standard IBM CGA/EGA/VGA graphics, which all PCs supported at the time. The graphics operated in VGA text mode, which provides a simple 80x25 character display with 16 colours. This legacy mode is similar to the capabilities of dedicated text terminals, such as the DEC VT100 series. It is still possible to boot in text mode if the system hardware supports it, but almost all modern distributions (including Arch Linux) use the framebuffer console instead.

フレームバッファーのコンソール

As Linux was ported to other non-PC architectures, a better solution was required, since other architectures do not use VGA-compatible graphics adapters, and may not support text modes at all. The framebuffer console was implemented to provide a standard console across all platforms, and so presents the same VGA-style interface regardless of the underlying graphics hardware. As such, the Linux console is not a terminal emulator, but a terminal in its own right. It uses the terminal type linux, and is largely compatible with VT100.

キーボードショートカット

Keyboard Shortcut Description
Ctrl+Alt+Del Reboots the system (specified by the symlink /usr/lib/systemd/system/ctrl-alt-del.target)
Alt+F1, F2, F3, ... Switch to n-th virtual console
Alt+ ← Switch to previous virtual console
Alt+ → Switch to next virtual console
Scroll Lock When Scroll Lock is activated, input/output is locked
Ctrl+c Kills current task
Ctrl+d Inserts an EOF
Ctrl+z Pauses current Task

See also console_codes(4).

フォント

ノート: このセクションでは Linux コンソールについて説明しています。(ユニコードフォントや最新のグラフィックアダプタのサポートなど) より多くの機能が備わっているコンソールについては fbtermKMSCON などのページを見て下さい。

仮想コンソールはカーネルに含まれているフォントと ASCII 文字セットがデフォルトで使用しますが、どちらも簡単に変えることができます。

コンソールフォントは 256 か 512 文字に制限されています。利用できるフォントは /usr/share/kbd/consolefonts/ にあります。

押したキーとコンピュータで使われる文字をつなぐ、キーマップは /usr/share/kbd/keymaps/ のサブディレクトリにあります。

ヒント: ラテン・ギリシャ文字で書かれたヨーロッパ系言語の場合、eurlatgr フォントを使うことができます。幅広いラテン・ギリシャ文字と特殊文字が収録されています [1]

プレビューとテスト

フォントで利用できる記号・文字は showconsolefont コマンドでテーブル表示できます:

$ showconsolefont

setfont ユーティリティを使うことで一時的にフォントを変えることができます。フォントの名前 (/usr/share/kbd/consolefonts/ にあります) を指定してください:

$ setfont Lat2-Terminus16

任意で、使用する文字セットを -m オプションで指定できます:

$ setfont Lat2-Terminus16 -m 8859-2

もし新しく変えたフォントに不満ならば、何も引数を付けないで実行することでデフォルトフォントに戻ります (コンソール画面が全く読めなくなってしまったときでも、このコマンドは動作します。なんとかしてコマンドを入力してください):

$ setfont
ノート: setfont は現在使われているコンソールだけで機能することを覚えておいて下さい。(アクティブだろうとそうでなかろうと)他のコンソールには影響しません。

デフォルトフォントを変更

デフォルトフォントを変えるには、/etc/vconsole.conf (このファイルは新しく作る必要があるかもしれません) の FONTFONT_MAP で設定します。

Č, ž, đ, š or Ł, ę, ą, ś などの文字を表示するために lat2-16.psfu.gz フォントを使うとします:

FONT=lat2-16

これで ISO/IEC 8859 の第2部がサイズ16で使われます。他の値にすればフォントサイズを変えられます (例: lat2-08)。8859 によって定められている地域については、Wikipedia の表を見て下さい。X サーバーを使わずコンソールで作業することが多いならば Terminus フォントが推奨です。例えば ter-216b はラテン2、サイズ16、太字です。ter-216n は通常の太さになります。Terminus フォントは32までのサイズが揃っています。

フォントを変えたら、適切なフォントマップを設定します。lat2-16 の場合は:

FONT_MAP=8859-2

初期のユーザースペース、つまりブートプロセスでも特定のフォントを使いたい場合は、/etc/mkinitcpio.confkeymap フックを使って下さい。詳しくは Mkinitcpio#HOOKS を参照してください。

ブート時にフォントが変わっていない、もしくは一時的にしか変わらなかった場合、グラフィックドライバが初期化されコンソールがフレームバッファに切り替わるときにリセットされている可能性があります。これを避けるには、グラフィックドライバを早くロードするようにしてください。Kernel Mode Setting#Early KMS start のサンプルを見るか他の方法で /etc/vconsole.conf が適用される前にフレームバッファをセットアップするようにしてください。

HiDPI

HiDPI#Linux コンソール を参照。

Audible tones

PC スピーカー#Beep を参照。

See also