Qt for Embedded Linux 字体
Qt XML 通常使用fontconfig
来访问系统字体。如果fontconfig
不可用,例如在空间有限的专用嵌入式系统中,Qt 将退回到使用QBasicFontDatabase
。在这种情况下,Qt 应用程序将在 Qt 的lib/fonts/
目录中查找字体。Qt 将自动检测预渲染字体和 TrueType 字体。
Qt 使用FreeType 2字体引擎生成字体输出。支持的格式取决于本地安装的 FreeType 库版本。使用 QBasicFontDatabase 时,Qt 还支持 Qt Prerendered 字体格式(QPF2),这是一种轻量级的不可缩放字体格式。QPF2 是 Qt for Embedded Linux 4.x 的本地格式。
所有支持的字体都使用 Unicode 字符编码。目前市面上的大多数字体都使用 Unicode 字符编码,但它们通常并不包含所有的 Unicode 字符。一个完整的 16 点 Unicode 字体需要 1 MB 以上的内存。
FreeType 字体格式
FreeType 2库支持以下字体格式:
- TrueType (TTF)
- PostScript Type1 (PFA/PFB)
- 位图分发格式 (BDF)
- CID 键控 Type1
- 紧凑字体格式 (CFF)
- OpenType 字体
- 基于 SFNT 的位图字体
- 可移植编译格式 (PCF)
- Microsoft Windows 字体文件格式(Windows FNT)
- 可移植字体资源 (PFR)
- 42 型(有限支持)
可以向FreeType 2字体引擎添加模块,以支持其他类型的字体文件。更多信息,请访问字体引擎自己的网站:http://freetype.sourceforge.net/freetype2/index.html。
使用 FreeType 渲染的字形可在应用程序之间有效共享,从而降低内存需求并加快文本渲染速度。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.