summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfont_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qfont_p.h')
-rw-r--r--src/gui/text/qfont_p.h112
1 files changed, 57 insertions, 55 deletions
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index d2d240b134..b674e71103 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QFONT_P_H
#define QFONT_P_H
@@ -66,38 +30,48 @@ QT_BEGIN_NAMESPACE
class QFontCache;
class QFontEngine;
+#define QFONT_WEIGHT_MIN 1
+#define QFONT_WEIGHT_MAX 1000
+
struct QFontDef
{
inline QFontDef()
- : pointSize(-1.0), pixelSize(-1),
- styleStrategy(QFont::PreferDefault), styleHint(QFont::AnyStyle),
- weight(50), fixedPitch(false), style(QFont::StyleNormal), stretch(QFont::AnyStretch),
- hintingPreference(QFont::PreferDefaultHinting), ignorePitch(true),
- fixedPitchComputed(0), reserved(0)
+ : pointSize(-1.0),
+ pixelSize(-1),
+ styleStrategy(QFont::PreferDefault),
+ stretch(QFont::AnyStretch),
+ style(QFont::StyleNormal),
+ hintingPreference(QFont::PreferDefaultHinting),
+ styleHint(QFont::AnyStyle),
+ weight(QFont::Normal),
+ fixedPitch(false),
+ ignorePitch(true),
+ fixedPitchComputed(0),
+ reserved(0)
{
}
- QString family;
QStringList families;
QString styleName;
QStringList fallBackFamilies;
+ QMap<QFont::Tag, float> variableAxisValues;
qreal pointSize;
qreal pixelSize;
+ // Note: Variable ordering matters to make sure no variable overlaps two 32-bit registers.
uint styleStrategy : 16;
- uint styleHint : 8;
+ uint stretch : 12; // 0-4000
+ uint style : 2;
+ uint hintingPreference : 2;
- uint weight : 7; // 0-99
+ uint styleHint : 8;
+ uint weight : 10; // 1-1000
uint fixedPitch : 1;
- uint style : 2;
- uint stretch : 12; // 0-4000
-
- uint hintingPreference : 2;
uint ignorePitch : 1;
uint fixedPitchComputed : 1; // for Mac OS X only
- uint reserved : 14; // for future extensions
+ uint reserved : 11; // for future extensions
bool exactMatch(const QFontDef &other) const;
bool operator==(const QFontDef &other) const
@@ -109,10 +83,10 @@ struct QFontDef
&& styleHint == other.styleHint
&& styleStrategy == other.styleStrategy
&& ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch
- && family == other.family
&& families == other.families
&& styleName == other.styleName
&& hintingPreference == other.hintingPreference
+ && variableAxisValues == other.variableAxisValues
;
}
inline bool operator<(const QFontDef &other) const
@@ -123,7 +97,6 @@ struct QFontDef
if (stretch != other.stretch) return stretch < other.stretch;
if (styleHint != other.styleHint) return styleHint < other.styleHint;
if (styleStrategy != other.styleStrategy) return styleStrategy < other.styleStrategy;
- if (family != other.family) return family < other.family;
if (families != other.families) return families < other.families;
if (styleName != other.styleName)
return styleName < other.styleName;
@@ -132,6 +105,22 @@ struct QFontDef
if (ignorePitch != other.ignorePitch) return ignorePitch < other.ignorePitch;
if (fixedPitch != other.fixedPitch) return fixedPitch < other.fixedPitch;
+ if (variableAxisValues != other.variableAxisValues) {
+ if (variableAxisValues.size() != other.variableAxisValues.size())
+ return variableAxisValues.size() < other.variableAxisValues.size();
+
+ {
+ auto it = variableAxisValues.constBegin();
+ auto jt = other.variableAxisValues.constBegin();
+ for (; it != variableAxisValues.constEnd(); ++it, ++jt) {
+ if (it.key() != jt.key())
+ return jt.key() < it.key();
+ if (it.value() != jt.value())
+ return jt.value() < it.value();
+ }
+ }
+ }
+
return false;
}
};
@@ -147,10 +136,11 @@ inline size_t qHash(const QFontDef &fd, size_t seed = 0) noexcept
fd.styleStrategy,
fd.ignorePitch,
fd.fixedPitch,
- fd.family,
fd.families,
fd.styleName,
- fd.hintingPreference);
+ fd.hintingPreference,
+ fd.variableAxisValues.keys(),
+ fd.variableAxisValues.values());
}
class QFontEngineData
@@ -194,6 +184,7 @@ public:
QFixed letterSpacing;
QFixed wordSpacing;
+ QHash<QFont::Tag, quint32> features;
mutable QFontPrivate *scFont;
QFont smallCapsFont() const { return QFont(smallCapsFontPrivate()); }
@@ -208,6 +199,13 @@ public:
static void detachButKeepEngineData(QFont *font);
+ void setFeature(QFont::Tag tag, quint32 value);
+ void unsetFeature(QFont::Tag tag);
+
+ void setVariableAxis(QFont::Tag tag, float value);
+ void unsetVariableAxis(QFont::Tag tag);
+ bool hasVariableAxis(QFont::Tag tag, float value) const;
+
private:
QFontPrivate &operator=(const QFontPrivate &) { return *this; }
};
@@ -289,6 +287,7 @@ private:
uint total_cost, max_cost;
uint current_timestamp;
bool fast;
+ const bool autoClean;
int timer_id;
const int m_id;
};
@@ -297,6 +296,9 @@ Q_GUI_EXPORT int qt_defaultDpiX();
Q_GUI_EXPORT int qt_defaultDpiY();
Q_GUI_EXPORT int qt_defaultDpi();
+Q_GUI_EXPORT int qt_legacyToOpenTypeWeight(int weight);
+Q_GUI_EXPORT int qt_openTypeToLegacyWeight(int weight);
+
QT_END_NAMESPACE
#endif // QFONT_P_H