windows - 直写 : CreateFontFaceFromHDC() failed

标签 windows qt c++11 fonts qt-creator

我在 Qt 5.5.1 上有一个项目,一切都很好,但今天我将 Qt 升级到 5.7,然后我在运行时遇到以下错误,它不会使应用程序崩溃,但它让我发疯,因为它不是之前有

DirectWrite: CreateFontFaceFromHDC() failed (Indicates an error in an input file such as a font file.) for QFontDef(Family="Small Fonts", pointsize=15, pixelsize=20, styleHint=5, weight=50, stretch=100, hintingPreference=0) LOGFONT("Small Fonts", lfWidth=0, lfHeight=-20) dpi=96 DirectWrite: CreateFontFaceFromHDC() failed (Indicates an error in an input file such as a font file.) for QFontDef(Family="System", pointsize=15, pixelsize=20, styleHint=5, weight=50, stretch=100, hintingPreference=0) LOGFONT("System", lfWidth=0, lfHeight=-20) dpi=96 How can I fix it

最佳答案

有同样的问题。有一个带有静态创建的 QTextDocument 的单例类,因此在 QFont 类所需的 QApplication 之前创建。

可以通过在对 QTextDocument 进行任何操作之前设置 DefaultFont 来解决该问题。

关于windows - 直写 : CreateFontFaceFromHDC() failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38364525/

相关文章:

c++ - 从 C++ native Windows 应用程序接收 WebRTC 调用

macos - 无法在 mac osx 上的 QT 中创建新项目

c++ - 如何解决 mac 中的 qt5(未找到软件包)cmake 错误?

c++ - 为什么共享指针不删除内存?

c++ - Lambda:为什么按值捕获的值是常量,但按引用捕获的值不是?

windows - 如何压缩 PowerShell 脚本以适应单行

c# - 在 C# 服务应用程序中配置 log4net 的步骤

windows - 将 rtsp-stream 转换为 http 流

c++ - Qt - Q_OBJECT 与#include <QObject>

c++ - "no base classes of the same type as the first non-static data member"