OSX FreeType: Add support for sub pixel font rendering.
Task-number: QTBUG-42839 Change-Id: Iea4552d766936a55fd177e4287591d2715202d9c Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
parent
ea3e2ca6ea
commit
385202c27c
@ -307,6 +307,7 @@ private:
|
||||
friend class QFontEngineFTRawFont;
|
||||
friend class QFontconfigDatabase;
|
||||
friend class QBasicFontDatabase;
|
||||
friend class QCoreTextFontDatabase;
|
||||
friend class QFontEngineMultiFontConfig;
|
||||
|
||||
int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const;
|
||||
|
@ -986,10 +986,20 @@ QFontEngine *QCoreTextFontDatabase::freeTypeFontEngine(const QFontDef &fontDef,
|
||||
QFontEngine::FaceId faceId;
|
||||
faceId.filename = filename;
|
||||
const bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
|
||||
const QFontEngineFT::GlyphFormat format = antialias ? QFontEngineFT::Format_A8
|
||||
: QFontEngineFT::Format_Mono;
|
||||
|
||||
QScopedPointer<QFontEngineFT> engine(new QFontEngineFT(fontDef));
|
||||
QFontEngineFT::GlyphFormat format = QFontEngineFT::Format_Mono;
|
||||
if (antialias) {
|
||||
QFontEngine::SubpixelAntialiasingType subpixelType = subpixelAntialiasingTypeHint();
|
||||
if (subpixelType == QFontEngine::Subpixel_None || (fontDef.styleStrategy & QFont::NoSubpixelAntialias)) {
|
||||
format = QFontEngineFT::Format_A8;
|
||||
engine->subpixelType = QFontEngine::Subpixel_None;
|
||||
} else {
|
||||
format = QFontEngineFT::Format_A32;
|
||||
engine->subpixelType = subpixelType;
|
||||
}
|
||||
}
|
||||
|
||||
if (!engine->init(faceId, antialias, format, fontData) || engine->invalid()) {
|
||||
qWarning() << "QCoreTextFontDatabase::freeTypefontEngine Failed to create engine";
|
||||
return Q_NULLPTR;
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
QPlatformCursor *cursor() const Q_DECL_OVERRIDE { return m_cursor; }
|
||||
QWindow *topLevelAt(const QPoint &point) const Q_DECL_OVERRIDE;
|
||||
QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE { return m_siblings; }
|
||||
QPlatformScreen::SubpixelAntialiasingType subpixelAntialiasingTypeHint() const Q_DECL_OVERRIDE;
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Additional methods
|
||||
|
@ -142,6 +142,16 @@ qreal QCocoaScreen::devicePixelRatio() const
|
||||
return qreal(screen ? [screen backingScaleFactor] : 1.0);
|
||||
}
|
||||
|
||||
QPlatformScreen::SubpixelAntialiasingType QCocoaScreen::subpixelAntialiasingTypeHint() const
|
||||
{
|
||||
QPlatformScreen::SubpixelAntialiasingType type = QPlatformScreen::subpixelAntialiasingTypeHint();
|
||||
if (type == QPlatformScreen::Subpixel_None) {
|
||||
// Every OSX machine has RGB pixels unless a peculiar or rotated non-Apple screen is attached
|
||||
type = QPlatformScreen::Subpixel_RGB;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
|
||||
{
|
||||
NSPoint screenPoint = qt_mac_flipPoint(point);
|
||||
|
Loading…
Reference in New Issue
Block a user