【报错】ubuntu下qt无法加载字体库

ubuntu下使用qt4.8.6,使用addApplicationFont加载字体库失败,该字体库在windows下能够正常加载使用,排除是字体库的原因,查看帮助文档addApplicationFont的函数说明,上面说unix需要支持fontconfig。

Loads the font from the file specified by fileName and makes it available to the application. An ID is returned that can be used to remove the font again with removeApplicationFont() or to retrieve the list of family names contained in the font.
The function returns -1 if the font could not be loaded.
Currently only TrueType fonts, TrueType font collections, and OpenType fonts are supported.
Note: Adding application fonts on Unix/X11 platforms without fontconfig is currently not supported.
Note: On Symbian, the font family names get truncated to a length of 20 characters.
This function was introduced in Qt 4.2.

网上一查,配置qt源码的时候需要配置fontconfig。即./configure -fontconfig。如果报错FontConfig support cannot be enabled, due to functionality tests!

则安装apt-get install libfontconfig1-dev。然后重新编译源码即可。即make→sudo make install。重新编译完之后就可以用了。

没有配置fontconfig,还会出现在线程中无法drawText的问题,绘制的文字显示一个个矩形框,可以通过查看supportsThreadedFontRendering是否支持在线程中绘制文字。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值