> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/di-11-zhang-xwindow-xi-tong/di-11.3-jie-xi-tong-zi-ti.md).

# 11.3 系统字体

FreeBSD 默认字体对中文显示效果欠佳。本节介绍图形界面引入 Windows TrueType 字体的方法。

> **警告**
>
> Windows 字体的最终用户许可协议（EULA）仅授权在正版 Windows 系统内使用这些字体，将其复制到其他操作系统安装属于违反许可协议的行为。此外，部分字体（如微软雅黑）的著作权由第三方字体厂商（如方正公司）保留，未经授权的商业使用可能构成侵权。建议优先选用开源可商用的替代字体，如思源黑体（Source Han Sans）、霞鹜文楷等。

## GUI 图形界面字体

首先提取 Windows **C:\Windows\Fonts** 目录下的所有 `.ttf` 和 `.ttc` 字体文件。macOS 字体文件格式虽同为 `.ttf`，仍需特殊处理。

为管理新字体，创建一个目录存放 Windows 字体：

```sh
# mkdir -p /usr/local/share/fonts/WindowsFonts
```

将字体文件复制到 **WindowsFonts** 目录。

字体目录结构：

```sh
/usr/local/share/
└── fonts/
    └── WindowsFonts/ # Windows 字体存放目录
```

设置 Windows 字体目录及其内容的权限为 755：

```sh
# chmod -R 755 /usr/local/share/fonts/WindowsFonts
```

还需刷新字体缓存：

```sh
# fc-cache
```

## 附录：安装 Windows 11 字体（自制包）

该包亦可运行于 Debian 与低版本 Ubuntu 的 FreeBSD 兼容层下。安装方法：

```sh
# apt install git                          # 安装 Git
# git clone https://github.com/ykla/ttf-mswin11-zh-deb   # 克隆字体包仓库
# cd ttf-mswin11-zh-deb                    # 进入字体包目录
# dpkg -i ttf-ms-win11-*.deb               # 安装 Windows 11 中文字体包
```

## 课后习题

1. 从 Windows 系统提取字体文件并在 FreeBSD 中配置，测试多个 GTK 和 Qt 应用程序的字体显示效果。
2. 下载 bdf 或 hex 格式的字体文件，使用 vtfontcvt 工具将其转换为 fnt 格式，在控制台中测试显示效果。
3. 尝试使用第三方工具（如 vt-fnt）生成中文字体的 fnt 文件，验证其在 FreeBSD 控制台中的显示效果。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/di-11-zhang-xwindow-xi-tong/di-11.3-jie-xi-tong-zi-ti.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
