mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add Qt 5.6 support to the headless fontconfig database
This commit is contained in:
parent
1c580d1eba
commit
df452b4d72
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the plugins of the Qt Toolkit.
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
**
|
**
|
||||||
@ -10,9 +10,9 @@
|
|||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
** accordance with the commercial license agreement provided with the
|
** accordance with the commercial license agreement provided with the
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
**
|
**
|
||||||
** GNU Lesser General Public License Usage
|
** GNU Lesser General Public License Usage
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
@ -23,8 +23,8 @@
|
|||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
**
|
**
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
**
|
**
|
||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
@ -44,6 +44,9 @@
|
|||||||
#include <QtPlatformSupport/private/qfontenginemultifontconfig_p.h>
|
#include <QtPlatformSupport/private/qfontenginemultifontconfig_p.h>
|
||||||
#include <QtGui/private/qfontengine_ft_p.h>
|
#include <QtGui/private/qfontengine_ft_p.h>
|
||||||
#include <QtGui/private/qguiapplication_p.h>
|
#include <QtGui/private/qguiapplication_p.h>
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||||
|
#include <QtGui/private/qhighdpiscaling_p.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QtGui/qguiapplication.h>
|
#include <QtGui/qguiapplication.h>
|
||||||
|
|
||||||
@ -266,10 +269,20 @@ static const char *specialLanguages[] = {
|
|||||||
"sa", // Siddham
|
"sa", // Siddham
|
||||||
"sd", // Khudawadi
|
"sd", // Khudawadi
|
||||||
"mai", // Tirhuta
|
"mai", // Tirhuta
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
|
"hoc", // WarangCiti
|
||||||
|
"", // Ahom
|
||||||
|
"", // AnatolianHieroglyphs
|
||||||
|
"", // Hatran
|
||||||
|
"", // Multani
|
||||||
|
"", // OldHungarian
|
||||||
|
"" // SignWriting
|
||||||
|
#else
|
||||||
"hoc" // WarangCiti
|
"hoc" // WarangCiti
|
||||||
|
#endif // Qt >= 5.6.0
|
||||||
#else
|
#else
|
||||||
"doi" // Takri
|
"doi" // Takri
|
||||||
#endif
|
#endif // Qt >= 5.5.0
|
||||||
|
|
||||||
};
|
};
|
||||||
Q_STATIC_ASSERT(sizeof(specialLanguages) / sizeof(const char *) == QChar::ScriptCount);
|
Q_STATIC_ASSERT(sizeof(specialLanguages) / sizeof(const char *) == QChar::ScriptCount);
|
||||||
@ -587,6 +600,11 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Removed by Kovid for headless QPA
|
// Removed by Kovid for headless QPA
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||||
|
if (QHighDpiScaling::isActive())
|
||||||
|
return QFontEngine::HintNone;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (useXftConf) {
|
if (useXftConf) {
|
||||||
void *hintStyleResource =
|
void *hintStyleResource =
|
||||||
@ -739,15 +757,19 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont
|
|||||||
FcPatternDestroy(pattern);
|
FcPatternDestroy(pattern);
|
||||||
|
|
||||||
if (fontSet) {
|
if (fontSet) {
|
||||||
|
QSet<QString> duplicates;
|
||||||
|
duplicates.reserve(fontSet->nfont + 1);
|
||||||
|
duplicates.insert(family.toCaseFolded());
|
||||||
for (int i = 0; i < fontSet->nfont; i++) {
|
for (int i = 0; i < fontSet->nfont; i++) {
|
||||||
FcChar8 *value = 0;
|
FcChar8 *value = 0;
|
||||||
if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
|
if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
|
||||||
continue;
|
continue;
|
||||||
// capitalize(value);
|
// capitalize(value);
|
||||||
QString familyName = QString::fromUtf8((const char *)value);
|
const QString familyName = QString::fromUtf8((const char *)value);
|
||||||
if (!fallbackFamilies.contains(familyName,Qt::CaseInsensitive) &&
|
const QString familyNameCF = familyName.toCaseFolded();
|
||||||
familyName.compare(family, Qt::CaseInsensitive)) {
|
if (!duplicates.contains(familyNameCF)) {
|
||||||
fallbackFamilies << familyName;
|
fallbackFamilies << familyName;
|
||||||
|
duplicates.insert(familyNameCF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FcFontSetDestroy(fontSet);
|
FcFontSetDestroy(fontSet);
|
||||||
@ -885,10 +907,8 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef
|
|||||||
QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled",
|
QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled",
|
||||||
QGuiApplication::primaryScreen());
|
QGuiApplication::primaryScreen());
|
||||||
int antialiasingEnabled = int(reinterpret_cast<qintptr>(antialiasResource));
|
int antialiasingEnabled = int(reinterpret_cast<qintptr>(antialiasResource));
|
||||||
if (antialiasingEnabled > 0) {
|
if (antialiasingEnabled > 0)
|
||||||
antialias = antialiasingEnabled - 1;
|
antialias = antialiasingEnabled - 1;
|
||||||
forcedAntialiasSetting = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QFontEngine::GlyphFormat format;
|
QFontEngine::GlyphFormat format;
|
||||||
@ -964,5 +984,3 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef
|
|||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user