有没有简单的方法来添加字体?

eyo*_*100 5 freebsd xorg fonts fontconfig

在因硬件故障而失去我心爱的 5 年多的 Gentoo 安装后,我去了 FreeBSD。我觉得这是我探索和使用基于源的操作系统的下一个合乎逻辑的步骤。在阅读FreeBSD 的所有相关文档时,在安装 XOrg 服务器时,5.6 - 在 XOrg 中使用字体部分引起了我的注意。意识到我从未添加过以下行:

Section "Files"
   FontPath  "/usr/share/fonts/...."
EndSection
Run Code Online (Sandbox Code Playgroud)

对于我的 Gentoo 安装中的任何字体,我现在明白为什么我的 DE 看起来像废话。作为一名残疾的单手打字员,我更难Files Section手动编辑,我更愿意手动添加字体作为最后的手段。因此,有没有办法将输出添加fc-list : file到文件部分,xorg.conf使用我尚未找到的某人创建的工具,或者这里的读者非常擅长制作的一些花哨的 shell 脚本等?

注意:我nvidia-xconfig用来生成我的xorg.conf文件,所以它与现在推荐的模块化方法相去甚远。如果需要,我可以将 conf.d 方法与生成的配置混合搭配吗?

the*_*fog 1

如果我理解这个问题,并且您在系统上安装了 vim(这也可以使用vi,因为这些只是ex命令)
在终端运行以下命令,将:

  • 读入文件:xorg.conf- 显然将其替换为您要修改的文件。注意:如果脚本出现问题,该文件xorg.conf不会被修改。
  • 进行一些文本操作
  • 命令的输出将放置在文件中:/tmp/temp_xorg.conf

如果在这些操作之后,您对状态感到满意,则/tmp/temp_xorg.conf可以将其复制到真实的、工作的 xorg 配置文件的位置。


运行命令

在 shell 提示符下运行此命令以生成 fontpaths 目录,该目录的格式可以放入 xorg conf 文件中(感谢 @meuh 提供此命令)。

fc-list : file | sed -E 's#(.*)/.*#\tFontPath "\1"#' | sort -u > /tmp/filepaths.txt
Run Code Online (Sandbox Code Playgroud)

然后运行此命令,该命令将获取上述命令的输出并将其插入到“文件”部分

$ vim -e xorg.conf << 'EOF' 
" move cursor to the line with the text: `Section "Files"`
/Section "Files"
" read in the output of `fc-list` at this point
r !fc-list
write /tmp/temp_xorg.conf
EOF
Run Code Online (Sandbox Code Playgroud)

例如,如果xorg.conf看起来像这样:

Section "InputClass"
    Identifier  "trackpoint catchall"
    MatchIsPointer  "true"
    MatchProduct    "TrackPoint|DualPoint Stick"
    MatchDevicePath "/dev/input/event*"
    Option  "Emulate3Buttons"   "true"
    Option  "EmulateWheel"  "true"
    Option  "EmulateWheelButton"    "2"
    Option  "XAxisMapping"  "6 7"
    Option  "YAxisMapping"  "4 5"
EndSection

Section "Files"
    Identifier  "trackpoint catchall"
    MatchIsPointer  "true"
    MatchProduct    "TrackPoint|DualPoint Stick"
    MatchDevicePath "/dev/input/event*"
    Option  "Emulate3Buttons"   "true"
    Option  "EmulateWheel"  "true"
    Option  "EmulateWheelButton"    "2"
    Option  "XAxisMapping"  "6 7"
    Option  "YAxisMapping"  "4 5"
EndSection


Section "InputClass"
    Identifier  "trackpoint catchall"
    MatchIsPointer  "true"
    MatchProduct    "TrackPoint|DualPoint Stick"
    MatchDevicePath "/dev/input/event*"
    Option  "Emulate3Buttons"   "true"
    Option  "EmulateWheel"  "true"
    Option  "EmulateWheelButton"    "2"
    Option  "XAxisMapping"  "6 7"
    Option  "YAxisMapping"  "4 5"
EndSection
Run Code Online (Sandbox Code Playgroud)

运行上述命令后/tmp/temp_xorg.conf应如下所示:

Section "InputClass"
    Identifier  "trackpoint catchall"
    MatchIsPointer  "true"
    MatchProduct    "TrackPoint|DualPoint Stick"
    MatchDevicePath "/dev/input/event*"
    Option  "Emulate3Buttons"   "true"
    Option  "EmulateWheel"  "true"
    Option  "EmulateWheelButton"    "2"
    Option  "XAxisMapping"  "6 7"
    Option  "YAxisMapping"  "4 5"
EndSection

Section "Files"
    FontPath "/home/ubuntu/.fonts"
    FontPath "/usr/share/fonts/opentype/noto"
    FontPath "/usr/share/fonts/opentype/stix"
    FontPath "/usr/share/fonts/opentype/stix-word"
    FontPath "/usr/share/fonts/truetype"
    FontPath "/usr/share/fonts/truetype/abyssinica"
    FontPath "/usr/share/fonts/truetype/ancient-scripts"
    FontPath "/usr/share/fonts/truetype/dejavu"
    FontPath "/usr/share/fonts/truetype/fonts-guru-extra"
    FontPath "/usr/share/fonts/truetype/freefont"
    FontPath "/usr/share/fonts/truetype/kacst"
    FontPath "/usr/share/fonts/truetype/kacst-one"
    FontPath "/usr/share/fonts/truetype/lao"
    FontPath "/usr/share/fonts/truetype/lato"
    FontPath "/usr/share/fonts/truetype/liberation"
    FontPath "/usr/share/fonts/truetype/lohit-punjabi"
    FontPath "/usr/share/fonts/truetype/nanum"
    FontPath "/usr/share/fonts/truetype/openoffice"
    FontPath "/usr/share/fonts/truetype/padauk"
    FontPath "/usr/share/fonts/truetype/sinhala"
    FontPath "/usr/share/fonts/truetype/takao-gothic"
    FontPath "/usr/share/fonts/truetype/tibetan-machine"
    FontPath "/usr/share/fonts/truetype/tlwg"
    FontPath "/usr/share/fonts/truetype/ttf-khmeros-core"
    FontPath "/usr/share/fonts/truetype/ubuntu-font-family"
    FontPath "/usr/share/fonts/type1/gsfonts"
    FontPath "/usr/share/fonts/X11/Type1"
    Identifier  "trackpoint catchall"
    MatchIsPointer  "true"
    MatchProduct    "TrackPoint|DualPoint Stick"
    MatchDevicePath "/dev/input/event*"
    Option  "Emulate3Buttons"   "true"
    Option  "EmulateWheel"  "true"
    Option  "EmulateWheelButton"    "2"
    Option  "XAxisMapping"  "6 7"
    Option  "YAxisMapping"  "4 5"
EndSection


Section "InputClass"
    Identifier  "trackpoint catchall"
    MatchIsPointer  "true"
    MatchProduct    "TrackPoint|DualPoint Stick"
    MatchDevicePath "/dev/input/event*"
    Option  "Emulate3Buttons"   "true"
    Option  "EmulateWheel"  "true"
    Option  "EmulateWheelButton"    "2"
    Option  "XAxisMapping"  "6 7"
    Option  "YAxisMapping"  "4 5"
EndSection
Run Code Online (Sandbox Code Playgroud)