1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the text module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
36
// This file is not part of the Qt API. It exists for the convenience
37
// of internal files. This header file may change from version to version
38
// without notice, or even be removed.
46
#include <private/qunicodetables_p.h>
54
: pointSize(-1.0), pixelSize(-1),
55
styleStrategy(QFont::PreferDefault), styleHint(QFont::AnyStyle),
56
weight(50), fixedPitch(false), style(QFont::StyleNormal), stretch(100),
59
,fixedPitchComputed(false)
73
uint styleStrategy : 16;
76
uint weight : 7; // 0-99
79
uint stretch : 12; // 0-400
82
uint fixedPitchComputed : 1; // for Mac OS X only
83
uint reserved : 16; // for future extensions
85
bool exactMatch(const QFontDef &other) const;
86
bool operator==(const QFontDef &other) const
88
return pixelSize == other.pixelSize
89
&& weight == other.weight
90
&& style == other.style
91
&& stretch == other.stretch
92
&& styleHint == other.styleHint
93
&& styleStrategy == other.styleStrategy
94
&& family == other.family
96
&& addStyle == other.addStyle
100
inline bool operator<(const QFontDef &other) const
102
if (pixelSize != other.pixelSize) return pixelSize < other.pixelSize;
103
if (weight != other.weight) return weight < other.weight;
104
if (style != other.style) return style < other.style;
105
if (stretch != other.stretch) return stretch < other.stretch;
106
if (styleHint != other.styleHint) return styleHint < other.styleHint;
107
if (styleStrategy != other.styleStrategy) return styleStrategy < other.styleStrategy;
108
if (family != other.family) return family < other.family;
111
if (addStyle != other.addStyle) return addStyle < other.addStyle;
118
class QFontEngineData
127
#if defined(Q_WS_X11) || defined(Q_WS_WIN)
128
QFontEngine *engines[QUnicodeTables::ScriptCount];
131
#endif // Q_WS_X11 || Q_WS_WIN
133
enum { widthCacheSize = 0x500 };
134
uchar widthCache[widthCacheSize];
139
class Q_GUI_EXPORT QFontPrivate
143
static int defaultEncodingID;
147
QFontPrivate(const QFontPrivate &other);
150
void load(int script);
151
#if defined(Q_WS_X11) || defined(Q_WS_WIN)
152
inline QFontEngine *engineForScript(int script) const
154
if (script >= QUnicodeTables::Inherited)
155
script = QUnicodeTables::Common;
156
if (!engineData || !engineData->engines[script])
157
const_cast<QFontPrivate *>(this)->load(script);
158
return engineData->engines[script];
161
inline QFontEngine *engineForScript(int script) const
163
if (script >= QUnicodeTables::Inherited)
164
script = QUnicodeTables::Common;
165
if (!engineData || !engineData->engine)
166
const_cast<QFontPrivate *>(this)->load(script);
167
return engineData->engine;
169
#endif // Q_WS_X11 || Q_WS_WIN
173
QFontEngineData *engineData;
187
StyleStrategy = 0x0008,
199
void resolve(uint mask, const QFontPrivate *other);
203
class QFontCache : public QObject
207
static QFontCache *instance;
215
// universal key structure. QFontEngineDatas and QFontEngines are cached using
218
Key() : script(0), screen(0) { }
219
Key(const QFontDef &d, int c, int s = 0)
220
: def(d), script(c), screen(s) { }
226
inline bool operator<(const Key &other) const
228
if (script != other.script) return script < other.script;
229
if (screen != other.screen) return screen < other.screen;
230
return def < other.def;
232
inline bool operator==(const Key &other) const
233
{ return def == other.def && script == other.script && screen == other.screen; }
236
// QFontEngineData cache
237
typedef QMap<Key,QFontEngineData*> EngineDataCache;
238
EngineDataCache engineDataCache;
240
QFontEngineData *findEngineData(const Key &key) const;
241
void insertEngineData(const Key &key, QFontEngineData *engineData);
245
Engine() : data(0), timestamp(0), hits(0) { }
246
Engine(QFontEngine *d) : data(d), timestamp(0), hits(0) { }
253
typedef QMap<Key,Engine> EngineCache;
254
EngineCache engineCache;
256
QFontEngine *findEngine(const Key &key);
257
void insertEngine(const Key &key, QFontEngine *engine);
259
#if defined(Q_WS_WIN) || defined(Q_WS_QWS)
260
void cleanupPrinterFonts();
264
void increaseCost(uint cost);
265
void decreaseCost(uint cost);
266
void timerEvent(QTimerEvent *event);
268
static const uint min_cost;
269
uint total_cost, max_cost;
270
uint current_timestamp;
275
#endif // QFONTDATA_P_H