Skip to content

Instantly share code, notes, and snippets.

Created September 22, 2011 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1235082 to your computer and use it in GitHub Desktop.
Save anonymous/1235082 to your computer and use it in GitHub Desktop.
diff --git i/Tools/ChangeLog w/Tools/ChangeLog
index ac589ac..e62adfb 100644
--- i/Tools/ChangeLog
+++ w/Tools/ChangeLog
@@ -1,3 +1,23 @@
+2011-09-22 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
+
+ [Qt] Use same DPI for application font as rest of app in DRT and WTR
+
+ QApplication will initialize the default application font based
+ on the application DPI at construction time, but we then override
+ the application DPI using QX11Info (hard-coding it to 96 for
+ consistency). This hard-coding is not reflected in the application
+ font, so we explicitly have update the font ourselves.
+
+ The 6 test results that are updated were originally produced with
+ a DPI of 75, as this is the default fallback DPI when a QFont is
+ constructed before QApplication. This was wrong, and the results
+ are updated to match a DPI of 96.
+
+ Reviewed by NOBODY.
+
+ * DumpRenderTree/qt/main.cpp:
+ * WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp:
+
2011-09-21 Anna Cavender <annacc@chromium.org>
Update committers.py with a new contributor contact
diff --git i/Tools/DumpRenderTree/qt/main.cpp w/Tools/DumpRenderTree/qt/main.cpp
index 89a5128..86b8b03 100644
--- i/Tools/DumpRenderTree/qt/main.cpp
+++ w/Tools/DumpRenderTree/qt/main.cpp
@@ -144,18 +144,26 @@ int main(int argc, char* argv[])
QApplication::setGraphicsSystem("raster");
QApplication::setStyle(new QWindowsStyle);
- QFont f("Sans Serif");
- f.setPointSize(9);
- f.setWeight(QFont::Normal);
- f.setStyle(QFont::StyleNormal);
- QApplication::setFont(f);
-
QApplication app(argc, argv);
+
#ifdef Q_WS_X11
QX11Info::setAppDpiY(0, 96);
QX11Info::setAppDpiX(0, 96);
#endif
+ /*
+ * QApplication will initialize the default application font based
+ * on the application DPI at construction time, which might be
+ * different from the DPI we explicitly set using QX11Info above.
+ * See: https://bugreports.qt.nokia.com/browse/QTBUG-21603
+ *
+ * To ensure that the application font DPI matches the application
+ * DPI, we override the application font using the font we get from
+ * a QWidget, which has already been resolved against the existing
+ * default font, but with the correct paint-device DPI.
+ */
+ QApplication::setFont(QWidget().font());
+
#if HAVE(SIGNAL_H)
signal(SIGILL, crashHandler); /* 4: illegal instruction (not reset when caught) */
signal(SIGTRAP, crashHandler); /* 5: trace trap (not reset when caught) */
diff --git i/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp w/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp
index fba00bd..b8be251 100644
--- i/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp
+++ w/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp
@@ -34,6 +34,7 @@
#include <QByteArray>
#include <QDir>
#include <QFont>
+#include <QWidget>
#include <QWindowsStyle>
#ifdef Q_WS_X11
@@ -90,16 +91,23 @@ void activateFonts()
QApplication::setGraphicsSystem(QLatin1String("raster"));
QApplication::setStyle(new QWindowsStyle);
- QFont f(QLatin1String("Sans Serif"));
- f.setPointSize(9);
- f.setWeight(QFont::Normal);
- f.setStyle(QFont::StyleNormal);
- QApplication::setFont(f);
-
#if defined(Q_WS_X11)
QX11Info::setAppDpiX(0, 96);
QX11Info::setAppDpiY(0, 96);
#endif
+
+ /*
+ * QApplication will initialize the default application font based
+ * on the application DPI at construction time, which might be
+ * different from the DPI we explicitly set using QX11Info above.
+ * See: https://bugreports.qt.nokia.com/browse/QTBUG-21603
+ *
+ * To ensure that the application font DPI matches the application
+ * DPI, we override the application font using the font we get from
+ * a QWidget, which has already been resolved against the existing
+ * default font, but with the correct paint-device DPI.
+ */
+ QApplication::setFont(QWidget().font());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment