Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

使用字体

Godot 中能够为不同的 UI 节点设置指定的字体。

There are three different places where you can setup font usage. The first is the theme editor. Choose the node you want to set the font for and select the font tab. The second is in the inspector for control nodes under Theme Overrides > Fonts. Lastly, in the inspector settings for themes under Default Font.

如果其他地方都没有指定字体覆盖项,那么就会使用 Open Sans SemiBold 作为默认的项目字体。

备注

从 Godot 4.0 开始,字体的大小不再随字体本身指定,而是在使用字体的节点中定义。可以在检查器的 Theme Overrides > Font Sizes 中找到。

这样修改字体大小的时候就不必为每种字体大小复制字体一份资源了。

There are 2 kinds of font files: dynamic (TTF/OTF/WOFF/WOFF2 formats) and bitmap (BMFont .fnt format or monospaced image). Dynamic fonts are the most commonly used option, as they can be resized and still look crisp at higher sizes. Thanks to their vector-based nature, they can also contain a lot more glyphs while keeping a reasonable file size compared to bitmap fonts. Dynamic fonts also support some advanced features that bitmap fonts cannot support, such as ligatures (several characters transforming into a single different design).