summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qplatformscreen.cpp27
-rw-r--r--src/gui/kernel/qplatformscreen.h9
-rw-r--r--src/gui/text/qfontengine_ft_p.h1
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp12
-rw-r--r--src/gui/text/qplatformfontdatabase.h2
5 files changed, 51 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp
index 745b89018e..edf546799f 100644
--- a/src/gui/kernel/qplatformscreen.cpp
+++ b/src/gui/kernel/qplatformscreen.cpp
@@ -393,4 +393,31 @@ QRect QPlatformScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation
return rect;
}
+/*!
+ Returns a hint about this screen's subpixel layout structure.
+
+ The default implementation queries the \b{QT_SUBPIXEL_AA_TYPE} env variable.
+ This is just a hint because most platforms don't have a way to retrieve the correct value from hardware
+ and instead rely on font configurations.
+*/
+QPlatformScreen::SubpixelAntialiasingType QPlatformScreen::subpixelAntialiasingTypeHint() const
+{
+ static int type = -1;
+ if (type == -1) {
+ QByteArray env = qgetenv("QT_SUBPIXEL_AA_TYPE");
+ if (env == "RGB")
+ type = QPlatformScreen::Subpixel_RGB;
+ else if (env == "BGR")
+ type = QPlatformScreen::Subpixel_BGR;
+ else if (env == "VRGB")
+ type = QPlatformScreen::Subpixel_VRGB;
+ else if (env == "VBGR")
+ type = QPlatformScreen::Subpixel_VBGR;
+ else
+ type = QPlatformScreen::Subpixel_None;
+ }
+
+ return static_cast<QPlatformScreen::SubpixelAntialiasingType>(type);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h
index fdae339815..551cb788c9 100644
--- a/src/gui/kernel/qplatformscreen.h
+++ b/src/gui/kernel/qplatformscreen.h
@@ -74,6 +74,14 @@ class Q_GUI_EXPORT QPlatformScreen
Q_DECLARE_PRIVATE(QPlatformScreen)
public:
+ enum SubpixelAntialiasingType { // copied from qfontengine_p.h since we can't include private headers
+ Subpixel_None,
+ Subpixel_RGB,
+ Subpixel_BGR,
+ Subpixel_VRGB,
+ Subpixel_VBGR
+ };
+
QPlatformScreen();
virtual ~QPlatformScreen();
@@ -107,6 +115,7 @@ public:
virtual QString name() const { return QString(); }
virtual QPlatformCursor *cursor() const;
+ virtual SubpixelAntialiasingType subpixelAntialiasingTypeHint() const;
static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b);
static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target);
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index bcd2efaef8..8fd5ca23af 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -305,6 +305,7 @@ protected:
private:
friend class QFontEngineFTRawFont;
friend class QFontconfigDatabase;
+ friend class QBasicFontDatabase;
friend class QFontEngineMultiFontConfig;
int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const;
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 080bfecefb..3c3000da4d 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -34,6 +34,9 @@
#include "qplatformfontdatabase.h"
#include <QtGui/private/qfontengine_p.h>
#include <QtGui/private/qfontengine_qpf2_p.h>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QScreen>
+#include <qpa/qplatformscreen.h>
#include <QtCore/QLibraryInfo>
#include <QtCore/QDir>
@@ -457,6 +460,15 @@ bool QPlatformFontDatabase::fontsAlwaysScalable() const
return ret;
}
+QFontEngine::SubpixelAntialiasingType QPlatformFontDatabase::subpixelAntialiasingTypeHint() const
+{
+ static int type = -1;
+ if (type == -1) {
+ if (QScreen *screen = QGuiApplication::primaryScreen())
+ type = screen->handle()->subpixelAntialiasingTypeHint();
+ }
+ return static_cast<QFontEngine::SubpixelAntialiasingType>(type);
+}
// ### copied to tools/makeqpf/qpf2.cpp
diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h
index 56934b066a..0615df65d6 100644
--- a/src/gui/text/qplatformfontdatabase.h
+++ b/src/gui/text/qplatformfontdatabase.h
@@ -49,6 +49,7 @@
#include <QtCore/QList>
#include <QtCore/QHash>
#include <QtGui/QFontDatabase>
+#include <QtGui/private/qfontengine_p.h>
#include <QtGui/private/qfont_p.h>
QT_BEGIN_NAMESPACE
@@ -107,6 +108,7 @@ public:
virtual QString resolveFontFamilyAlias(const QString &family) const;
virtual bool fontsAlwaysScalable() const;
virtual QList<int> standardSizes() const;
+ QFontEngine::SubpixelAntialiasingType subpixelAntialiasingTypeHint() const;
// helper
static QSupportedWritingSystems writingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2]);