Linux
使用大於 32 像素的 TTY 字型
我有一台 HiDPI 筆記型電腦,32 像素有點小,無法舒適地閱讀。我找不到任何更大的字型,所以我決定創建自己的字型。
這適用於高度小於或等於 32px 的任何字型,但 setfont 會拒絕任何更大的字型:
> file FC-32.psf FC-32.psf: Linux/i386 PC Screen Font v2 data, 256 characters, Unicode directory, 32x16 > file FC-33.psf FC-33.psf: Linux/i386 PC Screen Font v2 data, 256 characters, Unicode directory, 33x16 > # ----------- > setfont ./FC-32.psf > # 32 is fine > setfont ./FC-33.psf Bad character height 33 > # (It also reject reasonable numbers like 48 and 64)
這是我字型的問題嗎?難道我做錯了什麼?它是 Linux 控制台中的硬限制嗎?我找不到任何提及限制的內容,也找不到任何更大字型的範例。
使用的測試文件和腳本
下面給出了我生成字型的腳本。它將一些
.otf
字型轉換.psf.gz
為可配置的高度。數學是反复無常的,可能特定於 FiraCode。我也可以根據要求提供測試文件。
#!/bin/zsh # Based on this: https://unix.stackexchange.com/questions/161890/how-can-i-make-a-psf-font-for-the-console-from-a-otf-one H=32 # <- FONT HEIGHT PTS=12 (( W=H*5/10 )) (( WIDTH = W*10 )) (( DPI=H*60/PTS )) COUNT=256 OUT=FC otf2bdf -r $DPI -p $PTS -c C ./FiraCode-Regular.otf \ | sed -e "s/AVERAGE_WIDTH.*/AVERAGE_WIDTH $WIDTH/" \ > "$OUT.bdf" bdf2psf --fb "$OUT.bdf" \ /usr/share/bdf2psf/standard.equivalents \ /usr/share/bdf2psf/ascii.set+/usr/share/bdf2psf/useful.set \ $COUNT "$OUT.psf" gzip "$OUT.psf" -f
我不確定該限制是否明確記錄在任何面向使用者的文件中,但它已融入核心。的描述
fbcon_set_font
說:/* * User asked to set font; we are guaranteed that * a) width and height are in range 1..32 * b) charcount does not exceed 512 * but lets not assume that, since someone might someday want to use larger * fonts. And charcount of 512 is small for unicode support. * * However, user space gives the font in 32 rows , regardless of * actual font height. So a new API is needed if support for larger fonts * is ever implemented. */
並
fbcon_get_font
以 32 行的步長處理字元:if (font->width <= 8) { j = vc->vc_font.height; for (i = 0; i < font->charcount; i++) { memcpy(data, fontdata, j); memset(data + j, 0, 32 - j); data += 32; fontdata += j; }
(對寬於 8 像素的字型進行類似處理)。