18#include <QtGui/private/qtguiglobal_p.h>
19#include "QtGui/qfont.h"
20#include "QtCore/qbasictimer.h"
21#include "QtCore/qmap.h"
22#include "QtCore/qhash.h"
23#include "QtCore/qobject.h"
24#include "QtCore/qstringlist.h"
25#include <QtGui/qfontdatabase.h>
26#include "private/qfixed_p.h"
27#include "private/qfontdatabase_p.h"
35#define QFONT_WEIGHT_MIN 1
36#define QFONT_WEIGHT_MAX 1000
81 return pixelSize == other.pixelSize
82 && weight == other.weight
83 && style == other.style
84 && stretch == other.stretch
85 && styleHint == other.styleHint
86 && styleStrategy == other.styleStrategy
87 && ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch
88 && families == other.families
89 && styleName == other.styleName
90 && hintingPreference == other.hintingPreference
91 && variableAxisValues == other.variableAxisValues
96 if (pixelSize != other.pixelSize)
return pixelSize < other.pixelSize;
102 if (families != other.families)
return families < other.families;
103 if (styleName != other.styleName)
104 return styleName < other.styleName;
110 if (variableAxisValues != other.variableAxisValues) {
111 if (variableAxisValues.size() != other.variableAxisValues.size())
112 return variableAxisValues.size() < other.variableAxisValues.size();
115 auto it = variableAxisValues.constBegin();
116 auto jt = other.variableAxisValues.constBegin();
117 for (; it != variableAxisValues.constEnd(); ++it, ++jt) {
118 if (it.key() != jt.key())
119 return jt.key() < it.key();
120 if (it.value() != jt.value())
121 return jt.value() < it.value();
132 return qHashMulti(seed,
133 qRound64(fd.pixelSize*10000),
144 fd.variableAxisValues.keys(),
145 fd.variableAxisValues.values());
168 QFontPrivate(
const QFontPrivate &other);
171 QFontEngine *engineForScript(
int script)
const;
172 void alterCharForCapitalization(QChar &c)
const;
176 mutable QFontEngineData *engineData;
184 bool letterSpacingIsAbsolute : 1;
186 QFixed letterSpacing;
188 QHash<QFont::Tag, quint32> features;
190 mutable QFontPrivate *scFont;
191 QFont smallCapsFont()
const {
return QFont(smallCapsFontPrivate()); }
192 QFontPrivate *smallCapsFontPrivate()
const;
194 static QFontPrivate *get(
const QFont &font)
196 return font.d.data();
199 void resolve(uint mask,
const QFontPrivate *other);
201 static void detachButKeepEngineData(QFont *font);
203 void setFeature(QFont::Tag tag, quint32 value);
204 void unsetFeature(QFont::Tag tag);
206 void setVariableAxis(QFont::Tag tag,
float value);
207 void unsetVariableAxis(QFont::Tag tag);
208 bool hasVariableAxis(QFont::Tag tag,
float value)
const;
211 QFontPrivate &operator=(
const QFontPrivate &) {
return *
this; }
219 static QFontCache *instance();
220 static void cleanup();
225 int id()
const {
return m_id; }
230 Key() : script(0), multi(0) { }
231 Key(
const QFontDef &d, uchar c,
bool m = 0)
232 : def(d), script(c), multi(m) { }
238 inline bool operator<(
const Key &other)
const
240 if (script != other.script)
return script < other.script;
241 if (multi != other.multi)
return multi < other.multi;
242 if (multi && def.fallBackFamilies.size() != other.def.fallBackFamilies.size())
243 return def.fallBackFamilies.size() < other.def.fallBackFamilies.size();
244 return def < other.def;
246 inline bool operator==(
const Key &other)
const
248 return script == other.script
249 && multi == other.multi
250 && (!multi || def.fallBackFamilies == other.def.fallBackFamilies)
256 typedef QMap<QFontDef, QFontEngineData*> EngineDataCache;
257 EngineDataCache engineDataCache;
259 QFontEngineData *findEngineData(
const QFontDef &def)
const;
260 void insertEngineData(
const QFontDef &def, QFontEngineData *engineData);
264 Engine() : data(
nullptr), timestamp(0), hits(0) { }
265 Engine(QFontEngine *d) : data(d), timestamp(0), hits(0) { }
272 typedef QMultiMap<Key,Engine> EngineCache;
273 EngineCache engineCache;
274 QHash<QFontEngine *,
int> engineCacheCount;
276 QFontEngine *findEngine(
const Key &key);
278 void updateHitCountAndTimeStamp(Engine &value);
279 void insertEngine(
const Key &key, QFontEngine *engine,
bool insertMulti =
false);
282 void increaseCost(uint cost);
283 void decreaseCost(uint cost);
284 void timerEvent(QTimerEvent *event) override;
285 void decreaseCache();
287 static const uint min_cost;
288 uint total_cost, max_cost;
289 uint current_timestamp;
291 const bool autoClean;
\threadsafe \inmodule QtGui
QFontEngine * engines[QFontDatabasePrivate::ScriptCount]
QDataStream & operator>>(QDataStream &s, QKeyCombination &combination)
Q_GUI_EXPORT int qt_openTypeToLegacyWeight(int weight)
static void set_font_bits(int version, quint8 bits, QFontPrivate *f)
QRecursiveMutex * qt_fontdatabase_mutex()
static int convertWeights(int weight, bool inverted)
static QStringList splitIntoFamilies(const QString &family)
Q_GUI_EXPORT int qt_legacyToOpenTypeWeight(int weight)
static constexpr auto fast_timeout
QHash< QString, QStringList > QFontSubst
#define QFONT_DEBUG_SKIP_DEFAULT(prop)
#define QFONTCACHE_MIN_COST
#define QT_FONT_ENGINE_FROM_DATA(data, script)
Q_GUI_EXPORT int qt_defaultDpiY()
static constexpr auto slow_timeout
Q_GUI_EXPORT int qt_defaultDpiX()
static quint8 get_extended_font_bits(const QFontPrivate *f)
Q_GUI_EXPORT int qt_defaultDpi()
#define QFONTCACHE_DECREASE_TRIGGER_LIMIT
QStringList qt_fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QFontDatabasePrivate::ExtendedScript script)
static quint8 get_font_bits(int version, const QFontPrivate *f)
static void set_extended_font_bits(quint8 bits, QFontPrivate *f)
size_t qHash(const QFontDef &fd, size_t seed=0) noexcept
Q_CONSTINIT Q_GUI_EXPORT bool qt_is_tty_app
Q_GLOBAL_STATIC(QReadWriteLock, g_updateMutex)
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
QStringList fallBackFamilies
bool operator<(const QFontDef &other) const
QMap< QFont::Tag, float > variableAxisValues
bool operator==(const QFontDef &other) const
bool exactMatch(const QFontDef &other) const