diff options
Diffstat (limited to 'src/platformsupport/fontdatabases/fontconfig')
4 files changed, 147 insertions, 123 deletions
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index b8da9726d5..62dc9a9c6b 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -51,7 +43,6 @@ #include <qpa/qplatformservices.h> #include <QtGui/private/qfontengine_ft_p.h> -#include <QtGui/private/qfontengine_qpa_p.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/qguiapplication.h> @@ -517,21 +508,20 @@ QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine, } namespace { -QFontEngineFT::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintingPreference, FcPattern *match) +QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintingPreference, FcPattern *match, bool useXftConf) { switch (hintingPreference) { case QFont::PreferNoHinting: - return QFontEngineFT::HintNone; + return QFontEngine::HintNone; case QFont::PreferVerticalHinting: - return QFontEngineFT::HintLight; + return QFontEngine::HintLight; case QFont::PreferFullHinting: - return QFontEngineFT::HintFull; + return QFontEngine::HintFull; case QFont::PreferDefaultHinting: break; } - const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); - if (services && (services->desktopEnvironment() == "GNOME" || services->desktopEnvironment() == "UNITY")) { + if (useXftConf) { void *hintStyleResource = QGuiApplication::platformNativeInterface()->nativeResourceForScreen("hintstyle", QGuiApplication::primaryScreen()); @@ -545,42 +535,51 @@ QFontEngineFT::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hint hint_style = FC_HINT_FULL; switch (hint_style) { case FC_HINT_NONE: - return QFontEngineFT::HintNone; + return QFontEngine::HintNone; case FC_HINT_SLIGHT: - return QFontEngineFT::HintLight; + return QFontEngine::HintLight; case FC_HINT_MEDIUM: - return QFontEngineFT::HintMedium; + return QFontEngine::HintMedium; case FC_HINT_FULL: - return QFontEngineFT::HintFull; + return QFontEngine::HintFull; default: Q_UNREACHABLE(); break; } - return QFontEngineFT::HintFull; + return QFontEngine::HintFull; } -QFontEngineFT::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match) +QFontEngine::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match, bool useXftConf) { + if (useXftConf) { + void *subpixelTypeResource = + QGuiApplication::platformNativeInterface()->nativeResourceForScreen("subpixeltype", + QGuiApplication::primaryScreen()); + int subpixelType = int(reinterpret_cast<qintptr>(subpixelTypeResource)); + if (subpixelType > 0) + return QFontEngine::SubpixelAntialiasingType(subpixelType - 1); + } + int subpixel = FC_RGBA_UNKNOWN; FcPatternGetInteger(match, FC_RGBA, 0, &subpixel); switch (subpixel) { case FC_RGBA_UNKNOWN: case FC_RGBA_NONE: - return QFontEngineFT::Subpixel_None; + return QFontEngine::Subpixel_None; case FC_RGBA_RGB: - return QFontEngineFT::Subpixel_RGB; + return QFontEngine::Subpixel_RGB; case FC_RGBA_BGR: - return QFontEngineFT::Subpixel_BGR; + return QFontEngine::Subpixel_BGR; case FC_RGBA_VRGB: - return QFontEngineFT::Subpixel_VRGB; + return QFontEngine::Subpixel_VRGB; case FC_RGBA_VBGR: - return QFontEngineFT::Subpixel_VBGR; + return QFontEngine::Subpixel_VBGR; default: Q_UNREACHABLE(); break; } - return QFontEngineFT::Subpixel_None; + return QFontEngine::Subpixel_None; } } // namespace @@ -597,9 +596,23 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) fid.index = fontfile->indexValue; bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias); + bool forcedAntialiasSetting = !antialias; engine = new QFontEngineFT(fontDef); - QFontEngineFT::GlyphFormat format; + const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); + bool useXftConf = (services && (services->desktopEnvironment() == "GNOME" || services->desktopEnvironment() == "UNITY")); + if (useXftConf) { + void *antialiasResource = + QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled", + QGuiApplication::primaryScreen()); + int antialiasingEnabled = int(reinterpret_cast<qintptr>(antialiasResource)); + if (antialiasingEnabled > 0) { + antialias = antialiasingEnabled - 1; + forcedAntialiasSetting = true; + } + } + + QFontEngine::GlyphFormat format; // try and get the pattern FcPattern *pattern = FcPatternCreate(); @@ -623,29 +636,39 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) FcPattern *match = FcFontMatch(0, pattern, &result); if (match) { - engine->setDefaultHintStyle(defaultHintStyleFromMatch((QFont::HintingPreference)f.hintingPreference, match)); + engine->setDefaultHintStyle(defaultHintStyleFromMatch((QFont::HintingPreference)f.hintingPreference, match, useXftConf)); - if (antialias) { - // If antialiasing is not fully disabled, fontconfig may still disable it on a font match basis. + FcBool fc_autohint; + if (FcPatternGetBool(match, FC_AUTOHINT,0, &fc_autohint) == FcResultMatch) + engine->forceAutoHint = fc_autohint; + +#if defined(FT_LCD_FILTER_H) + int lcdFilter; + if (FcPatternGetInteger(match, FC_LCD_FILTER, 0, &lcdFilter) == FcResultMatch) + engine->lcdFilterType = lcdFilter; +#endif + + if (!forcedAntialiasSetting) { FcBool fc_antialias; - if (FcPatternGetBool(match, FC_ANTIALIAS,0, &fc_antialias) != FcResultMatch) - fc_antialias = true; - antialias = fc_antialias; + if (FcPatternGetBool(match, FC_ANTIALIAS,0, &fc_antialias) == FcResultMatch) + antialias = fc_antialias; } if (antialias) { - QFontEngineFT::SubpixelAntialiasingType subpixelType = subpixelTypeFromMatch(match); + QFontEngine::SubpixelAntialiasingType subpixelType = QFontEngine::Subpixel_None; + if (!(f.styleStrategy & QFont::NoSubpixelAntialias)) + subpixelType = subpixelTypeFromMatch(match, useXftConf); engine->subpixelType = subpixelType; - format = (subpixelType == QFontEngineFT::Subpixel_None) - ? QFontEngineFT::Format_A8 - : QFontEngineFT::Format_A32; + format = (subpixelType == QFontEngine::Subpixel_None) + ? QFontEngine::Format_A8 + : QFontEngine::Format_A32; } else - format = QFontEngineFT::Format_Mono; + format = QFontEngine::Format_Mono; FcPatternDestroy(match); } else - format = antialias ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono; + format = antialias ? QFontEngine::Format_A8 : QFontEngine::Format_Mono; FcPatternDestroy(pattern); @@ -665,7 +688,21 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QByteArray &fontData, qreal p QFontDef fontDef = engine->fontDef; - QFontEngineFT::GlyphFormat format; + bool forcedAntialiasSetting = false; + const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); + bool useXftConf = (services && (services->desktopEnvironment() == "GNOME" || services->desktopEnvironment() == "UNITY")); + if (useXftConf) { + void *antialiasResource = + QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled", + QGuiApplication::primaryScreen()); + int antialiasingEnabled = int(reinterpret_cast<qintptr>(antialiasResource)); + if (antialiasingEnabled > 0) { + engine->antialias = antialiasingEnabled - 1; + forcedAntialiasSetting = true; + } + } + + QFontEngine::GlyphFormat format; // try and get the pattern FcPattern *pattern = FcPatternCreate(); @@ -682,25 +719,36 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QByteArray &fontData, qreal p FcPattern *match = FcFontMatch(0, pattern, &result); if (match) { - engine->setDefaultHintStyle(defaultHintStyleFromMatch(hintingPreference, match)); + engine->setDefaultHintStyle(defaultHintStyleFromMatch(hintingPreference, match, useXftConf)); + + FcBool fc_autohint; + if (FcPatternGetBool(match, FC_AUTOHINT,0, &fc_autohint) == FcResultMatch) + engine->forceAutoHint = fc_autohint; + +#if defined(FT_LCD_FILTER_H) + int lcdFilter; + if (FcPatternGetInteger(match, FC_LCD_FILTER, 0, &lcdFilter) == FcResultMatch) + engine->lcdFilterType = lcdFilter; +#endif - FcBool fc_antialias; - if (FcPatternGetBool(match, FC_ANTIALIAS,0, &fc_antialias) != FcResultMatch) - fc_antialias = true; - engine->antialias = fc_antialias; + if (!forcedAntialiasSetting) { + FcBool fc_antialias; + if (FcPatternGetBool(match, FC_ANTIALIAS,0, &fc_antialias) == FcResultMatch) + engine->antialias = fc_antialias; + } if (engine->antialias) { - QFontEngineFT::SubpixelAntialiasingType subpixelType = subpixelTypeFromMatch(match); + QFontEngine::SubpixelAntialiasingType subpixelType = subpixelTypeFromMatch(match, useXftConf); engine->subpixelType = subpixelType; - format = subpixelType == QFontEngineFT::Subpixel_None - ? QFontEngineFT::Format_A8 - : QFontEngineFT::Format_A32; + format = subpixelType == QFontEngine::Subpixel_None + ? QFontEngine::Format_A8 + : QFontEngine::Format_A32; } else - format = QFontEngineFT::Format_Mono; + format = QFontEngine::Format_Mono; FcPatternDestroy(match); } else - format = QFontEngineFT::Format_A8; + format = QFontEngine::Format_A8; FcPatternDestroy(pattern); diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h index fc929e464d..91ecb52e7b 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp index fec489ba60..956cf68290 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -46,7 +38,7 @@ QT_BEGIN_NAMESPACE QFontEngineMultiFontConfig::QFontEngineMultiFontConfig(QFontEngine *fe, int script) - : QFontEngineMultiQPA(fe, script) + : QFontEngineMultiBasicImpl(fe, script) { } diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h index 3c2be10be6..115f8e6c16 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h +++ b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -53,12 +45,12 @@ // We mean it. // -#include <QtGui/private/qfontengine_qpa_p.h> +#include <QtGui/private/qfontengine_p.h> #include <fontconfig/fontconfig.h> QT_BEGIN_NAMESPACE -class QFontEngineMultiFontConfig : public QFontEngineMultiQPA +class QFontEngineMultiFontConfig : public QFontEngineMultiBasicImpl { public: explicit QFontEngineMultiFontConfig(QFontEngine *fe, int script); |