如何在Windows Qt中使用Linux字体? [英] How to use linux fonts in windows Qt?

查看:180
本文介绍了如何在Windows Qt中使用Linux字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在MS Windows上为Linux开发一个嵌入式Qt应用程序。目标平台是没有X-windows的linux(framebuffer)。不幸的是,窗口上的屏幕看起来比在Linux上的屏幕相当不同(更好),因为Windows有更好的字体。有没有办法强制在Windows上使用Linux字体的Qt?我希望实现二进制兼容性,即屏幕截图的CRC在Linux和Windows中将是相同的。 解决方案

您可以使用 QFontDatabase :: addApplicationFont 从文件或内存中加载字体(的QByteArray )。返回的ID可用于检索字体系列列表(请参阅QFontDatabase :: applicationFontFamilies < a>)可以传递给QFontDatabase :: 字体创建一个 QFont 在您的应用程序中使用的对象。



<仅支持 TrueType 字体。


We develop an embedded Qt application for linux on MS Windows. The target platform is linux without X-windows (framebuffer). Unfortunallety, the screens on windows look rather different (better) than the same screens on linux because windows has better fonts. Is there a way to force Qt on windows to use the linux fonts? I would like to achieve binary compatibility i.e. CRCs of the screenshots will be the same in linux and in windows.

解决方案

You can use QFontDatabase::addApplicationFont to load a font from a file or from memory (QByteArray). The returned id can be used to retrieve a list of font families (see QFontDatabase::applicationFontFamilies) that can be passed to QFontDatabase::font to create a QFont object for use in your application.

Only TrueType fonts are supported.

这篇关于如何在Windows Qt中使用Linux字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆