关于嵌入式Qt字体大小设置无效的原因分析

在Qt官网上,Qt for Embedded Linux Fonts模块已经说的很清楚了,搞了好多天大哭

Qt for Embedded Linux Fonts

Qt for Embedded Linux uses the FreeType 2 font engine to produce font output. The formats supported depends on the locally installed version of the FreeType library. In addition, Qt for Embedded Linux supports the Qt Prerendered Font formats (QPF and QPF2): light-weight non-scalable font formats specific to Qt for Embedded Linux. QPF2 is the native format of Qt for Embedded Linux. QPF is the legacy format used by Qt/Embedded 2.x and 3.x. Several of the formats may be rendered using anti-aliasing for improved readability.

QPF是一个轻量不可缩放的字体库格式。

When Qt for Embedded Linux applications run, they look for fonts in Qt's lib/fonts/ directory. Qt for Embedded Linux will automatically detect prerendered fonts and TrueType fonts. For compatibility, it will also read the legacy lib/fonts/fontdir file.

当程序运行的时候,会自动查找字库

Nokia provides support for the legacy QPF format for compatibility reasons. QPF is based on the internal font engine data structure of Qt/Embedded versions 2 and 3.

Note that the file name describes the font, for example helvetica_120_50.qpf is 12 point Helvetica while helvetica_120_50i.qpf is 12 point Helvetica italic.

120对应12号,字号*10;

The Legacy fontdir File

For compatibility reasons Qt for Embedded Linux supports the fontdir file, if present. The file defines additional fonts available to the application, and has the following format:

 name file renderer italic weight size flags

FieldDescription
nameThe name of the font format, e.g.,Helvetica, Times, etc.
fileThe name of the file containing the font, e.g., helvR0810.bdf, verdana.ttf, etc.
rendererSpecifies the font engine that should be used to render the font, currently only the FreeType font engine (FT) is supported.
italicSpecifies whether the font is italic or not; the accepted values are y or n.
weightSpecifies the font's weight: 50 is normal, 75 is bold, etc.
sizeSpecifies the font size, i.e., point size * 10. For example, a value of 120 means 12pt. A value of 0 means that the font is scalable.
flagsThe following flag is supported:
  • s: smooth (anti-aliased)

All other flags are ignored.



为了兼容多种字体,可以通过设置fontdir文件来完成

例如:

simhei_10 simhei_ms.ttf FT n 50 100 su
simhei_11 simhei_ms.ttf FT n 50 110 su
simhei_12 simhei_ms.ttf FT n 50 120 su
simhei_13 simhei_ms.ttf FT n 50 130 su
simhei_14 simhei_ms.ttf FT n 50 140 su
simhei_15 simhei_ms.ttf FT n 50 150 su
simhei_16 simhei_ms.ttf FT n 50 160 su

QFont font;

font.setpointsize(10);

font.setfamliy("simhei_10");

qApp->setfont(font);


Qt:官网:http://doc.qt.digia.com/4.6/qt-embedded-fonts.html#the-legacy-file


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值