Rendered text looks very different in Qt and Blink, although same font is set

六月ゝ 毕业季﹏ 提交于 2020-02-08 06:28:45

问题


The upper font is from a QLabel with QFont("Arial"). The lower font is rendered with QWebEngine, e.g. Chromium/Blink backend, using css

font-family: Arial, Helvetica, sans-serif;
font-size: 8pt;

Is there a way to make the blink one look as dark and sharp as the Qt one? It looks blurry and as both texts in the app are placed next to each other, it does not look good enough.

(Qt5.8 msvc 2015 on windows 8.1)

Edit

The reason is that chromium since version 52 did drop GDI support. In former version GDI rendering could be activated by disabling the DirectWrite flag. So basically I need to recompile Qt with a different chromium backend. Or perhaps with Cent Browser because it still supports that flag despite using newest chromium.


回答1:


First get the font family using QFontInfo::family(). This function returns matched family name of windows system font.

QFont f("Arial");
QFontInfo info(f);
QString family = info.family();

In simple terms "QFontInfo object is used to determine the attributes of the font actually used in the window system."

Use the family name returned by QFontInfo and set the same for QWebEngine by QWebEngineSettings::setFontFamily or using CSS.

useful links:

http://doc.qt.io/qt-5/qfontinfo.html#family

http://doc.qt.io/qt-5/qwebenginesettings.html#setFontFamily



来源:https://stackoverflow.com/questions/43161662/rendered-text-looks-very-different-in-qt-and-blink-although-same-font-is-set

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!