| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qfont.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
| 29 | ** | - | ||||||||||||||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
| 31 | ** | - | ||||||||||||||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||
| 34 | #include "qfont.h" | - | ||||||||||||||||||||||||
| 35 | #include "qdebug.h" | - | ||||||||||||||||||||||||
| 36 | #include "qpaintdevice.h" | - | ||||||||||||||||||||||||
| 37 | #include "qfontdatabase.h" | - | ||||||||||||||||||||||||
| 38 | #include "qfontmetrics.h" | - | ||||||||||||||||||||||||
| 39 | #include "qfontinfo.h" | - | ||||||||||||||||||||||||
| 40 | #include "qpainter.h" | - | ||||||||||||||||||||||||
| 41 | #include "qhash.h" | - | ||||||||||||||||||||||||
| 42 | #include "qdatastream.h" | - | ||||||||||||||||||||||||
| 43 | #include "qguiapplication.h" | - | ||||||||||||||||||||||||
| 44 | #include "qstringlist.h" | - | ||||||||||||||||||||||||
| 45 | #include "qscreen.h" | - | ||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | #include "qthread.h" | - | ||||||||||||||||||||||||
| 48 | #include "qthreadstorage.h" | - | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | #include "qfont_p.h" | - | ||||||||||||||||||||||||
| 51 | #include <private/qfontengine_p.h> | - | ||||||||||||||||||||||||
| 52 | #include <private/qpainter_p.h> | - | ||||||||||||||||||||||||
| 53 | #include <private/qtextengine_p.h> | - | ||||||||||||||||||||||||
| 54 | #include <limits.h> | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | #include <qpa/qplatformscreen.h> | - | ||||||||||||||||||||||||
| 57 | #include <qpa/qplatformintegration.h> | - | ||||||||||||||||||||||||
| 58 | #include <qpa/qplatformfontdatabase.h> | - | ||||||||||||||||||||||||
| 59 | #include <QtGui/private/qguiapplication_p.h> | - | ||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | #include <QtCore/QMutexLocker> | - | ||||||||||||||||||||||||
| 62 | #include <QtCore/QMutex> | - | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | // #define QFONTCACHE_DEBUG | - | ||||||||||||||||||||||||
| 65 | #ifdef QFONTCACHE_DEBUG | - | ||||||||||||||||||||||||
| 66 | # define FC_DEBUG qDebug | - | ||||||||||||||||||||||||
| 67 | #else | - | ||||||||||||||||||||||||
| 68 | # define FC_DEBUG if (false) qDebug | - | ||||||||||||||||||||||||
| 69 | #endif | - | ||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||
| 71 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | #ifndef QFONTCACHE_DECREASE_TRIGGER_LIMIT | - | ||||||||||||||||||||||||
| 74 | # define QFONTCACHE_DECREASE_TRIGGER_LIMIT 256 | - | ||||||||||||||||||||||||
| 75 | #endif | - | ||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | bool QFontDef::exactMatch(const QFontDef &other) const | - | ||||||||||||||||||||||||
| 78 | { | - | ||||||||||||||||||||||||
| 79 | /* | - | ||||||||||||||||||||||||
| 80 | QFontDef comparison is more complicated than just simple | - | ||||||||||||||||||||||||
| 81 | per-member comparisons. | - | ||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||
| 83 | When comparing point/pixel sizes, either point or pixelsize | - | ||||||||||||||||||||||||
| 84 | could be -1. in This case we have to compare the non negative | - | ||||||||||||||||||||||||
| 85 | size value. | - | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | This test will fail if the point-sizes differ by 1/2 point or | - | ||||||||||||||||||||||||
| 88 | more or they do not round to the same value. We have to do this | - | ||||||||||||||||||||||||
| 89 | since our API still uses 'int' point-sizes in the API, but store | - | ||||||||||||||||||||||||
| 90 | deci-point-sizes internally. | - | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | To compare the family members, we need to parse the font names | - | ||||||||||||||||||||||||
| 93 | and compare the family/foundry strings separately. This allows | - | ||||||||||||||||||||||||
| 94 | us to compare e.g. "Helvetica" and "Helvetica [Adobe]" with | - | ||||||||||||||||||||||||
| 95 | positive results. | - | ||||||||||||||||||||||||
| 96 | */ | - | ||||||||||||||||||||||||
| 97 | if (pixelSize != -1 && other.pixelSize != -1) {
| 0 | ||||||||||||||||||||||||
| 98 | if (pixelSize != other.pixelSize)
| 0 | ||||||||||||||||||||||||
| 99 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 100 | } else if (pointSize != -1 && other.pointSize != -1) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 101 | if (pointSize != other.pointSize)
| 0 | ||||||||||||||||||||||||
| 102 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 103 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 104 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 105 | } | - | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | if (!ignorePitch && !other.ignorePitch && fixedPitch != other.fixedPitch)
| 0 | ||||||||||||||||||||||||
| 108 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | if (stretch != 0 && other.stretch != 0 && stretch != other.stretch)
| 0 | ||||||||||||||||||||||||
| 111 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | QString this_family, this_foundry, other_family, other_foundry; | - | ||||||||||||||||||||||||
| 114 | QFontDatabase::parseFontName(family, this_foundry, this_family); | - | ||||||||||||||||||||||||
| 115 | QFontDatabase::parseFontName(other.family, other_foundry, other_family); | - | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | this_family = QFontDatabase::resolveFontFamilyAlias(this_family); | - | ||||||||||||||||||||||||
| 118 | other_family = QFontDatabase::resolveFontFamilyAlias(other_family); | - | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | return (styleHint == other.styleHint never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
| 0 | ||||||||||||||||||||||||
| 121 | && styleStrategy == other.styleStrategy never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
| 0 | ||||||||||||||||||||||||
| 122 | && weight == other.weight never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
| 0 | ||||||||||||||||||||||||
| 123 | && style == other.style never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
| 0 | ||||||||||||||||||||||||
| 124 | && this_family == other_family never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
| 0 | ||||||||||||||||||||||||
| 125 | && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
| 0 | ||||||||||||||||||||||||
| 126 | && (this_foundry.isEmpty() never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
| 0 | ||||||||||||||||||||||||
| 127 | || other_foundry.isEmpty() never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
| 0 | ||||||||||||||||||||||||
| 128 | || this_foundry == other_foundry) never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
| 0 | ||||||||||||||||||||||||
| 129 | ); never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) ); | 0 | ||||||||||||||||||||||||
| 130 | } | - | ||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | extern bool qt_is_gui_used; | - | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | Q_GUI_EXPORT int qt_defaultDpiX() | - | ||||||||||||||||||||||||
| 135 | { | - | ||||||||||||||||||||||||
| 136 | if (QCoreApplication::instance()->testAttribute(Qt::AA_Use96Dpi))
| 0 | ||||||||||||||||||||||||
| 137 | return 96; never executed: return 96; | 0 | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | if (!qt_is_gui_used)
| 0 | ||||||||||||||||||||||||
| 140 | return 75; never executed: return 75; | 0 | ||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | if (const QScreen *screen = QGuiApplication::primaryScreen())
| 0 | ||||||||||||||||||||||||
| 143 | return qRound(screen->logicalDotsPerInchX()); never executed: return qRound(screen->logicalDotsPerInchX()); | 0 | ||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||
| 145 | //PI has not been initialised, or it is being initialised. Give a default dpi | - | ||||||||||||||||||||||||
| 146 | return 100; never executed: return 100; | 0 | ||||||||||||||||||||||||
| 147 | } | - | ||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | Q_GUI_EXPORT int qt_defaultDpiY() | - | ||||||||||||||||||||||||
| 150 | { | - | ||||||||||||||||||||||||
| 151 | if (QCoreApplication::instance()->testAttribute(Qt::AA_Use96Dpi))
| 0 | ||||||||||||||||||||||||
| 152 | return 96; never executed: return 96; | 0 | ||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | if (!qt_is_gui_used)
| 0 | ||||||||||||||||||||||||
| 155 | return 75; never executed: return 75; | 0 | ||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||
| 157 | if (const QScreen *screen = QGuiApplication::primaryScreen())
| 0 | ||||||||||||||||||||||||
| 158 | return qRound(screen->logicalDotsPerInchY()); never executed: return qRound(screen->logicalDotsPerInchY()); | 0 | ||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | //PI has not been initialised, or it is being initialised. Give a default dpi | - | ||||||||||||||||||||||||
| 161 | return 100; never executed: return 100; | 0 | ||||||||||||||||||||||||
| 162 | } | - | ||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||
| 164 | Q_GUI_EXPORT int qt_defaultDpi() | - | ||||||||||||||||||||||||
| 165 | { | - | ||||||||||||||||||||||||
| 166 | return qt_defaultDpiY(); never executed: return qt_defaultDpiY(); | 0 | ||||||||||||||||||||||||
| 167 | } | - | ||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||
| 169 | QFontPrivate::QFontPrivate() | - | ||||||||||||||||||||||||
| 170 | : engineData(0), dpi(qt_defaultDpi()), screen(0), | - | ||||||||||||||||||||||||
| 171 | underline(false), overline(false), strikeOut(false), kerning(true), | - | ||||||||||||||||||||||||
| 172 | capital(0), letterSpacingIsAbsolute(false), scFont(0) | - | ||||||||||||||||||||||||
| 173 | { | - | ||||||||||||||||||||||||
| 174 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||
| 176 | QFontPrivate::QFontPrivate(const QFontPrivate &other) | - | ||||||||||||||||||||||||
| 177 | : request(other.request), engineData(0), dpi(other.dpi), screen(other.screen), | - | ||||||||||||||||||||||||
| 178 | underline(other.underline), overline(other.overline), | - | ||||||||||||||||||||||||
| 179 | strikeOut(other.strikeOut), kerning(other.kerning), | - | ||||||||||||||||||||||||
| 180 | capital(other.capital), letterSpacingIsAbsolute(other.letterSpacingIsAbsolute), | - | ||||||||||||||||||||||||
| 181 | letterSpacing(other.letterSpacing), wordSpacing(other.wordSpacing), | - | ||||||||||||||||||||||||
| 182 | scFont(other.scFont) | - | ||||||||||||||||||||||||
| 183 | { | - | ||||||||||||||||||||||||
| 184 | if (scFont && scFont != this)
| 0 | ||||||||||||||||||||||||
| 185 | scFont->ref.ref(); never executed: scFont->ref.ref(); | 0 | ||||||||||||||||||||||||
| 186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||
| 188 | QFontPrivate::~QFontPrivate() | - | ||||||||||||||||||||||||
| 189 | { | - | ||||||||||||||||||||||||
| 190 | if (engineData && !engineData->ref.deref())
| 0 | ||||||||||||||||||||||||
| 191 | delete engineData; never executed: delete engineData; | 0 | ||||||||||||||||||||||||
| 192 | engineData = 0; | - | ||||||||||||||||||||||||
| 193 | if (scFont && scFont != this)
| 0 | ||||||||||||||||||||||||
| 194 | scFont->ref.deref(); never executed: scFont->ref.deref(); | 0 | ||||||||||||||||||||||||
| 195 | scFont = 0; | - | ||||||||||||||||||||||||
| 196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||
| 198 | extern QMutex *qt_fontdatabase_mutex(); | - | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | #define QT_FONT_ENGINE_FROM_DATA(data, script) data->engines[script] | - | ||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||
| 202 | QFontEngine *QFontPrivate::engineForScript(int script) const | - | ||||||||||||||||||||||||
| 203 | { | - | ||||||||||||||||||||||||
| 204 | QMutexLocker locker(qt_fontdatabase_mutex()); | - | ||||||||||||||||||||||||
| 205 | if (script <= QChar::Script_Latin)
| 0 | ||||||||||||||||||||||||
| 206 | script = QChar::Script_Common; never executed: script = QChar::Script_Common; | 0 | ||||||||||||||||||||||||
| 207 | if (engineData && engineData->fontCacheId != QFontCache::instance()->id()) {
| 0 | ||||||||||||||||||||||||
| 208 | // throw out engineData that came from a different thread | - | ||||||||||||||||||||||||
| 209 | if (!engineData->ref.deref())
| 0 | ||||||||||||||||||||||||
| 210 | delete engineData; never executed: delete engineData; | 0 | ||||||||||||||||||||||||
| 211 | engineData = 0; | - | ||||||||||||||||||||||||
| 212 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 213 | if (!engineData || !QT_FONT_ENGINE_FROM_DATA(engineData, script))
| 0 | ||||||||||||||||||||||||
| 214 | QFontDatabase::load(this, script); never executed: QFontDatabase::load(this, script); | 0 | ||||||||||||||||||||||||
| 215 | return QT_FONT_ENGINE_FROM_DATA(engineData, script); never executed: return engineData->engines[script]; | 0 | ||||||||||||||||||||||||
| 216 | } | - | ||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | void QFontPrivate::alterCharForCapitalization(QChar &c) const { | - | ||||||||||||||||||||||||
| 219 | switch (capital) { | - | ||||||||||||||||||||||||
| 220 | case QFont::AllUppercase: never executed: case QFont::AllUppercase: | 0 | ||||||||||||||||||||||||
| 221 | case QFont::SmallCaps: never executed: case QFont::SmallCaps: | 0 | ||||||||||||||||||||||||
| 222 | c = c.toUpper(); | - | ||||||||||||||||||||||||
| 223 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 224 | case QFont::AllLowercase: never executed: case QFont::AllLowercase: | 0 | ||||||||||||||||||||||||
| 225 | c = c.toLower(); | - | ||||||||||||||||||||||||
| 226 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 227 | case QFont::MixedCase: never executed: case QFont::MixedCase: | 0 | ||||||||||||||||||||||||
| 228 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 229 | } | - | ||||||||||||||||||||||||
| 230 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 231 | - | |||||||||||||||||||||||||
| 232 | QFontPrivate *QFontPrivate::smallCapsFontPrivate() const | - | ||||||||||||||||||||||||
| 233 | { | - | ||||||||||||||||||||||||
| 234 | if (scFont)
| 0 | ||||||||||||||||||||||||
| 235 | return scFont; never executed: return scFont; | 0 | ||||||||||||||||||||||||
| 236 | QFont font(const_cast<QFontPrivate *>(this)); | - | ||||||||||||||||||||||||
| 237 | qreal pointSize = font.pointSizeF(); | - | ||||||||||||||||||||||||
| 238 | if (pointSize > 0)
| 0 | ||||||||||||||||||||||||
| 239 | font.setPointSizeF(pointSize * .7); never executed: font.setPointSizeF(pointSize * .7); | 0 | ||||||||||||||||||||||||
| 240 | else | - | ||||||||||||||||||||||||
| 241 | font.setPixelSize((font.pixelSize() * 7 + 5) / 10); never executed: font.setPixelSize((font.pixelSize() * 7 + 5) / 10); | 0 | ||||||||||||||||||||||||
| 242 | scFont = font.d.data(); | - | ||||||||||||||||||||||||
| 243 | if (scFont != this)
| 0 | ||||||||||||||||||||||||
| 244 | scFont->ref.ref(); never executed: scFont->ref.ref(); | 0 | ||||||||||||||||||||||||
| 245 | return scFont; never executed: return scFont; | 0 | ||||||||||||||||||||||||
| 246 | } | - | ||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | void QFontPrivate::resolve(uint mask, const QFontPrivate *other) | - | ||||||||||||||||||||||||
| 250 | { | - | ||||||||||||||||||||||||
| 251 | Q_ASSERT(other != 0); | - | ||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | dpi = other->dpi; | - | ||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||
| 255 | if ((mask & QFont::AllPropertiesResolved) == QFont::AllPropertiesResolved) return; never executed: return;
| 0 | ||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||
| 257 | // assign the unset-bits with the set-bits of the other font def | - | ||||||||||||||||||||||||
| 258 | if (! (mask & QFont::FamilyResolved))
| 0 | ||||||||||||||||||||||||
| 259 | request.family = other->request.family; never executed: request.family = other->request.family; | 0 | ||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | if (! (mask & QFont::StyleNameResolved))
| 0 | ||||||||||||||||||||||||
| 262 | request.styleName = other->request.styleName; never executed: request.styleName = other->request.styleName; | 0 | ||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||
| 264 | if (! (mask & QFont::SizeResolved)) {
| 0 | ||||||||||||||||||||||||
| 265 | request.pointSize = other->request.pointSize; | - | ||||||||||||||||||||||||
| 266 | request.pixelSize = other->request.pixelSize; | - | ||||||||||||||||||||||||
| 267 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | if (! (mask & QFont::StyleHintResolved))
| 0 | ||||||||||||||||||||||||
| 270 | request.styleHint = other->request.styleHint; never executed: request.styleHint = other->request.styleHint; | 0 | ||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||
| 272 | if (! (mask & QFont::StyleStrategyResolved))
| 0 | ||||||||||||||||||||||||
| 273 | request.styleStrategy = other->request.styleStrategy; never executed: request.styleStrategy = other->request.styleStrategy; | 0 | ||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||
| 275 | if (! (mask & QFont::WeightResolved))
| 0 | ||||||||||||||||||||||||
| 276 | request.weight = other->request.weight; never executed: request.weight = other->request.weight; | 0 | ||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | if (! (mask & QFont::StyleResolved))
| 0 | ||||||||||||||||||||||||
| 279 | request.style = other->request.style; never executed: request.style = other->request.style; | 0 | ||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||
| 281 | if (! (mask & QFont::FixedPitchResolved))
| 0 | ||||||||||||||||||||||||
| 282 | request.fixedPitch = other->request.fixedPitch; never executed: request.fixedPitch = other->request.fixedPitch; | 0 | ||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||
| 284 | if (! (mask & QFont::StretchResolved))
| 0 | ||||||||||||||||||||||||
| 285 | request.stretch = other->request.stretch; never executed: request.stretch = other->request.stretch; | 0 | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | if (! (mask & QFont::HintingPreferenceResolved))
| 0 | ||||||||||||||||||||||||
| 288 | request.hintingPreference = other->request.hintingPreference; never executed: request.hintingPreference = other->request.hintingPreference; | 0 | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | if (! (mask & QFont::UnderlineResolved))
| 0 | ||||||||||||||||||||||||
| 291 | underline = other->underline; never executed: underline = other->underline; | 0 | ||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | if (! (mask & QFont::OverlineResolved))
| 0 | ||||||||||||||||||||||||
| 294 | overline = other->overline; never executed: overline = other->overline; | 0 | ||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||
| 296 | if (! (mask & QFont::StrikeOutResolved))
| 0 | ||||||||||||||||||||||||
| 297 | strikeOut = other->strikeOut; never executed: strikeOut = other->strikeOut; | 0 | ||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||
| 299 | if (! (mask & QFont::KerningResolved))
| 0 | ||||||||||||||||||||||||
| 300 | kerning = other->kerning; never executed: kerning = other->kerning; | 0 | ||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | if (! (mask & QFont::LetterSpacingResolved)) {
| 0 | ||||||||||||||||||||||||
| 303 | letterSpacing = other->letterSpacing; | - | ||||||||||||||||||||||||
| 304 | letterSpacingIsAbsolute = other->letterSpacingIsAbsolute; | - | ||||||||||||||||||||||||
| 305 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 306 | if (! (mask & QFont::WordSpacingResolved))
| 0 | ||||||||||||||||||||||||
| 307 | wordSpacing = other->wordSpacing; never executed: wordSpacing = other->wordSpacing; | 0 | ||||||||||||||||||||||||
| 308 | if (! (mask & QFont::CapitalizationResolved))
| 0 | ||||||||||||||||||||||||
| 309 | capital = other->capital; never executed: capital = other->capital; | 0 | ||||||||||||||||||||||||
| 310 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||
| 313 | - | |||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||
| 315 | QFontEngineData::QFontEngineData() | - | ||||||||||||||||||||||||
| 316 | : ref(0), fontCacheId(QFontCache::instance()->id()) | - | ||||||||||||||||||||||||
| 317 | { | - | ||||||||||||||||||||||||
| 318 | memset(engines, 0, QChar::ScriptCount * sizeof(QFontEngine *)); | - | ||||||||||||||||||||||||
| 319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||
| 321 | QFontEngineData::~QFontEngineData() | - | ||||||||||||||||||||||||
| 322 | { | - | ||||||||||||||||||||||||
| 323 | Q_ASSERT(ref.load() == 0); | - | ||||||||||||||||||||||||
| 324 | for (int i = 0; i < QChar::ScriptCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 325 | if (engines[i]) {
| 0 | ||||||||||||||||||||||||
| 326 | if (!engines[i]->ref.deref())
| 0 | ||||||||||||||||||||||||
| 327 | delete engines[i]; never executed: delete engines[i]; | 0 | ||||||||||||||||||||||||
| 328 | engines[i] = 0; | - | ||||||||||||||||||||||||
| 329 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 330 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 331 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | /*! | - | ||||||||||||||||||||||||
| 337 | \class QFont | - | ||||||||||||||||||||||||
| 338 | \reentrant | - | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | \brief The QFont class specifies a font used for drawing text. | - | ||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||
| 342 | \ingroup painting | - | ||||||||||||||||||||||||
| 343 | \ingroup appearance | - | ||||||||||||||||||||||||
| 344 | \ingroup shared | - | ||||||||||||||||||||||||
| 345 | \ingroup richtext-processing | - | ||||||||||||||||||||||||
| 346 | \inmodule QtGui | - | ||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||
| 349 | When you create a QFont object you specify various attributes that | - | ||||||||||||||||||||||||
| 350 | you want the font to have. Qt will use the font with the specified | - | ||||||||||||||||||||||||
| 351 | attributes, or if no matching font exists, Qt will use the closest | - | ||||||||||||||||||||||||
| 352 | matching installed font. The attributes of the font that is | - | ||||||||||||||||||||||||
| 353 | actually used are retrievable from a QFontInfo object. If the | - | ||||||||||||||||||||||||
| 354 | window system provides an exact match exactMatch() returns \c true. | - | ||||||||||||||||||||||||
| 355 | Use QFontMetrics to get measurements, e.g. the pixel length of a | - | ||||||||||||||||||||||||
| 356 | string using QFontMetrics::width(). | - | ||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 | Note that a QGuiApplication instance must exist before a QFont can be | - | ||||||||||||||||||||||||
| 359 | used. You can set the application's default font with | - | ||||||||||||||||||||||||
| 360 | QGuiApplication::setFont(). | - | ||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||
| 362 | If a chosen font does not include all the characters that | - | ||||||||||||||||||||||||
| 363 | need to be displayed, QFont will try to find the characters in the | - | ||||||||||||||||||||||||
| 364 | nearest equivalent fonts. When a QPainter draws a character from a | - | ||||||||||||||||||||||||
| 365 | font the QFont will report whether or not it has the character; if | - | ||||||||||||||||||||||||
| 366 | it does not, QPainter will draw an unfilled square. | - | ||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | Create QFonts like this: | - | ||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | \snippet code/src_gui_text_qfont.cpp 0 | - | ||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||
| 372 | The attributes set in the constructor can also be set later, e.g. | - | ||||||||||||||||||||||||
| 373 | setFamily(), setPointSize(), setPointSizeF(), setWeight() and | - | ||||||||||||||||||||||||
| 374 | setItalic(). The remaining attributes must be set after | - | ||||||||||||||||||||||||
| 375 | contstruction, e.g. setBold(), setUnderline(), setOverline(), | - | ||||||||||||||||||||||||
| 376 | setStrikeOut() and setFixedPitch(). QFontInfo objects should be | - | ||||||||||||||||||||||||
| 377 | created \e after the font's attributes have been set. A QFontInfo | - | ||||||||||||||||||||||||
| 378 | object will not change, even if you change the font's | - | ||||||||||||||||||||||||
| 379 | attributes. The corresponding "get" functions, e.g. family(), | - | ||||||||||||||||||||||||
| 380 | pointSize(), etc., return the values that were set, even though | - | ||||||||||||||||||||||||
| 381 | the values used may differ. The actual values are available from a | - | ||||||||||||||||||||||||
| 382 | QFontInfo object. | - | ||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||
| 384 | If the requested font family is unavailable you can influence the | - | ||||||||||||||||||||||||
| 385 | \l{#fontmatching}{font matching algorithm} by choosing a | - | ||||||||||||||||||||||||
| 386 | particular \l{QFont::StyleHint} and \l{QFont::StyleStrategy} with | - | ||||||||||||||||||||||||
| 387 | setStyleHint(). The default family (corresponding to the current | - | ||||||||||||||||||||||||
| 388 | style hint) is returned by defaultFamily(). | - | ||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | The font-matching algorithm has a lastResortFamily() and | - | ||||||||||||||||||||||||
| 391 | lastResortFont() in cases where a suitable match cannot be found. | - | ||||||||||||||||||||||||
| 392 | You can provide substitutions for font family names using | - | ||||||||||||||||||||||||
| 393 | insertSubstitution() and insertSubstitutions(). Substitutions can | - | ||||||||||||||||||||||||
| 394 | be removed with removeSubstitutions(). Use substitute() to retrieve | - | ||||||||||||||||||||||||
| 395 | a family's first substitute, or the family name itself if it has | - | ||||||||||||||||||||||||
| 396 | no substitutes. Use substitutes() to retrieve a list of a family's | - | ||||||||||||||||||||||||
| 397 | substitutes (which may be empty). | - | ||||||||||||||||||||||||
| 398 | - | |||||||||||||||||||||||||
| 399 | Every QFont has a key() which you can use, for example, as the key | - | ||||||||||||||||||||||||
| 400 | in a cache or dictionary. If you want to store a user's font | - | ||||||||||||||||||||||||
| 401 | preferences you could use QSettings, writing the font information | - | ||||||||||||||||||||||||
| 402 | with toString() and reading it back with fromString(). The | - | ||||||||||||||||||||||||
| 403 | operator<<() and operator>>() functions are also available, but | - | ||||||||||||||||||||||||
| 404 | they work on a data stream. | - | ||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||
| 406 | It is possible to set the height of characters shown on the screen | - | ||||||||||||||||||||||||
| 407 | to a specified number of pixels with setPixelSize(); however using | - | ||||||||||||||||||||||||
| 408 | setPointSize() has a similar effect and provides device | - | ||||||||||||||||||||||||
| 409 | independence. | - | ||||||||||||||||||||||||
| 410 | - | |||||||||||||||||||||||||
| 411 | Loading fonts can be expensive, especially on X11. QFont contains | - | ||||||||||||||||||||||||
| 412 | extensive optimizations to make the copying of QFont objects fast, | - | ||||||||||||||||||||||||
| 413 | and to cache the results of the slow window system functions it | - | ||||||||||||||||||||||||
| 414 | depends upon. | - | ||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||
| 416 | \target fontmatching | - | ||||||||||||||||||||||||
| 417 | The font matching algorithm works as follows: | - | ||||||||||||||||||||||||
| 418 | \list 1 | - | ||||||||||||||||||||||||
| 419 | \li The specified font family is searched for. | - | ||||||||||||||||||||||||
| 420 | \li If not found, the styleHint() is used to select a replacement | - | ||||||||||||||||||||||||
| 421 | family. | - | ||||||||||||||||||||||||
| 422 | \li Each replacement font family is searched for. | - | ||||||||||||||||||||||||
| 423 | \li If none of these are found or there was no styleHint(), "helvetica" | - | ||||||||||||||||||||||||
| 424 | will be searched for. | - | ||||||||||||||||||||||||
| 425 | \li If "helvetica" isn't found Qt will try the lastResortFamily(). | - | ||||||||||||||||||||||||
| 426 | \li If the lastResortFamily() isn't found Qt will try the | - | ||||||||||||||||||||||||
| 427 | lastResortFont() which will always return a name of some kind. | - | ||||||||||||||||||||||||
| 428 | \endlist | - | ||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||
| 430 | Note that the actual font matching algorithm varies from platform to platform. | - | ||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||
| 432 | In Windows a request for the "Courier" font is automatically changed to | - | ||||||||||||||||||||||||
| 433 | "Courier New", an improved version of Courier that allows for smooth scaling. | - | ||||||||||||||||||||||||
| 434 | The older "Courier" bitmap font can be selected by setting the PreferBitmap | - | ||||||||||||||||||||||||
| 435 | style strategy (see setStyleStrategy()). | - | ||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | Once a font is found, the remaining attributes are matched in order of | - | ||||||||||||||||||||||||
| 438 | priority: | - | ||||||||||||||||||||||||
| 439 | \list 1 | - | ||||||||||||||||||||||||
| 440 | \li fixedPitch() | - | ||||||||||||||||||||||||
| 441 | \li pointSize() (see below) | - | ||||||||||||||||||||||||
| 442 | \li weight() | - | ||||||||||||||||||||||||
| 443 | \li style() | - | ||||||||||||||||||||||||
| 444 | \endlist | - | ||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | If you have a font which matches on family, even if none of the | - | ||||||||||||||||||||||||
| 447 | other attributes match, this font will be chosen in preference to | - | ||||||||||||||||||||||||
| 448 | a font which doesn't match on family but which does match on the | - | ||||||||||||||||||||||||
| 449 | other attributes. This is because font family is the dominant | - | ||||||||||||||||||||||||
| 450 | search criteria. | - | ||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||
| 452 | The point size is defined to match if it is within 20% of the | - | ||||||||||||||||||||||||
| 453 | requested point size. When several fonts match and are only | - | ||||||||||||||||||||||||
| 454 | distinguished by point size, the font with the closest point size | - | ||||||||||||||||||||||||
| 455 | to the one requested will be chosen. | - | ||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | The actual family, font size, weight and other font attributes | - | ||||||||||||||||||||||||
| 458 | used for drawing text will depend on what's available for the | - | ||||||||||||||||||||||||
| 459 | chosen family under the window system. A QFontInfo object can be | - | ||||||||||||||||||||||||
| 460 | used to determine the actual values used for drawing the text. | - | ||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||
| 462 | Examples: | - | ||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||
| 464 | \snippet code/src_gui_text_qfont.cpp 1 | - | ||||||||||||||||||||||||
| 465 | If you had both an Adobe and a Cronyx Helvetica, you might get | - | ||||||||||||||||||||||||
| 466 | either. | - | ||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||
| 468 | \snippet code/src_gui_text_qfont.cpp 2 | - | ||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | You can specify the foundry you want in the family name. The font f | - | ||||||||||||||||||||||||
| 471 | in the above example will be set to "Helvetica | - | ||||||||||||||||||||||||
| 472 | [Cronyx]". | - | ||||||||||||||||||||||||
| 473 | - | |||||||||||||||||||||||||
| 474 | To determine the attributes of the font actually used in the window | - | ||||||||||||||||||||||||
| 475 | system, use a QFontInfo object, e.g. | - | ||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | \snippet code/src_gui_text_qfont.cpp 3 | - | ||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | To find out font metrics use a QFontMetrics object, e.g. | - | ||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | \snippet code/src_gui_text_qfont.cpp 4 | - | ||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||
| 483 | For more general information on fonts, see the | - | ||||||||||||||||||||||||
| 484 | \l{comp.fonts FAQ}{comp.fonts FAQ}. | - | ||||||||||||||||||||||||
| 485 | Information on encodings can be found from | - | ||||||||||||||||||||||||
| 486 | \l{Roman Czyborra's} page. | - | ||||||||||||||||||||||||
| 487 | - | |||||||||||||||||||||||||
| 488 | \sa QFontMetrics, QFontInfo, QFontDatabase, {Character Map Example} | - | ||||||||||||||||||||||||
| 489 | */ | - | ||||||||||||||||||||||||
| 490 | - | |||||||||||||||||||||||||
| 491 | /*! | - | ||||||||||||||||||||||||
| 492 | \internal | - | ||||||||||||||||||||||||
| 493 | \enum QFont::ResolveProperties | - | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | This enum describes the properties of a QFont that can be set on a font | - | ||||||||||||||||||||||||
| 496 | individually and then considered resolved. | - | ||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||
| 498 | \value FamilyResolved | - | ||||||||||||||||||||||||
| 499 | \value SizeResolved | - | ||||||||||||||||||||||||
| 500 | \value StyleHintResolved | - | ||||||||||||||||||||||||
| 501 | \value StyleStrategyResolved | - | ||||||||||||||||||||||||
| 502 | \value WeightResolved | - | ||||||||||||||||||||||||
| 503 | \value StyleResolved | - | ||||||||||||||||||||||||
| 504 | \value UnderlineResolved | - | ||||||||||||||||||||||||
| 505 | \value OverlineResolved | - | ||||||||||||||||||||||||
| 506 | \value StrikeOutResolved | - | ||||||||||||||||||||||||
| 507 | \value FixedPitchResolved | - | ||||||||||||||||||||||||
| 508 | \value StretchResolved | - | ||||||||||||||||||||||||
| 509 | \value KerningResolved | - | ||||||||||||||||||||||||
| 510 | \value CapitalizationResolved | - | ||||||||||||||||||||||||
| 511 | \value LetterSpacingResolved | - | ||||||||||||||||||||||||
| 512 | \value WordSpacingResolved | - | ||||||||||||||||||||||||
| 513 | \value CompletelyResolved | - | ||||||||||||||||||||||||
| 514 | */ | - | ||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||
| 516 | /*! | - | ||||||||||||||||||||||||
| 517 | \enum QFont::Style | - | ||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | This enum describes the different styles of glyphs that are used to | - | ||||||||||||||||||||||||
| 520 | display text. | - | ||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||
| 522 | \value StyleNormal Normal glyphs used in unstyled text. | - | ||||||||||||||||||||||||
| 523 | \value StyleItalic Italic glyphs that are specifically designed for | - | ||||||||||||||||||||||||
| 524 | the purpose of representing italicized text. | - | ||||||||||||||||||||||||
| 525 | \value StyleOblique Glyphs with an italic appearance that are typically | - | ||||||||||||||||||||||||
| 526 | based on the unstyled glyphs, but are not fine-tuned | - | ||||||||||||||||||||||||
| 527 | for the purpose of representing italicized text. | - | ||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||
| 529 | \sa Weight | - | ||||||||||||||||||||||||
| 530 | */ | - | ||||||||||||||||||||||||
| 531 | - | |||||||||||||||||||||||||
| 532 | /*! | - | ||||||||||||||||||||||||
| 533 | \fn QFont &QFont::operator=(QFont &&other) | - | ||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||
| 535 | Move-assigns \a other to this QFont instance. | - | ||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||
| 537 | \since 5.2 | - | ||||||||||||||||||||||||
| 538 | */ | - | ||||||||||||||||||||||||
| 539 | - | |||||||||||||||||||||||||
| 540 | /*! | - | ||||||||||||||||||||||||
| 541 | Constructs a font from \a font for use on the paint device \a pd. | - | ||||||||||||||||||||||||
| 542 | */ | - | ||||||||||||||||||||||||
| 543 | QFont::QFont(const QFont &font, QPaintDevice *pd) | - | ||||||||||||||||||||||||
| 544 | : resolve_mask(font.resolve_mask) | - | ||||||||||||||||||||||||
| 545 | { | - | ||||||||||||||||||||||||
| 546 | Q_ASSERT(pd != 0); | - | ||||||||||||||||||||||||
| 547 | int dpi = pd->logicalDpiY(); | - | ||||||||||||||||||||||||
| 548 | const int screen = 0; | - | ||||||||||||||||||||||||
| 549 | if (font.d->dpi != dpi || font.d->screen != screen ) {
| 0 | ||||||||||||||||||||||||
| 550 | d = new QFontPrivate(*font.d); | - | ||||||||||||||||||||||||
| 551 | d->dpi = dpi; | - | ||||||||||||||||||||||||
| 552 | d->screen = screen; | - | ||||||||||||||||||||||||
| 553 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 554 | d = font.d.data(); | - | ||||||||||||||||||||||||
| 555 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 556 | } | - | ||||||||||||||||||||||||
| 557 | - | |||||||||||||||||||||||||
| 558 | /*! | - | ||||||||||||||||||||||||
| 559 | \internal | - | ||||||||||||||||||||||||
| 560 | */ | - | ||||||||||||||||||||||||
| 561 | QFont::QFont(QFontPrivate *data) | - | ||||||||||||||||||||||||
| 562 | : d(data), resolve_mask(QFont::AllPropertiesResolved) | - | ||||||||||||||||||||||||
| 563 | { | - | ||||||||||||||||||||||||
| 564 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||
| 566 | /*! \internal | - | ||||||||||||||||||||||||
| 567 | Detaches the font object from common font data. | - | ||||||||||||||||||||||||
| 568 | */ | - | ||||||||||||||||||||||||
| 569 | void QFont::detach() | - | ||||||||||||||||||||||||
| 570 | { | - | ||||||||||||||||||||||||
| 571 | if (d->ref.load() == 1) {
| 0 | ||||||||||||||||||||||||
| 572 | if (d->engineData && !d->engineData->ref.deref())
| 0 | ||||||||||||||||||||||||
| 573 | delete d->engineData; never executed: delete d->engineData; | 0 | ||||||||||||||||||||||||
| 574 | d->engineData = 0; | - | ||||||||||||||||||||||||
| 575 | if (d->scFont && d->scFont != d.data())
| 0 | ||||||||||||||||||||||||
| 576 | d->scFont->ref.deref(); never executed: d->scFont->ref.deref(); | 0 | ||||||||||||||||||||||||
| 577 | d->scFont = 0; | - | ||||||||||||||||||||||||
| 578 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 579 | } | - | ||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||
| 581 | d.detach(); | - | ||||||||||||||||||||||||
| 582 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 583 | - | |||||||||||||||||||||||||
| 584 | /*! | - | ||||||||||||||||||||||||
| 585 | \internal | - | ||||||||||||||||||||||||
| 586 | Detaches the font object from common font attributes data. | - | ||||||||||||||||||||||||
| 587 | Call this instead of QFont::detach() if the only font attributes data | - | ||||||||||||||||||||||||
| 588 | has been changed (underline, letterSpacing, kerning, etc.). | - | ||||||||||||||||||||||||
| 589 | */ | - | ||||||||||||||||||||||||
| 590 | void QFontPrivate::detachButKeepEngineData(QFont *font) | - | ||||||||||||||||||||||||
| 591 | { | - | ||||||||||||||||||||||||
| 592 | if (font->d->ref.load() == 1)
| 0 | ||||||||||||||||||||||||
| 593 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 594 | - | |||||||||||||||||||||||||
| 595 | QFontEngineData *engineData = font->d->engineData; | - | ||||||||||||||||||||||||
| 596 | if (engineData)
| 0 | ||||||||||||||||||||||||
| 597 | engineData->ref.ref(); never executed: engineData->ref.ref(); | 0 | ||||||||||||||||||||||||
| 598 | font->d.detach(); | - | ||||||||||||||||||||||||
| 599 | font->d->engineData = engineData; | - | ||||||||||||||||||||||||
| 600 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | /*! | - | ||||||||||||||||||||||||
| 603 | Constructs a font object that uses the application's default font. | - | ||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||
| 605 | \sa QGuiApplication::setFont(), QGuiApplication::font() | - | ||||||||||||||||||||||||
| 606 | */ | - | ||||||||||||||||||||||||
| 607 | QFont::QFont() | - | ||||||||||||||||||||||||
| 608 | : d(QGuiApplicationPrivate::instance() ? QGuiApplication::font().d.data() : new QFontPrivate()), resolve_mask(0) | - | ||||||||||||||||||||||||
| 609 | { | - | ||||||||||||||||||||||||
| 610 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||
| 612 | /*! | - | ||||||||||||||||||||||||
| 613 | Constructs a font object with the specified \a family, \a | - | ||||||||||||||||||||||||
| 614 | pointSize, \a weight and \a italic settings. | - | ||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||
| 616 | If \a pointSize is zero or negative, the point size of the font | - | ||||||||||||||||||||||||
| 617 | is set to a system-dependent default value. Generally, this is | - | ||||||||||||||||||||||||
| 618 | 12 points. | - | ||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | The \a family name may optionally also include a foundry name, | - | ||||||||||||||||||||||||
| 621 | e.g. "Helvetica [Cronyx]". If the \a family is | - | ||||||||||||||||||||||||
| 622 | available from more than one foundry and the foundry isn't | - | ||||||||||||||||||||||||
| 623 | specified, an arbitrary foundry is chosen. If the family isn't | - | ||||||||||||||||||||||||
| 624 | available a family will be set using the \l{QFont}{font matching} | - | ||||||||||||||||||||||||
| 625 | algorithm. | - | ||||||||||||||||||||||||
| 626 | - | |||||||||||||||||||||||||
| 627 | \sa Weight, setFamily(), setPointSize(), setWeight(), setItalic(), | - | ||||||||||||||||||||||||
| 628 | setStyleHint(), QGuiApplication::font() | - | ||||||||||||||||||||||||
| 629 | */ | - | ||||||||||||||||||||||||
| 630 | QFont::QFont(const QString &family, int pointSize, int weight, bool italic) | - | ||||||||||||||||||||||||
| 631 | : d(new QFontPrivate()), resolve_mask(QFont::FamilyResolved) | - | ||||||||||||||||||||||||
| 632 | { | - | ||||||||||||||||||||||||
| 633 | if (pointSize <= 0) {
| 0 | ||||||||||||||||||||||||
| 634 | pointSize = 12; | - | ||||||||||||||||||||||||
| 635 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 636 | resolve_mask |= QFont::SizeResolved; | - | ||||||||||||||||||||||||
| 637 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 638 | - | |||||||||||||||||||||||||
| 639 | if (weight < 0) {
| 0 | ||||||||||||||||||||||||
| 640 | weight = Normal; | - | ||||||||||||||||||||||||
| 641 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 642 | resolve_mask |= QFont::WeightResolved | QFont::StyleResolved; | - | ||||||||||||||||||||||||
| 643 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||
| 645 | if (italic)
| 0 | ||||||||||||||||||||||||
| 646 | resolve_mask |= QFont::StyleResolved; never executed: resolve_mask |= QFont::StyleResolved; | 0 | ||||||||||||||||||||||||
| 647 | - | |||||||||||||||||||||||||
| 648 | d->request.family = family; | - | ||||||||||||||||||||||||
| 649 | d->request.pointSize = qreal(pointSize); | - | ||||||||||||||||||||||||
| 650 | d->request.pixelSize = -1; | - | ||||||||||||||||||||||||
| 651 | d->request.weight = weight; | - | ||||||||||||||||||||||||
| 652 | d->request.style = italic ? QFont::StyleItalic : QFont::StyleNormal;
| 0 | ||||||||||||||||||||||||
| 653 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 654 | - | |||||||||||||||||||||||||
| 655 | /*! | - | ||||||||||||||||||||||||
| 656 | Constructs a font that is a copy of \a font. | - | ||||||||||||||||||||||||
| 657 | */ | - | ||||||||||||||||||||||||
| 658 | QFont::QFont(const QFont &font) | - | ||||||||||||||||||||||||
| 659 | : d(font.d.data()), resolve_mask(font.resolve_mask) | - | ||||||||||||||||||||||||
| 660 | { | - | ||||||||||||||||||||||||
| 661 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||
| 663 | /*! | - | ||||||||||||||||||||||||
| 664 | Destroys the font object and frees all allocated resources. | - | ||||||||||||||||||||||||
| 665 | */ | - | ||||||||||||||||||||||||
| 666 | QFont::~QFont() | - | ||||||||||||||||||||||||
| 667 | { | - | ||||||||||||||||||||||||
| 668 | } | - | ||||||||||||||||||||||||
| 669 | - | |||||||||||||||||||||||||
| 670 | /*! | - | ||||||||||||||||||||||||
| 671 | Assigns \a font to this font and returns a reference to it. | - | ||||||||||||||||||||||||
| 672 | */ | - | ||||||||||||||||||||||||
| 673 | QFont &QFont::operator=(const QFont &font) | - | ||||||||||||||||||||||||
| 674 | { | - | ||||||||||||||||||||||||
| 675 | d = font.d.data(); | - | ||||||||||||||||||||||||
| 676 | resolve_mask = font.resolve_mask; | - | ||||||||||||||||||||||||
| 677 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
| 678 | } | - | ||||||||||||||||||||||||
| 679 | - | |||||||||||||||||||||||||
| 680 | /*! | - | ||||||||||||||||||||||||
| 681 | \fn void QFont::swap(QFont &other) | - | ||||||||||||||||||||||||
| 682 | \since 5.0 | - | ||||||||||||||||||||||||
| 683 | - | |||||||||||||||||||||||||
| 684 | Swaps this font instance with \a other. This function is very fast | - | ||||||||||||||||||||||||
| 685 | and never fails. | - | ||||||||||||||||||||||||
| 686 | */ | - | ||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||
| 688 | /*! | - | ||||||||||||||||||||||||
| 689 | Returns the requested font family name, i.e. the name set in the | - | ||||||||||||||||||||||||
| 690 | constructor or the last setFont() call. | - | ||||||||||||||||||||||||
| 691 | - | |||||||||||||||||||||||||
| 692 | \sa setFamily(), substitutes(), substitute() | - | ||||||||||||||||||||||||
| 693 | */ | - | ||||||||||||||||||||||||
| 694 | QString QFont::family() const | - | ||||||||||||||||||||||||
| 695 | { | - | ||||||||||||||||||||||||
| 696 | return d->request.family; never executed: return d->request.family; | 0 | ||||||||||||||||||||||||
| 697 | } | - | ||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||
| 699 | /*! | - | ||||||||||||||||||||||||
| 700 | Sets the family name of the font. The name is case insensitive and | - | ||||||||||||||||||||||||
| 701 | may include a foundry name. | - | ||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | The \a family name may optionally also include a foundry name, | - | ||||||||||||||||||||||||
| 704 | e.g. "Helvetica [Cronyx]". If the \a family is | - | ||||||||||||||||||||||||
| 705 | available from more than one foundry and the foundry isn't | - | ||||||||||||||||||||||||
| 706 | specified, an arbitrary foundry is chosen. If the family isn't | - | ||||||||||||||||||||||||
| 707 | available a family will be set using the \l{QFont}{font matching} | - | ||||||||||||||||||||||||
| 708 | algorithm. | - | ||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | \sa family(), setStyleHint(), QFontInfo | - | ||||||||||||||||||||||||
| 711 | */ | - | ||||||||||||||||||||||||
| 712 | void QFont::setFamily(const QString &family) | - | ||||||||||||||||||||||||
| 713 | { | - | ||||||||||||||||||||||||
| 714 | if ((resolve_mask & QFont::FamilyResolved) && d->request.family == family)
| 0 | ||||||||||||||||||||||||
| 715 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 716 | - | |||||||||||||||||||||||||
| 717 | detach(); | - | ||||||||||||||||||||||||
| 718 | - | |||||||||||||||||||||||||
| 719 | d->request.family = family; | - | ||||||||||||||||||||||||
| 720 | - | |||||||||||||||||||||||||
| 721 | resolve_mask |= QFont::FamilyResolved; | - | ||||||||||||||||||||||||
| 722 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 723 | - | |||||||||||||||||||||||||
| 724 | /*! | - | ||||||||||||||||||||||||
| 725 | \since 4.8 | - | ||||||||||||||||||||||||
| 726 | - | |||||||||||||||||||||||||
| 727 | Returns the requested font style name, it will be used to match the | - | ||||||||||||||||||||||||
| 728 | font with irregular styles (that can't be normalized in other style | - | ||||||||||||||||||||||||
| 729 | properties). It depends on system font support, thus only works for | - | ||||||||||||||||||||||||
| 730 | \macos and X11 so far. On Windows irregular styles will be added | - | ||||||||||||||||||||||||
| 731 | as separate font families so there is no need for this. | - | ||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||
| 733 | \sa setFamily(), setStyle() | - | ||||||||||||||||||||||||
| 734 | */ | - | ||||||||||||||||||||||||
| 735 | QString QFont::styleName() const | - | ||||||||||||||||||||||||
| 736 | { | - | ||||||||||||||||||||||||
| 737 | return d->request.styleName; never executed: return d->request.styleName; | 0 | ||||||||||||||||||||||||
| 738 | } | - | ||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||
| 740 | /*! | - | ||||||||||||||||||||||||
| 741 | \since 4.8 | - | ||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||
| 743 | Sets the style name of the font to \a styleName. When set, other style properties | - | ||||||||||||||||||||||||
| 744 | like \l style() and \l weight() will be ignored for font matching. | - | ||||||||||||||||||||||||
| 745 | - | |||||||||||||||||||||||||
| 746 | \sa styleName() | - | ||||||||||||||||||||||||
| 747 | */ | - | ||||||||||||||||||||||||
| 748 | void QFont::setStyleName(const QString &styleName) | - | ||||||||||||||||||||||||
| 749 | { | - | ||||||||||||||||||||||||
| 750 | if ((resolve_mask & QFont::StyleNameResolved) && d->request.styleName == styleName)
| 0 | ||||||||||||||||||||||||
| 751 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | detach(); | - | ||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | d->request.styleName = styleName; | - | ||||||||||||||||||||||||
| 756 | resolve_mask |= QFont::StyleNameResolved; | - | ||||||||||||||||||||||||
| 757 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||
| 759 | /*! | - | ||||||||||||||||||||||||
| 760 | Returns the point size of the font. Returns -1 if the font size | - | ||||||||||||||||||||||||
| 761 | was specified in pixels. | - | ||||||||||||||||||||||||
| 762 | - | |||||||||||||||||||||||||
| 763 | \sa setPointSize(), pointSizeF() | - | ||||||||||||||||||||||||
| 764 | */ | - | ||||||||||||||||||||||||
| 765 | int QFont::pointSize() const | - | ||||||||||||||||||||||||
| 766 | { | - | ||||||||||||||||||||||||
| 767 | return qRound(d->request.pointSize); never executed: return qRound(d->request.pointSize); | 0 | ||||||||||||||||||||||||
| 768 | } | - | ||||||||||||||||||||||||
| 769 | - | |||||||||||||||||||||||||
| 770 | /*! | - | ||||||||||||||||||||||||
| 771 | \since 4.8 | - | ||||||||||||||||||||||||
| 772 | - | |||||||||||||||||||||||||
| 773 | \enum QFont::HintingPreference | - | ||||||||||||||||||||||||
| 774 | - | |||||||||||||||||||||||||
| 775 | This enum describes the different levels of hinting that can be applied | - | ||||||||||||||||||||||||
| 776 | to glyphs to improve legibility on displays where it might be warranted | - | ||||||||||||||||||||||||
| 777 | by the density of pixels. | - | ||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||
| 779 | \value PreferDefaultHinting Use the default hinting level for the target platform. | - | ||||||||||||||||||||||||
| 780 | \value PreferNoHinting If possible, render text without hinting the outlines | - | ||||||||||||||||||||||||
| 781 | of the glyphs. The text layout will be typographically accurate and | - | ||||||||||||||||||||||||
| 782 | scalable, using the same metrics as are used e.g. when printing. | - | ||||||||||||||||||||||||
| 783 | \value PreferVerticalHinting If possible, render text with no horizontal hinting, | - | ||||||||||||||||||||||||
| 784 | but align glyphs to the pixel grid in the vertical direction. The text will appear | - | ||||||||||||||||||||||||
| 785 | crisper on displays where the density is too low to give an accurate rendering | - | ||||||||||||||||||||||||
| 786 | of the glyphs. But since the horizontal metrics of the glyphs are unhinted, the text's | - | ||||||||||||||||||||||||
| 787 | layout will be scalable to higher density devices (such as printers) without impacting | - | ||||||||||||||||||||||||
| 788 | details such as line breaks. | - | ||||||||||||||||||||||||
| 789 | \value PreferFullHinting If possible, render text with hinting in both horizontal and | - | ||||||||||||||||||||||||
| 790 | vertical directions. The text will be altered to optimize legibility on the target | - | ||||||||||||||||||||||||
| 791 | device, but since the metrics will depend on the target size of the text, the positions | - | ||||||||||||||||||||||||
| 792 | of glyphs, line breaks, and other typographical detail will not scale, meaning that a | - | ||||||||||||||||||||||||
| 793 | text layout may look different on devices with different pixel densities. | - | ||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||
| 795 | Please note that this enum only describes a preference, as the full range of hinting levels | - | ||||||||||||||||||||||||
| 796 | are not supported on all of Qt's supported platforms. The following table details the effect | - | ||||||||||||||||||||||||
| 797 | of a given hinting preference on a selected set of target platforms. | - | ||||||||||||||||||||||||
| 798 | - | |||||||||||||||||||||||||
| 799 | \table | - | ||||||||||||||||||||||||
| 800 | \header | - | ||||||||||||||||||||||||
| 801 | \li | - | ||||||||||||||||||||||||
| 802 | \li PreferDefaultHinting | - | ||||||||||||||||||||||||
| 803 | \li PreferNoHinting | - | ||||||||||||||||||||||||
| 804 | \li PreferVerticalHinting | - | ||||||||||||||||||||||||
| 805 | \li PreferFullHinting | - | ||||||||||||||||||||||||
| 806 | \row | - | ||||||||||||||||||||||||
| 807 | \li Windows Vista (w/o Platform Update) and earlier | - | ||||||||||||||||||||||||
| 808 | \li Full hinting | - | ||||||||||||||||||||||||
| 809 | \li Full hinting | - | ||||||||||||||||||||||||
| 810 | \li Full hinting | - | ||||||||||||||||||||||||
| 811 | \li Full hinting | - | ||||||||||||||||||||||||
| 812 | \row | - | ||||||||||||||||||||||||
| 813 | \li Windows 7 and Windows Vista (w/Platform Update) and DirectWrite enabled in Qt | - | ||||||||||||||||||||||||
| 814 | \li Full hinting | - | ||||||||||||||||||||||||
| 815 | \li Vertical hinting | - | ||||||||||||||||||||||||
| 816 | \li Vertical hinting | - | ||||||||||||||||||||||||
| 817 | \li Full hinting | - | ||||||||||||||||||||||||
| 818 | \row | - | ||||||||||||||||||||||||
| 819 | \li FreeType | - | ||||||||||||||||||||||||
| 820 | \li Operating System setting | - | ||||||||||||||||||||||||
| 821 | \li No hinting | - | ||||||||||||||||||||||||
| 822 | \li Vertical hinting (light) | - | ||||||||||||||||||||||||
| 823 | \li Full hinting | - | ||||||||||||||||||||||||
| 824 | \row | - | ||||||||||||||||||||||||
| 825 | \li Cocoa on \macos | - | ||||||||||||||||||||||||
| 826 | \li No hinting | - | ||||||||||||||||||||||||
| 827 | \li No hinting | - | ||||||||||||||||||||||||
| 828 | \li No hinting | - | ||||||||||||||||||||||||
| 829 | \li No hinting | - | ||||||||||||||||||||||||
| 830 | \endtable | - | ||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||
| 832 | \note Please be aware that altering the hinting preference on Windows is available through | - | ||||||||||||||||||||||||
| 833 | the DirectWrite font engine. This is available on Windows Vista after installing the platform | - | ||||||||||||||||||||||||
| 834 | update, and on Windows 7. In order to use this extension, configure Qt using -directwrite. | - | ||||||||||||||||||||||||
| 835 | The target application will then depend on the availability of DirectWrite on the target | - | ||||||||||||||||||||||||
| 836 | system. | - | ||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||
| 838 | */ | - | ||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||
| 840 | /*! | - | ||||||||||||||||||||||||
| 841 | \since 4.8 | - | ||||||||||||||||||||||||
| 842 | - | |||||||||||||||||||||||||
| 843 | Set the preference for the hinting level of the glyphs to \a hintingPreference. This is a hint | - | ||||||||||||||||||||||||
| 844 | to the underlying font rendering system to use a certain level of hinting, and has varying | - | ||||||||||||||||||||||||
| 845 | support across platforms. See the table in the documentation for QFont::HintingPreference for | - | ||||||||||||||||||||||||
| 846 | more details. | - | ||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||
| 848 | The default hinting preference is QFont::PreferDefaultHinting. | - | ||||||||||||||||||||||||
| 849 | */ | - | ||||||||||||||||||||||||
| 850 | void QFont::setHintingPreference(HintingPreference hintingPreference) | - | ||||||||||||||||||||||||
| 851 | { | - | ||||||||||||||||||||||||
| 852 | if ((resolve_mask & QFont::HintingPreferenceResolved) && d->request.hintingPreference == hintingPreference)
| 0 | ||||||||||||||||||||||||
| 853 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 854 | - | |||||||||||||||||||||||||
| 855 | detach(); | - | ||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||
| 857 | d->request.hintingPreference = hintingPreference; | - | ||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||
| 859 | resolve_mask |= QFont::HintingPreferenceResolved; | - | ||||||||||||||||||||||||
| 860 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 861 | - | |||||||||||||||||||||||||
| 862 | /*! | - | ||||||||||||||||||||||||
| 863 | \since 4.8 | - | ||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | Returns the currently preferred hinting level for glyphs rendered with this font. | - | ||||||||||||||||||||||||
| 866 | */ | - | ||||||||||||||||||||||||
| 867 | QFont::HintingPreference QFont::hintingPreference() const | - | ||||||||||||||||||||||||
| 868 | { | - | ||||||||||||||||||||||||
| 869 | return QFont::HintingPreference(d->request.hintingPreference); never executed: return QFont::HintingPreference(d->request.hintingPreference); | 0 | ||||||||||||||||||||||||
| 870 | } | - | ||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||
| 872 | /*! | - | ||||||||||||||||||||||||
| 873 | Sets the point size to \a pointSize. The point size must be | - | ||||||||||||||||||||||||
| 874 | greater than zero. | - | ||||||||||||||||||||||||
| 875 | - | |||||||||||||||||||||||||
| 876 | \sa pointSize(), setPointSizeF() | - | ||||||||||||||||||||||||
| 877 | */ | - | ||||||||||||||||||||||||
| 878 | void QFont::setPointSize(int pointSize) | - | ||||||||||||||||||||||||
| 879 | { | - | ||||||||||||||||||||||||
| 880 | if (pointSize <= 0) {
| 0 | ||||||||||||||||||||||||
| 881 | qWarning("QFont::setPointSize: Point size <= 0 (%d), must be greater than 0", pointSize); | - | ||||||||||||||||||||||||
| 882 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 883 | } | - | ||||||||||||||||||||||||
| 884 | - | |||||||||||||||||||||||||
| 885 | if ((resolve_mask & QFont::SizeResolved) && d->request.pointSize == qreal(pointSize))
| 0 | ||||||||||||||||||||||||
| 886 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||
| 888 | detach(); | - | ||||||||||||||||||||||||
| 889 | - | |||||||||||||||||||||||||
| 890 | d->request.pointSize = qreal(pointSize); | - | ||||||||||||||||||||||||
| 891 | d->request.pixelSize = -1; | - | ||||||||||||||||||||||||
| 892 | - | |||||||||||||||||||||||||
| 893 | resolve_mask |= QFont::SizeResolved; | - | ||||||||||||||||||||||||
| 894 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 895 | - | |||||||||||||||||||||||||
| 896 | /*! | - | ||||||||||||||||||||||||
| 897 | Sets the point size to \a pointSize. The point size must be | - | ||||||||||||||||||||||||
| 898 | greater than zero. The requested precision may not be achieved on | - | ||||||||||||||||||||||||
| 899 | all platforms. | - | ||||||||||||||||||||||||
| 900 | - | |||||||||||||||||||||||||
| 901 | \sa pointSizeF(), setPointSize(), setPixelSize() | - | ||||||||||||||||||||||||
| 902 | */ | - | ||||||||||||||||||||||||
| 903 | void QFont::setPointSizeF(qreal pointSize) | - | ||||||||||||||||||||||||
| 904 | { | - | ||||||||||||||||||||||||
| 905 | if (pointSize <= 0) {
| 0 | ||||||||||||||||||||||||
| 906 | qWarning("QFont::setPointSizeF: Point size <= 0 (%f), must be greater than 0", pointSize); | - | ||||||||||||||||||||||||
| 907 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 908 | } | - | ||||||||||||||||||||||||
| 909 | - | |||||||||||||||||||||||||
| 910 | if ((resolve_mask & QFont::SizeResolved) && d->request.pointSize == pointSize)
| 0 | ||||||||||||||||||||||||
| 911 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 912 | - | |||||||||||||||||||||||||
| 913 | detach(); | - | ||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||
| 915 | d->request.pointSize = pointSize; | - | ||||||||||||||||||||||||
| 916 | d->request.pixelSize = -1; | - | ||||||||||||||||||||||||
| 917 | - | |||||||||||||||||||||||||
| 918 | resolve_mask |= QFont::SizeResolved; | - | ||||||||||||||||||||||||
| 919 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||
| 921 | /*! | - | ||||||||||||||||||||||||
| 922 | Returns the point size of the font. Returns -1 if the font size was | - | ||||||||||||||||||||||||
| 923 | specified in pixels. | - | ||||||||||||||||||||||||
| 924 | - | |||||||||||||||||||||||||
| 925 | \sa pointSize(), setPointSizeF(), pixelSize(), QFontInfo::pointSize(), QFontInfo::pixelSize() | - | ||||||||||||||||||||||||
| 926 | */ | - | ||||||||||||||||||||||||
| 927 | qreal QFont::pointSizeF() const | - | ||||||||||||||||||||||||
| 928 | { | - | ||||||||||||||||||||||||
| 929 | return d->request.pointSize; never executed: return d->request.pointSize; | 0 | ||||||||||||||||||||||||
| 930 | } | - | ||||||||||||||||||||||||
| 931 | - | |||||||||||||||||||||||||
| 932 | /*! | - | ||||||||||||||||||||||||
| 933 | Sets the font size to \a pixelSize pixels. | - | ||||||||||||||||||||||||
| 934 | - | |||||||||||||||||||||||||
| 935 | Using this function makes the font device dependent. Use | - | ||||||||||||||||||||||||
| 936 | setPointSize() or setPointSizeF() to set the size of the font | - | ||||||||||||||||||||||||
| 937 | in a device independent manner. | - | ||||||||||||||||||||||||
| 938 | - | |||||||||||||||||||||||||
| 939 | \sa pixelSize() | - | ||||||||||||||||||||||||
| 940 | */ | - | ||||||||||||||||||||||||
| 941 | void QFont::setPixelSize(int pixelSize) | - | ||||||||||||||||||||||||
| 942 | { | - | ||||||||||||||||||||||||
| 943 | if (pixelSize <= 0) {
| 0 | ||||||||||||||||||||||||
| 944 | qWarning("QFont::setPixelSize: Pixel size <= 0 (%d)", pixelSize); | - | ||||||||||||||||||||||||
| 945 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 946 | } | - | ||||||||||||||||||||||||
| 947 | - | |||||||||||||||||||||||||
| 948 | if ((resolve_mask & QFont::SizeResolved) && d->request.pixelSize == qreal(pixelSize))
| 0 | ||||||||||||||||||||||||
| 949 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 950 | - | |||||||||||||||||||||||||
| 951 | detach(); | - | ||||||||||||||||||||||||
| 952 | - | |||||||||||||||||||||||||
| 953 | d->request.pixelSize = pixelSize; | - | ||||||||||||||||||||||||
| 954 | d->request.pointSize = -1; | - | ||||||||||||||||||||||||
| 955 | - | |||||||||||||||||||||||||
| 956 | resolve_mask |= QFont::SizeResolved; | - | ||||||||||||||||||||||||
| 957 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 958 | - | |||||||||||||||||||||||||
| 959 | /*! | - | ||||||||||||||||||||||||
| 960 | Returns the pixel size of the font if it was set with | - | ||||||||||||||||||||||||
| 961 | setPixelSize(). Returns -1 if the size was set with setPointSize() | - | ||||||||||||||||||||||||
| 962 | or setPointSizeF(). | - | ||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||
| 964 | \sa setPixelSize(), pointSize(), QFontInfo::pointSize(), QFontInfo::pixelSize() | - | ||||||||||||||||||||||||
| 965 | */ | - | ||||||||||||||||||||||||
| 966 | int QFont::pixelSize() const | - | ||||||||||||||||||||||||
| 967 | { | - | ||||||||||||||||||||||||
| 968 | return d->request.pixelSize; never executed: return d->request.pixelSize; | 0 | ||||||||||||||||||||||||
| 969 | } | - | ||||||||||||||||||||||||
| 970 | - | |||||||||||||||||||||||||
| 971 | /*! | - | ||||||||||||||||||||||||
| 972 | \fn bool QFont::italic() const | - | ||||||||||||||||||||||||
| 973 | - | |||||||||||||||||||||||||
| 974 | Returns \c true if the style() of the font is not QFont::StyleNormal | - | ||||||||||||||||||||||||
| 975 | - | |||||||||||||||||||||||||
| 976 | \sa setItalic(), style() | - | ||||||||||||||||||||||||
| 977 | */ | - | ||||||||||||||||||||||||
| 978 | - | |||||||||||||||||||||||||
| 979 | /*! | - | ||||||||||||||||||||||||
| 980 | \fn void QFont::setItalic(bool enable) | - | ||||||||||||||||||||||||
| 981 | - | |||||||||||||||||||||||||
| 982 | Sets the style() of the font to QFont::StyleItalic if \a enable is true; | - | ||||||||||||||||||||||||
| 983 | otherwise the style is set to QFont::StyleNormal. | - | ||||||||||||||||||||||||
| 984 | - | |||||||||||||||||||||||||
| 985 | \sa italic(), QFontInfo | - | ||||||||||||||||||||||||
| 986 | */ | - | ||||||||||||||||||||||||
| 987 | - | |||||||||||||||||||||||||
| 988 | /*! | - | ||||||||||||||||||||||||
| 989 | Returns the style of the font. | - | ||||||||||||||||||||||||
| 990 | - | |||||||||||||||||||||||||
| 991 | \sa setStyle() | - | ||||||||||||||||||||||||
| 992 | */ | - | ||||||||||||||||||||||||
| 993 | QFont::Style QFont::style() const | - | ||||||||||||||||||||||||
| 994 | { | - | ||||||||||||||||||||||||
| 995 | return (QFont::Style)d->request.style; never executed: return (QFont::Style)d->request.style; | 0 | ||||||||||||||||||||||||
| 996 | } | - | ||||||||||||||||||||||||
| 997 | - | |||||||||||||||||||||||||
| 998 | - | |||||||||||||||||||||||||
| 999 | /*! | - | ||||||||||||||||||||||||
| 1000 | Sets the style of the font to \a style. | - | ||||||||||||||||||||||||
| 1001 | - | |||||||||||||||||||||||||
| 1002 | \sa italic(), QFontInfo | - | ||||||||||||||||||||||||
| 1003 | */ | - | ||||||||||||||||||||||||
| 1004 | void QFont::setStyle(Style style) | - | ||||||||||||||||||||||||
| 1005 | { | - | ||||||||||||||||||||||||
| 1006 | if ((resolve_mask & QFont::StyleResolved) && d->request.style == style)
| 0 | ||||||||||||||||||||||||
| 1007 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1008 | - | |||||||||||||||||||||||||
| 1009 | detach(); | - | ||||||||||||||||||||||||
| 1010 | - | |||||||||||||||||||||||||
| 1011 | d->request.style = style; | - | ||||||||||||||||||||||||
| 1012 | resolve_mask |= QFont::StyleResolved; | - | ||||||||||||||||||||||||
| 1013 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1014 | - | |||||||||||||||||||||||||
| 1015 | /*! | - | ||||||||||||||||||||||||
| 1016 | Returns the weight of the font, using the same scale as the | - | ||||||||||||||||||||||||
| 1017 | \l{QFont::Weight} enumeration. | - | ||||||||||||||||||||||||
| 1018 | - | |||||||||||||||||||||||||
| 1019 | \sa setWeight(), Weight, QFontInfo | - | ||||||||||||||||||||||||
| 1020 | */ | - | ||||||||||||||||||||||||
| 1021 | int QFont::weight() const | - | ||||||||||||||||||||||||
| 1022 | { | - | ||||||||||||||||||||||||
| 1023 | return d->request.weight; never executed: return d->request.weight; | 0 | ||||||||||||||||||||||||
| 1024 | } | - | ||||||||||||||||||||||||
| 1025 | - | |||||||||||||||||||||||||
| 1026 | /*! | - | ||||||||||||||||||||||||
| 1027 | \enum QFont::Weight | - | ||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||
| 1029 | Qt uses a weighting scale from 0 to 99 similar to, but not the | - | ||||||||||||||||||||||||
| 1030 | same as, the scales used in Windows or CSS. A weight of 0 will be | - | ||||||||||||||||||||||||
| 1031 | thin, whilst 99 will be extremely black. | - | ||||||||||||||||||||||||
| 1032 | - | |||||||||||||||||||||||||
| 1033 | This enum contains the predefined font weights: | - | ||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||
| 1035 | \value Thin 0 | - | ||||||||||||||||||||||||
| 1036 | \value ExtraLight 12 | - | ||||||||||||||||||||||||
| 1037 | \value Light 25 | - | ||||||||||||||||||||||||
| 1038 | \value Normal 50 | - | ||||||||||||||||||||||||
| 1039 | \value Medium 57 | - | ||||||||||||||||||||||||
| 1040 | \value DemiBold 63 | - | ||||||||||||||||||||||||
| 1041 | \value Bold 75 | - | ||||||||||||||||||||||||
| 1042 | \value ExtraBold 81 | - | ||||||||||||||||||||||||
| 1043 | \value Black 87 | - | ||||||||||||||||||||||||
| 1044 | */ | - | ||||||||||||||||||||||||
| 1045 | - | |||||||||||||||||||||||||
| 1046 | /*! | - | ||||||||||||||||||||||||
| 1047 | Sets the weight of the font to \a weight, using the scale defined by | - | ||||||||||||||||||||||||
| 1048 | \l QFont::Weight enumeration. | - | ||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | \sa weight(), QFontInfo | - | ||||||||||||||||||||||||
| 1051 | */ | - | ||||||||||||||||||||||||
| 1052 | void QFont::setWeight(int weight) | - | ||||||||||||||||||||||||
| 1053 | { | - | ||||||||||||||||||||||||
| 1054 | Q_ASSERT_X(weight >= 0 && weight <= 99, "QFont::setWeight", "Weight must be between 0 and 99"); | - | ||||||||||||||||||||||||
| 1055 | - | |||||||||||||||||||||||||
| 1056 | if ((resolve_mask & QFont::WeightResolved) && d->request.weight == weight)
| 0 | ||||||||||||||||||||||||
| 1057 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1058 | - | |||||||||||||||||||||||||
| 1059 | detach(); | - | ||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||
| 1061 | d->request.weight = weight; | - | ||||||||||||||||||||||||
| 1062 | resolve_mask |= QFont::WeightResolved; | - | ||||||||||||||||||||||||
| 1063 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1064 | - | |||||||||||||||||||||||||
| 1065 | /*! | - | ||||||||||||||||||||||||
| 1066 | \fn bool QFont::bold() const | - | ||||||||||||||||||||||||
| 1067 | - | |||||||||||||||||||||||||
| 1068 | Returns \c true if weight() is a value greater than | - | ||||||||||||||||||||||||
| 1069 | \l{Weight}{QFont::Medium}; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 1070 | - | |||||||||||||||||||||||||
| 1071 | \sa weight(), setBold(), QFontInfo::bold() | - | ||||||||||||||||||||||||
| 1072 | */ | - | ||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||
| 1074 | /*! | - | ||||||||||||||||||||||||
| 1075 | \fn void QFont::setBold(bool enable) | - | ||||||||||||||||||||||||
| 1076 | - | |||||||||||||||||||||||||
| 1077 | If \a enable is true sets the font's weight to | - | ||||||||||||||||||||||||
| 1078 | \l{Weight}{QFont::Bold}; | - | ||||||||||||||||||||||||
| 1079 | otherwise sets the weight to \l{Weight}{QFont::Normal}. | - | ||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||
| 1081 | For finer boldness control use setWeight(). | - | ||||||||||||||||||||||||
| 1082 | - | |||||||||||||||||||||||||
| 1083 | \sa bold(), setWeight() | - | ||||||||||||||||||||||||
| 1084 | */ | - | ||||||||||||||||||||||||
| 1085 | - | |||||||||||||||||||||||||
| 1086 | /*! | - | ||||||||||||||||||||||||
| 1087 | Returns \c true if underline has been set; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 1088 | - | |||||||||||||||||||||||||
| 1089 | \sa setUnderline() | - | ||||||||||||||||||||||||
| 1090 | */ | - | ||||||||||||||||||||||||
| 1091 | bool QFont::underline() const | - | ||||||||||||||||||||||||
| 1092 | { | - | ||||||||||||||||||||||||
| 1093 | return d->underline; never executed: return d->underline; | 0 | ||||||||||||||||||||||||
| 1094 | } | - | ||||||||||||||||||||||||
| 1095 | - | |||||||||||||||||||||||||
| 1096 | /*! | - | ||||||||||||||||||||||||
| 1097 | If \a enable is true, sets underline on; otherwise sets underline | - | ||||||||||||||||||||||||
| 1098 | off. | - | ||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||
| 1100 | \sa underline(), QFontInfo | - | ||||||||||||||||||||||||
| 1101 | */ | - | ||||||||||||||||||||||||
| 1102 | void QFont::setUnderline(bool enable) | - | ||||||||||||||||||||||||
| 1103 | { | - | ||||||||||||||||||||||||
| 1104 | if ((resolve_mask & QFont::UnderlineResolved) && d->underline == enable)
| 0 | ||||||||||||||||||||||||
| 1105 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||
| 1107 | QFontPrivate::detachButKeepEngineData(this); | - | ||||||||||||||||||||||||
| 1108 | - | |||||||||||||||||||||||||
| 1109 | d->underline = enable; | - | ||||||||||||||||||||||||
| 1110 | resolve_mask |= QFont::UnderlineResolved; | - | ||||||||||||||||||||||||
| 1111 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1112 | - | |||||||||||||||||||||||||
| 1113 | /*! | - | ||||||||||||||||||||||||
| 1114 | Returns \c true if overline has been set; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 1115 | - | |||||||||||||||||||||||||
| 1116 | \sa setOverline() | - | ||||||||||||||||||||||||
| 1117 | */ | - | ||||||||||||||||||||||||
| 1118 | bool QFont::overline() const | - | ||||||||||||||||||||||||
| 1119 | { | - | ||||||||||||||||||||||||
| 1120 | return d->overline; never executed: return d->overline; | 0 | ||||||||||||||||||||||||
| 1121 | } | - | ||||||||||||||||||||||||
| 1122 | - | |||||||||||||||||||||||||
| 1123 | /*! | - | ||||||||||||||||||||||||
| 1124 | If \a enable is true, sets overline on; otherwise sets overline off. | - | ||||||||||||||||||||||||
| 1125 | - | |||||||||||||||||||||||||
| 1126 | \sa overline(), QFontInfo | - | ||||||||||||||||||||||||
| 1127 | */ | - | ||||||||||||||||||||||||
| 1128 | void QFont::setOverline(bool enable) | - | ||||||||||||||||||||||||
| 1129 | { | - | ||||||||||||||||||||||||
| 1130 | if ((resolve_mask & QFont::OverlineResolved) && d->overline == enable)
| 0 | ||||||||||||||||||||||||
| 1131 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||
| 1133 | QFontPrivate::detachButKeepEngineData(this); | - | ||||||||||||||||||||||||
| 1134 | - | |||||||||||||||||||||||||
| 1135 | d->overline = enable; | - | ||||||||||||||||||||||||
| 1136 | resolve_mask |= QFont::OverlineResolved; | - | ||||||||||||||||||||||||
| 1137 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1138 | - | |||||||||||||||||||||||||
| 1139 | /*! | - | ||||||||||||||||||||||||
| 1140 | Returns \c true if strikeout has been set; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 1141 | - | |||||||||||||||||||||||||
| 1142 | \sa setStrikeOut() | - | ||||||||||||||||||||||||
| 1143 | */ | - | ||||||||||||||||||||||||
| 1144 | bool QFont::strikeOut() const | - | ||||||||||||||||||||||||
| 1145 | { | - | ||||||||||||||||||||||||
| 1146 | return d->strikeOut; never executed: return d->strikeOut; | 0 | ||||||||||||||||||||||||
| 1147 | } | - | ||||||||||||||||||||||||
| 1148 | - | |||||||||||||||||||||||||
| 1149 | /*! | - | ||||||||||||||||||||||||
| 1150 | If \a enable is true, sets strikeout on; otherwise sets strikeout | - | ||||||||||||||||||||||||
| 1151 | off. | - | ||||||||||||||||||||||||
| 1152 | - | |||||||||||||||||||||||||
| 1153 | \sa strikeOut(), QFontInfo | - | ||||||||||||||||||||||||
| 1154 | */ | - | ||||||||||||||||||||||||
| 1155 | void QFont::setStrikeOut(bool enable) | - | ||||||||||||||||||||||||
| 1156 | { | - | ||||||||||||||||||||||||
| 1157 | if ((resolve_mask & QFont::StrikeOutResolved) && d->strikeOut == enable)
| 0 | ||||||||||||||||||||||||
| 1158 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1159 | - | |||||||||||||||||||||||||
| 1160 | QFontPrivate::detachButKeepEngineData(this); | - | ||||||||||||||||||||||||
| 1161 | - | |||||||||||||||||||||||||
| 1162 | d->strikeOut = enable; | - | ||||||||||||||||||||||||
| 1163 | resolve_mask |= QFont::StrikeOutResolved; | - | ||||||||||||||||||||||||
| 1164 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||
| 1166 | /*! | - | ||||||||||||||||||||||||
| 1167 | Returns \c true if fixed pitch has been set; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||
| 1169 | \sa setFixedPitch(), QFontInfo::fixedPitch() | - | ||||||||||||||||||||||||
| 1170 | */ | - | ||||||||||||||||||||||||
| 1171 | bool QFont::fixedPitch() const | - | ||||||||||||||||||||||||
| 1172 | { | - | ||||||||||||||||||||||||
| 1173 | return d->request.fixedPitch; never executed: return d->request.fixedPitch; | 0 | ||||||||||||||||||||||||
| 1174 | } | - | ||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||
| 1176 | /*! | - | ||||||||||||||||||||||||
| 1177 | If \a enable is true, sets fixed pitch on; otherwise sets fixed | - | ||||||||||||||||||||||||
| 1178 | pitch off. | - | ||||||||||||||||||||||||
| 1179 | - | |||||||||||||||||||||||||
| 1180 | \sa fixedPitch(), QFontInfo | - | ||||||||||||||||||||||||
| 1181 | */ | - | ||||||||||||||||||||||||
| 1182 | void QFont::setFixedPitch(bool enable) | - | ||||||||||||||||||||||||
| 1183 | { | - | ||||||||||||||||||||||||
| 1184 | if ((resolve_mask & QFont::FixedPitchResolved) && d->request.fixedPitch == enable)
| 0 | ||||||||||||||||||||||||
| 1185 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1186 | - | |||||||||||||||||||||||||
| 1187 | detach(); | - | ||||||||||||||||||||||||
| 1188 | - | |||||||||||||||||||||||||
| 1189 | d->request.fixedPitch = enable; | - | ||||||||||||||||||||||||
| 1190 | d->request.ignorePitch = false; | - | ||||||||||||||||||||||||
| 1191 | resolve_mask |= QFont::FixedPitchResolved; | - | ||||||||||||||||||||||||
| 1192 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1193 | - | |||||||||||||||||||||||||
| 1194 | /*! | - | ||||||||||||||||||||||||
| 1195 | Returns \c true if kerning should be used when drawing text with this font. | - | ||||||||||||||||||||||||
| 1196 | - | |||||||||||||||||||||||||
| 1197 | \sa setKerning() | - | ||||||||||||||||||||||||
| 1198 | */ | - | ||||||||||||||||||||||||
| 1199 | bool QFont::kerning() const | - | ||||||||||||||||||||||||
| 1200 | { | - | ||||||||||||||||||||||||
| 1201 | return d->kerning; never executed: return d->kerning; | 0 | ||||||||||||||||||||||||
| 1202 | } | - | ||||||||||||||||||||||||
| 1203 | - | |||||||||||||||||||||||||
| 1204 | /*! | - | ||||||||||||||||||||||||
| 1205 | Enables kerning for this font if \a enable is true; otherwise | - | ||||||||||||||||||||||||
| 1206 | disables it. By default, kerning is enabled. | - | ||||||||||||||||||||||||
| 1207 | - | |||||||||||||||||||||||||
| 1208 | When kerning is enabled, glyph metrics do not add up anymore, | - | ||||||||||||||||||||||||
| 1209 | even for Latin text. In other words, the assumption that | - | ||||||||||||||||||||||||
| 1210 | width('a') + width('b') is equal to width("ab") is not | - | ||||||||||||||||||||||||
| 1211 | necessarily true. | - | ||||||||||||||||||||||||
| 1212 | - | |||||||||||||||||||||||||
| 1213 | \sa kerning(), QFontMetrics | - | ||||||||||||||||||||||||
| 1214 | */ | - | ||||||||||||||||||||||||
| 1215 | void QFont::setKerning(bool enable) | - | ||||||||||||||||||||||||
| 1216 | { | - | ||||||||||||||||||||||||
| 1217 | if ((resolve_mask & QFont::KerningResolved) && d->kerning == enable)
| 0 | ||||||||||||||||||||||||
| 1218 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1219 | - | |||||||||||||||||||||||||
| 1220 | QFontPrivate::detachButKeepEngineData(this); | - | ||||||||||||||||||||||||
| 1221 | - | |||||||||||||||||||||||||
| 1222 | d->kerning = enable; | - | ||||||||||||||||||||||||
| 1223 | resolve_mask |= QFont::KerningResolved; | - | ||||||||||||||||||||||||
| 1224 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1225 | - | |||||||||||||||||||||||||
| 1226 | /*! | - | ||||||||||||||||||||||||
| 1227 | Returns the StyleStrategy. | - | ||||||||||||||||||||||||
| 1228 | - | |||||||||||||||||||||||||
| 1229 | The style strategy affects the \l{QFont}{font matching} algorithm. | - | ||||||||||||||||||||||||
| 1230 | See \l QFont::StyleStrategy for the list of available strategies. | - | ||||||||||||||||||||||||
| 1231 | - | |||||||||||||||||||||||||
| 1232 | \sa setStyleHint(), QFont::StyleHint | - | ||||||||||||||||||||||||
| 1233 | */ | - | ||||||||||||||||||||||||
| 1234 | QFont::StyleStrategy QFont::styleStrategy() const | - | ||||||||||||||||||||||||
| 1235 | { | - | ||||||||||||||||||||||||
| 1236 | return (StyleStrategy) d->request.styleStrategy; never executed: return (StyleStrategy) d->request.styleStrategy; | 0 | ||||||||||||||||||||||||
| 1237 | } | - | ||||||||||||||||||||||||
| 1238 | - | |||||||||||||||||||||||||
| 1239 | /*! | - | ||||||||||||||||||||||||
| 1240 | Returns the StyleHint. | - | ||||||||||||||||||||||||
| 1241 | - | |||||||||||||||||||||||||
| 1242 | The style hint affects the \l{QFont}{font matching} algorithm. | - | ||||||||||||||||||||||||
| 1243 | See \l QFont::StyleHint for the list of available hints. | - | ||||||||||||||||||||||||
| 1244 | - | |||||||||||||||||||||||||
| 1245 | \sa setStyleHint(), QFont::StyleStrategy, QFontInfo::styleHint() | - | ||||||||||||||||||||||||
| 1246 | */ | - | ||||||||||||||||||||||||
| 1247 | QFont::StyleHint QFont::styleHint() const | - | ||||||||||||||||||||||||
| 1248 | { | - | ||||||||||||||||||||||||
| 1249 | return (StyleHint) d->request.styleHint; never executed: return (StyleHint) d->request.styleHint; | 0 | ||||||||||||||||||||||||
| 1250 | } | - | ||||||||||||||||||||||||
| 1251 | - | |||||||||||||||||||||||||
| 1252 | /*! | - | ||||||||||||||||||||||||
| 1253 | \enum QFont::StyleHint | - | ||||||||||||||||||||||||
| 1254 | - | |||||||||||||||||||||||||
| 1255 | Style hints are used by the \l{QFont}{font matching} algorithm to | - | ||||||||||||||||||||||||
| 1256 | find an appropriate default family if a selected font family is | - | ||||||||||||||||||||||||
| 1257 | not available. | - | ||||||||||||||||||||||||
| 1258 | - | |||||||||||||||||||||||||
| 1259 | \value AnyStyle leaves the font matching algorithm to choose the | - | ||||||||||||||||||||||||
| 1260 | family. This is the default. | - | ||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||
| 1262 | \value SansSerif the font matcher prefer sans serif fonts. | - | ||||||||||||||||||||||||
| 1263 | \value Helvetica is a synonym for \c SansSerif. | - | ||||||||||||||||||||||||
| 1264 | - | |||||||||||||||||||||||||
| 1265 | \value Serif the font matcher prefers serif fonts. | - | ||||||||||||||||||||||||
| 1266 | \value Times is a synonym for \c Serif. | - | ||||||||||||||||||||||||
| 1267 | - | |||||||||||||||||||||||||
| 1268 | \value TypeWriter the font matcher prefers fixed pitch fonts. | - | ||||||||||||||||||||||||
| 1269 | \value Courier a synonym for \c TypeWriter. | - | ||||||||||||||||||||||||
| 1270 | - | |||||||||||||||||||||||||
| 1271 | \value OldEnglish the font matcher prefers decorative fonts. | - | ||||||||||||||||||||||||
| 1272 | \value Decorative is a synonym for \c OldEnglish. | - | ||||||||||||||||||||||||
| 1273 | - | |||||||||||||||||||||||||
| 1274 | \value Monospace the font matcher prefers fonts that map to the | - | ||||||||||||||||||||||||
| 1275 | CSS generic font-family 'monospace'. | - | ||||||||||||||||||||||||
| 1276 | - | |||||||||||||||||||||||||
| 1277 | \value Fantasy the font matcher prefers fonts that map to the | - | ||||||||||||||||||||||||
| 1278 | CSS generic font-family 'fantasy'. | - | ||||||||||||||||||||||||
| 1279 | - | |||||||||||||||||||||||||
| 1280 | \value Cursive the font matcher prefers fonts that map to the | - | ||||||||||||||||||||||||
| 1281 | CSS generic font-family 'cursive'. | - | ||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||
| 1283 | \value System the font matcher prefers system fonts. | - | ||||||||||||||||||||||||
| 1284 | */ | - | ||||||||||||||||||||||||
| 1285 | - | |||||||||||||||||||||||||
| 1286 | /*! | - | ||||||||||||||||||||||||
| 1287 | \enum QFont::StyleStrategy | - | ||||||||||||||||||||||||
| 1288 | - | |||||||||||||||||||||||||
| 1289 | The style strategy tells the \l{QFont}{font matching} algorithm | - | ||||||||||||||||||||||||
| 1290 | what type of fonts should be used to find an appropriate default | - | ||||||||||||||||||||||||
| 1291 | family. | - | ||||||||||||||||||||||||
| 1292 | - | |||||||||||||||||||||||||
| 1293 | The following strategies are available: | - | ||||||||||||||||||||||||
| 1294 | - | |||||||||||||||||||||||||
| 1295 | \value PreferDefault the default style strategy. It does not prefer | - | ||||||||||||||||||||||||
| 1296 | any type of font. | - | ||||||||||||||||||||||||
| 1297 | \value PreferBitmap prefers bitmap fonts (as opposed to outline | - | ||||||||||||||||||||||||
| 1298 | fonts). | - | ||||||||||||||||||||||||
| 1299 | \value PreferDevice prefers device fonts. | - | ||||||||||||||||||||||||
| 1300 | \value PreferOutline prefers outline fonts (as opposed to bitmap fonts). | - | ||||||||||||||||||||||||
| 1301 | \value ForceOutline forces the use of outline fonts. | - | ||||||||||||||||||||||||
| 1302 | \value NoAntialias don't antialias the fonts. | - | ||||||||||||||||||||||||
| 1303 | \value NoSubpixelAntialias avoid subpixel antialiasing on the fonts if possible. | - | ||||||||||||||||||||||||
| 1304 | \value PreferAntialias antialias if possible. | - | ||||||||||||||||||||||||
| 1305 | \value OpenGLCompatible forces the use of OpenGL compatible | - | ||||||||||||||||||||||||
| 1306 | fonts. | - | ||||||||||||||||||||||||
| 1307 | \value NoFontMerging If the font selected for a certain writing system | - | ||||||||||||||||||||||||
| 1308 | does not contain a character requested to draw, then Qt automatically chooses a similar | - | ||||||||||||||||||||||||
| 1309 | looking font that contains the character. The NoFontMerging flag disables this feature. | - | ||||||||||||||||||||||||
| 1310 | Please note that enabling this flag will not prevent Qt from automatically picking a | - | ||||||||||||||||||||||||
| 1311 | suitable font when the selected font does not support the writing system of the text. | - | ||||||||||||||||||||||||
| 1312 | - | |||||||||||||||||||||||||
| 1313 | Any of these may be OR-ed with one of these flags: | - | ||||||||||||||||||||||||
| 1314 | - | |||||||||||||||||||||||||
| 1315 | \value PreferMatch prefer an exact match. The font matcher will try to | - | ||||||||||||||||||||||||
| 1316 | use the exact font size that has been specified. | - | ||||||||||||||||||||||||
| 1317 | \value PreferQuality prefer the best quality font. The font matcher | - | ||||||||||||||||||||||||
| 1318 | will use the nearest standard point size that the font | - | ||||||||||||||||||||||||
| 1319 | supports. | - | ||||||||||||||||||||||||
| 1320 | \value ForceIntegerMetrics forces the use of integer values in font engines that support fractional | - | ||||||||||||||||||||||||
| 1321 | font metrics. | - | ||||||||||||||||||||||||
| 1322 | */ | - | ||||||||||||||||||||||||
| 1323 | - | |||||||||||||||||||||||||
| 1324 | /*! | - | ||||||||||||||||||||||||
| 1325 | Sets the style hint and strategy to \a hint and \a strategy, | - | ||||||||||||||||||||||||
| 1326 | respectively. | - | ||||||||||||||||||||||||
| 1327 | - | |||||||||||||||||||||||||
| 1328 | If these aren't set explicitly the style hint will default to | - | ||||||||||||||||||||||||
| 1329 | \c AnyStyle and the style strategy to \c PreferDefault. | - | ||||||||||||||||||||||||
| 1330 | - | |||||||||||||||||||||||||
| 1331 | Qt does not support style hints on X11 since this information | - | ||||||||||||||||||||||||
| 1332 | is not provided by the window system. | - | ||||||||||||||||||||||||
| 1333 | - | |||||||||||||||||||||||||
| 1334 | \sa StyleHint, styleHint(), StyleStrategy, styleStrategy(), QFontInfo | - | ||||||||||||||||||||||||
| 1335 | */ | - | ||||||||||||||||||||||||
| 1336 | void QFont::setStyleHint(StyleHint hint, StyleStrategy strategy) | - | ||||||||||||||||||||||||
| 1337 | { | - | ||||||||||||||||||||||||
| 1338 | if ((resolve_mask & (QFont::StyleHintResolved | QFont::StyleStrategyResolved)) &&
| 0 | ||||||||||||||||||||||||
| 1339 | (StyleHint) d->request.styleHint == hint &&
| 0 | ||||||||||||||||||||||||
| 1340 | (StyleStrategy) d->request.styleStrategy == strategy)
| 0 | ||||||||||||||||||||||||
| 1341 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1342 | - | |||||||||||||||||||||||||
| 1343 | detach(); | - | ||||||||||||||||||||||||
| 1344 | - | |||||||||||||||||||||||||
| 1345 | d->request.styleHint = hint; | - | ||||||||||||||||||||||||
| 1346 | d->request.styleStrategy = strategy; | - | ||||||||||||||||||||||||
| 1347 | resolve_mask |= QFont::StyleHintResolved; | - | ||||||||||||||||||||||||
| 1348 | resolve_mask |= QFont::StyleStrategyResolved; | - | ||||||||||||||||||||||||
| 1349 | - | |||||||||||||||||||||||||
| 1350 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1351 | - | |||||||||||||||||||||||||
| 1352 | /*! | - | ||||||||||||||||||||||||
| 1353 | Sets the style strategy for the font to \a s. | - | ||||||||||||||||||||||||
| 1354 | - | |||||||||||||||||||||||||
| 1355 | \sa QFont::StyleStrategy | - | ||||||||||||||||||||||||
| 1356 | */ | - | ||||||||||||||||||||||||
| 1357 | void QFont::setStyleStrategy(StyleStrategy s) | - | ||||||||||||||||||||||||
| 1358 | { | - | ||||||||||||||||||||||||
| 1359 | if ((resolve_mask & QFont::StyleStrategyResolved) &&
| 0 | ||||||||||||||||||||||||
| 1360 | s == (StyleStrategy)d->request.styleStrategy)
| 0 | ||||||||||||||||||||||||
| 1361 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1362 | - | |||||||||||||||||||||||||
| 1363 | detach(); | - | ||||||||||||||||||||||||
| 1364 | - | |||||||||||||||||||||||||
| 1365 | d->request.styleStrategy = s; | - | ||||||||||||||||||||||||
| 1366 | resolve_mask |= QFont::StyleStrategyResolved; | - | ||||||||||||||||||||||||
| 1367 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1368 | - | |||||||||||||||||||||||||
| 1369 | - | |||||||||||||||||||||||||
| 1370 | /*! | - | ||||||||||||||||||||||||
| 1371 | \enum QFont::Stretch | - | ||||||||||||||||||||||||
| 1372 | - | |||||||||||||||||||||||||
| 1373 | Predefined stretch values that follow the CSS naming convention. The higher | - | ||||||||||||||||||||||||
| 1374 | the value, the more stretched the text is. | - | ||||||||||||||||||||||||
| 1375 | - | |||||||||||||||||||||||||
| 1376 | \value UltraCondensed 50 | - | ||||||||||||||||||||||||
| 1377 | \value ExtraCondensed 62 | - | ||||||||||||||||||||||||
| 1378 | \value Condensed 75 | - | ||||||||||||||||||||||||
| 1379 | \value SemiCondensed 87 | - | ||||||||||||||||||||||||
| 1380 | \value Unstretched 100 | - | ||||||||||||||||||||||||
| 1381 | \value SemiExpanded 112 | - | ||||||||||||||||||||||||
| 1382 | \value Expanded 125 | - | ||||||||||||||||||||||||
| 1383 | \value ExtraExpanded 150 | - | ||||||||||||||||||||||||
| 1384 | \value UltraExpanded 200 | - | ||||||||||||||||||||||||
| 1385 | - | |||||||||||||||||||||||||
| 1386 | \sa setStretch(), stretch() | - | ||||||||||||||||||||||||
| 1387 | */ | - | ||||||||||||||||||||||||
| 1388 | - | |||||||||||||||||||||||||
| 1389 | /*! | - | ||||||||||||||||||||||||
| 1390 | Returns the stretch factor for the font. | - | ||||||||||||||||||||||||
| 1391 | - | |||||||||||||||||||||||||
| 1392 | \sa setStretch() | - | ||||||||||||||||||||||||
| 1393 | */ | - | ||||||||||||||||||||||||
| 1394 | int QFont::stretch() const | - | ||||||||||||||||||||||||
| 1395 | { | - | ||||||||||||||||||||||||
| 1396 | return d->request.stretch; never executed: return d->request.stretch; | 0 | ||||||||||||||||||||||||
| 1397 | } | - | ||||||||||||||||||||||||
| 1398 | - | |||||||||||||||||||||||||
| 1399 | /*! | - | ||||||||||||||||||||||||
| 1400 | Sets the stretch factor for the font. | - | ||||||||||||||||||||||||
| 1401 | - | |||||||||||||||||||||||||
| 1402 | The stretch factor changes the width of all characters in the font | - | ||||||||||||||||||||||||
| 1403 | by \a factor percent. For example, setting \a factor to 150 | - | ||||||||||||||||||||||||
| 1404 | results in all characters in the font being 1.5 times (ie. 150%) | - | ||||||||||||||||||||||||
| 1405 | wider. The default stretch factor is 100. The minimum stretch | - | ||||||||||||||||||||||||
| 1406 | factor is 1, and the maximum stretch factor is 4000. | - | ||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||
| 1408 | The stretch factor is only applied to outline fonts. The stretch | - | ||||||||||||||||||||||||
| 1409 | factor is ignored for bitmap fonts. | - | ||||||||||||||||||||||||
| 1410 | - | |||||||||||||||||||||||||
| 1411 | \sa stretch(), QFont::Stretch | - | ||||||||||||||||||||||||
| 1412 | */ | - | ||||||||||||||||||||||||
| 1413 | void QFont::setStretch(int factor) | - | ||||||||||||||||||||||||
| 1414 | { | - | ||||||||||||||||||||||||
| 1415 | if (factor < 1 || factor > 4000) {
| 0 | ||||||||||||||||||||||||
| 1416 | qWarning("QFont::setStretch: Parameter '%d' out of range", factor); | - | ||||||||||||||||||||||||
| 1417 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1418 | } | - | ||||||||||||||||||||||||
| 1419 | - | |||||||||||||||||||||||||
| 1420 | if ((resolve_mask & QFont::StretchResolved) &&
| 0 | ||||||||||||||||||||||||
| 1421 | d->request.stretch == (uint)factor)
| 0 | ||||||||||||||||||||||||
| 1422 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1423 | - | |||||||||||||||||||||||||
| 1424 | detach(); | - | ||||||||||||||||||||||||
| 1425 | - | |||||||||||||||||||||||||
| 1426 | d->request.stretch = (uint)factor; | - | ||||||||||||||||||||||||
| 1427 | resolve_mask |= QFont::StretchResolved; | - | ||||||||||||||||||||||||
| 1428 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1429 | - | |||||||||||||||||||||||||
| 1430 | /*! | - | ||||||||||||||||||||||||
| 1431 | \enum QFont::SpacingType | - | ||||||||||||||||||||||||
| 1432 | \since 4.4 | - | ||||||||||||||||||||||||
| 1433 | - | |||||||||||||||||||||||||
| 1434 | \value PercentageSpacing A value of 100 will keep the spacing unchanged; a value of 200 will enlarge the | - | ||||||||||||||||||||||||
| 1435 | spacing after a character by the width of the character itself. | - | ||||||||||||||||||||||||
| 1436 | \value AbsoluteSpacing A positive value increases the letter spacing by the corresponding pixels; a negative | - | ||||||||||||||||||||||||
| 1437 | value decreases the spacing. | - | ||||||||||||||||||||||||
| 1438 | */ | - | ||||||||||||||||||||||||
| 1439 | - | |||||||||||||||||||||||||
| 1440 | /*! | - | ||||||||||||||||||||||||
| 1441 | \since 4.4 | - | ||||||||||||||||||||||||
| 1442 | Returns the letter spacing for the font. | - | ||||||||||||||||||||||||
| 1443 | - | |||||||||||||||||||||||||
| 1444 | \sa setLetterSpacing(), letterSpacingType(), setWordSpacing() | - | ||||||||||||||||||||||||
| 1445 | */ | - | ||||||||||||||||||||||||
| 1446 | qreal QFont::letterSpacing() const | - | ||||||||||||||||||||||||
| 1447 | { | - | ||||||||||||||||||||||||
| 1448 | return d->letterSpacing.toReal(); never executed: return d->letterSpacing.toReal(); | 0 | ||||||||||||||||||||||||
| 1449 | } | - | ||||||||||||||||||||||||
| 1450 | - | |||||||||||||||||||||||||
| 1451 | /*! | - | ||||||||||||||||||||||||
| 1452 | \since 4.4 | - | ||||||||||||||||||||||||
| 1453 | Sets the letter spacing for the font to \a spacing and the type | - | ||||||||||||||||||||||||
| 1454 | of spacing to \a type. | - | ||||||||||||||||||||||||
| 1455 | - | |||||||||||||||||||||||||
| 1456 | Letter spacing changes the default spacing between individual | - | ||||||||||||||||||||||||
| 1457 | letters in the font. The spacing between the letters can be | - | ||||||||||||||||||||||||
| 1458 | made smaller as well as larger either in percentage of the | - | ||||||||||||||||||||||||
| 1459 | character width or in pixels, depending on the selected spacing type. | - | ||||||||||||||||||||||||
| 1460 | - | |||||||||||||||||||||||||
| 1461 | \sa letterSpacing(), letterSpacingType(), setWordSpacing() | - | ||||||||||||||||||||||||
| 1462 | */ | - | ||||||||||||||||||||||||
| 1463 | void QFont::setLetterSpacing(SpacingType type, qreal spacing) | - | ||||||||||||||||||||||||
| 1464 | { | - | ||||||||||||||||||||||||
| 1465 | const QFixed newSpacing = QFixed::fromReal(spacing); | - | ||||||||||||||||||||||||
| 1466 | const bool absoluteSpacing = type == AbsoluteSpacing; | - | ||||||||||||||||||||||||
| 1467 | if ((resolve_mask & QFont::LetterSpacingResolved) &&
| 0 | ||||||||||||||||||||||||
| 1468 | d->letterSpacingIsAbsolute == absoluteSpacing &&
| 0 | ||||||||||||||||||||||||
| 1469 | d->letterSpacing == newSpacing)
| 0 | ||||||||||||||||||||||||
| 1470 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1471 | - | |||||||||||||||||||||||||
| 1472 | QFontPrivate::detachButKeepEngineData(this); | - | ||||||||||||||||||||||||
| 1473 | - | |||||||||||||||||||||||||
| 1474 | d->letterSpacing = newSpacing; | - | ||||||||||||||||||||||||
| 1475 | d->letterSpacingIsAbsolute = absoluteSpacing; | - | ||||||||||||||||||||||||
| 1476 | resolve_mask |= QFont::LetterSpacingResolved; | - | ||||||||||||||||||||||||
| 1477 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1478 | - | |||||||||||||||||||||||||
| 1479 | /*! | - | ||||||||||||||||||||||||
| 1480 | \since 4.4 | - | ||||||||||||||||||||||||
| 1481 | Returns the spacing type used for letter spacing. | - | ||||||||||||||||||||||||
| 1482 | - | |||||||||||||||||||||||||
| 1483 | \sa letterSpacing(), setLetterSpacing(), setWordSpacing() | - | ||||||||||||||||||||||||
| 1484 | */ | - | ||||||||||||||||||||||||
| 1485 | QFont::SpacingType QFont::letterSpacingType() const | - | ||||||||||||||||||||||||
| 1486 | { | - | ||||||||||||||||||||||||
| 1487 | return d->letterSpacingIsAbsolute ? AbsoluteSpacing : PercentageSpacing; never executed: return d->letterSpacingIsAbsolute ? AbsoluteSpacing : PercentageSpacing;
| 0 | ||||||||||||||||||||||||
| 1488 | } | - | ||||||||||||||||||||||||
| 1489 | - | |||||||||||||||||||||||||
| 1490 | /*! | - | ||||||||||||||||||||||||
| 1491 | \since 4.4 | - | ||||||||||||||||||||||||
| 1492 | Returns the word spacing for the font. | - | ||||||||||||||||||||||||
| 1493 | - | |||||||||||||||||||||||||
| 1494 | \sa setWordSpacing(), setLetterSpacing() | - | ||||||||||||||||||||||||
| 1495 | */ | - | ||||||||||||||||||||||||
| 1496 | qreal QFont::wordSpacing() const | - | ||||||||||||||||||||||||
| 1497 | { | - | ||||||||||||||||||||||||
| 1498 | return d->wordSpacing.toReal(); never executed: return d->wordSpacing.toReal(); | 0 | ||||||||||||||||||||||||
| 1499 | } | - | ||||||||||||||||||||||||
| 1500 | - | |||||||||||||||||||||||||
| 1501 | /*! | - | ||||||||||||||||||||||||
| 1502 | \since 4.4 | - | ||||||||||||||||||||||||
| 1503 | Sets the word spacing for the font to \a spacing. | - | ||||||||||||||||||||||||
| 1504 | - | |||||||||||||||||||||||||
| 1505 | Word spacing changes the default spacing between individual | - | ||||||||||||||||||||||||
| 1506 | words. A positive value increases the word spacing | - | ||||||||||||||||||||||||
| 1507 | by a corresponding amount of pixels, while a negative value | - | ||||||||||||||||||||||||
| 1508 | decreases the inter-word spacing accordingly. | - | ||||||||||||||||||||||||
| 1509 | - | |||||||||||||||||||||||||
| 1510 | Word spacing will not apply to writing systems, where indiviaul | - | ||||||||||||||||||||||||
| 1511 | words are not separated by white space. | - | ||||||||||||||||||||||||
| 1512 | - | |||||||||||||||||||||||||
| 1513 | \sa wordSpacing(), setLetterSpacing() | - | ||||||||||||||||||||||||
| 1514 | */ | - | ||||||||||||||||||||||||
| 1515 | void QFont::setWordSpacing(qreal spacing) | - | ||||||||||||||||||||||||
| 1516 | { | - | ||||||||||||||||||||||||
| 1517 | const QFixed newSpacing = QFixed::fromReal(spacing); | - | ||||||||||||||||||||||||
| 1518 | if ((resolve_mask & QFont::WordSpacingResolved) &&
| 0 | ||||||||||||||||||||||||
| 1519 | d->wordSpacing == newSpacing)
| 0 | ||||||||||||||||||||||||
| 1520 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1521 | - | |||||||||||||||||||||||||
| 1522 | QFontPrivate::detachButKeepEngineData(this); | - | ||||||||||||||||||||||||
| 1523 | - | |||||||||||||||||||||||||
| 1524 | d->wordSpacing = newSpacing; | - | ||||||||||||||||||||||||
| 1525 | resolve_mask |= QFont::WordSpacingResolved; | - | ||||||||||||||||||||||||
| 1526 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1527 | - | |||||||||||||||||||||||||
| 1528 | /*! | - | ||||||||||||||||||||||||
| 1529 | \enum QFont::Capitalization | - | ||||||||||||||||||||||||
| 1530 | \since 4.4 | - | ||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||
| 1532 | Rendering option for text this font applies to. | - | ||||||||||||||||||||||||
| 1533 | - | |||||||||||||||||||||||||
| 1534 | - | |||||||||||||||||||||||||
| 1535 | \value MixedCase This is the normal text rendering option where no capitalization change is applied. | - | ||||||||||||||||||||||||
| 1536 | \value AllUppercase This alters the text to be rendered in all uppercase type. | - | ||||||||||||||||||||||||
| 1537 | \value AllLowercase This alters the text to be rendered in all lowercase type. | - | ||||||||||||||||||||||||
| 1538 | \value SmallCaps This alters the text to be rendered in small-caps type. | - | ||||||||||||||||||||||||
| 1539 | \value Capitalize This alters the text to be rendered with the first character of each word as an uppercase character. | - | ||||||||||||||||||||||||
| 1540 | */ | - | ||||||||||||||||||||||||
| 1541 | - | |||||||||||||||||||||||||
| 1542 | /*! | - | ||||||||||||||||||||||||
| 1543 | \since 4.4 | - | ||||||||||||||||||||||||
| 1544 | Sets the capitalization of the text in this font to \a caps. | - | ||||||||||||||||||||||||
| 1545 | - | |||||||||||||||||||||||||
| 1546 | A font's capitalization makes the text appear in the selected capitalization mode. | - | ||||||||||||||||||||||||
| 1547 | - | |||||||||||||||||||||||||
| 1548 | \sa capitalization() | - | ||||||||||||||||||||||||
| 1549 | */ | - | ||||||||||||||||||||||||
| 1550 | void QFont::setCapitalization(Capitalization caps) | - | ||||||||||||||||||||||||
| 1551 | { | - | ||||||||||||||||||||||||
| 1552 | if ((resolve_mask & QFont::CapitalizationResolved) &&
| 0 | ||||||||||||||||||||||||
| 1553 | capitalization() == caps)
| 0 | ||||||||||||||||||||||||
| 1554 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1555 | - | |||||||||||||||||||||||||
| 1556 | QFontPrivate::detachButKeepEngineData(this); | - | ||||||||||||||||||||||||
| 1557 | - | |||||||||||||||||||||||||
| 1558 | d->capital = caps; | - | ||||||||||||||||||||||||
| 1559 | resolve_mask |= QFont::CapitalizationResolved; | - | ||||||||||||||||||||||||
| 1560 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1561 | - | |||||||||||||||||||||||||
| 1562 | /*! | - | ||||||||||||||||||||||||
| 1563 | \since 4.4 | - | ||||||||||||||||||||||||
| 1564 | Returns the current capitalization type of the font. | - | ||||||||||||||||||||||||
| 1565 | - | |||||||||||||||||||||||||
| 1566 | \sa setCapitalization() | - | ||||||||||||||||||||||||
| 1567 | */ | - | ||||||||||||||||||||||||
| 1568 | QFont::Capitalization QFont::capitalization() const | - | ||||||||||||||||||||||||
| 1569 | { | - | ||||||||||||||||||||||||
| 1570 | return static_cast<QFont::Capitalization> (d->capital); never executed: return static_cast<QFont::Capitalization> (d->capital); | 0 | ||||||||||||||||||||||||
| 1571 | } | - | ||||||||||||||||||||||||
| 1572 | - | |||||||||||||||||||||||||
| 1573 | #if QT_DEPRECATED_SINCE(5, 5) | - | ||||||||||||||||||||||||
| 1574 | /*! | - | ||||||||||||||||||||||||
| 1575 | \fn void QFont::setRawMode(bool enable) | - | ||||||||||||||||||||||||
| 1576 | \deprecated | - | ||||||||||||||||||||||||
| 1577 | - | |||||||||||||||||||||||||
| 1578 | If \a enable is true, turns raw mode on; otherwise turns raw mode | - | ||||||||||||||||||||||||
| 1579 | off. This function only has an effect under X11. | - | ||||||||||||||||||||||||
| 1580 | - | |||||||||||||||||||||||||
| 1581 | If raw mode is enabled, Qt will search for an X font with a | - | ||||||||||||||||||||||||
| 1582 | complete font name matching the family name, ignoring all other | - | ||||||||||||||||||||||||
| 1583 | values set for the QFont. If the font name matches several fonts, | - | ||||||||||||||||||||||||
| 1584 | Qt will use the first font returned by X. QFontInfo \e cannot be | - | ||||||||||||||||||||||||
| 1585 | used to fetch information about a QFont using raw mode (it will | - | ||||||||||||||||||||||||
| 1586 | return the values set in the QFont for all parameters, including | - | ||||||||||||||||||||||||
| 1587 | the family name). | - | ||||||||||||||||||||||||
| 1588 | - | |||||||||||||||||||||||||
| 1589 | \warning Enabling raw mode has no effect since Qt 5.0. | - | ||||||||||||||||||||||||
| 1590 | - | |||||||||||||||||||||||||
| 1591 | \sa rawMode() | - | ||||||||||||||||||||||||
| 1592 | */ | - | ||||||||||||||||||||||||
| 1593 | void QFont::setRawMode(bool) | - | ||||||||||||||||||||||||
| 1594 | { | - | ||||||||||||||||||||||||
| 1595 | } | - | ||||||||||||||||||||||||
| 1596 | #endif | - | ||||||||||||||||||||||||
| 1597 | - | |||||||||||||||||||||||||
| 1598 | /*! | - | ||||||||||||||||||||||||
| 1599 | Returns \c true if a window system font exactly matching the settings | - | ||||||||||||||||||||||||
| 1600 | of this font is available. | - | ||||||||||||||||||||||||
| 1601 | - | |||||||||||||||||||||||||
| 1602 | \sa QFontInfo | - | ||||||||||||||||||||||||
| 1603 | */ | - | ||||||||||||||||||||||||
| 1604 | bool QFont::exactMatch() const | - | ||||||||||||||||||||||||
| 1605 | { | - | ||||||||||||||||||||||||
| 1606 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 1607 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 1608 | return d->request.exactMatch(engine->fontDef); never executed: return d->request.exactMatch(engine->fontDef); | 0 | ||||||||||||||||||||||||
| 1609 | } | - | ||||||||||||||||||||||||
| 1610 | - | |||||||||||||||||||||||||
| 1611 | /*! | - | ||||||||||||||||||||||||
| 1612 | Returns \c true if this font is equal to \a f; otherwise returns | - | ||||||||||||||||||||||||
| 1613 | false. | - | ||||||||||||||||||||||||
| 1614 | - | |||||||||||||||||||||||||
| 1615 | Two QFonts are considered equal if their font attributes are | - | ||||||||||||||||||||||||
| 1616 | equal. | - | ||||||||||||||||||||||||
| 1617 | - | |||||||||||||||||||||||||
| 1618 | \sa operator!=(), isCopyOf() | - | ||||||||||||||||||||||||
| 1619 | */ | - | ||||||||||||||||||||||||
| 1620 | bool QFont::operator==(const QFont &f) const | - | ||||||||||||||||||||||||
| 1621 | { | - | ||||||||||||||||||||||||
| 1622 | return (f.d == d never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1623 | || (f.d->request == d->request never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1624 | && f.d->request.pointSize == d->request.pointSize never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1625 | && f.d->underline == d->underline never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1626 | && f.d->overline == d->overline never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1627 | && f.d->strikeOut == d->strikeOut never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1628 | && f.d->kerning == d->kerning never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1629 | && f.d->capital == d->capital never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1630 | && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1631 | && f.d->letterSpacing == d->letterSpacing never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1632 | && f.d->wordSpacing == d->wordSpacing never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing ));
| 0 | ||||||||||||||||||||||||
| 1633 | )); never executed: return (f.d == d || (f.d->request == d->request && f.d->request.pointSize == d->request.pointSize && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning && f.d->capital == d->capital && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute && f.d->letterSpacing == d->letterSpacing && f.d->wordSpacing == d->wordSpacing )); | 0 | ||||||||||||||||||||||||
| 1634 | } | - | ||||||||||||||||||||||||
| 1635 | - | |||||||||||||||||||||||||
| 1636 | - | |||||||||||||||||||||||||
| 1637 | /*! | - | ||||||||||||||||||||||||
| 1638 | Provides an arbitrary comparison of this font and font \a f. | - | ||||||||||||||||||||||||
| 1639 | All that is guaranteed is that the operator returns \c false if both | - | ||||||||||||||||||||||||
| 1640 | fonts are equal and that (f1 \< f2) == !(f2 \< f1) if the fonts | - | ||||||||||||||||||||||||
| 1641 | are not equal. | - | ||||||||||||||||||||||||
| 1642 | - | |||||||||||||||||||||||||
| 1643 | This function is useful in some circumstances, for example if you | - | ||||||||||||||||||||||||
| 1644 | want to use QFont objects as keys in a QMap. | - | ||||||||||||||||||||||||
| 1645 | - | |||||||||||||||||||||||||
| 1646 | \sa operator==(), operator!=(), isCopyOf() | - | ||||||||||||||||||||||||
| 1647 | */ | - | ||||||||||||||||||||||||
| 1648 | bool QFont::operator<(const QFont &f) const | - | ||||||||||||||||||||||||
| 1649 | { | - | ||||||||||||||||||||||||
| 1650 | if (f.d == d) return false; never executed: return false;
| 0 | ||||||||||||||||||||||||
| 1651 | // the < operator for fontdefs ignores point sizes. | - | ||||||||||||||||||||||||
| 1652 | QFontDef &r1 = f.d->request; | - | ||||||||||||||||||||||||
| 1653 | QFontDef &r2 = d->request; | - | ||||||||||||||||||||||||
| 1654 | if (r1.pointSize != r2.pointSize) return r1.pointSize < r2.pointSize; never executed: return r1.pointSize < r2.pointSize;
| 0 | ||||||||||||||||||||||||
| 1655 | if (r1.pixelSize != r2.pixelSize) return r1.pixelSize < r2.pixelSize; never executed: return r1.pixelSize < r2.pixelSize;
| 0 | ||||||||||||||||||||||||
| 1656 | if (r1.weight != r2.weight) return r1.weight < r2.weight; never executed: return r1.weight < r2.weight;
| 0 | ||||||||||||||||||||||||
| 1657 | if (r1.style != r2.style) return r1.style < r2.style; never executed: return r1.style < r2.style;
| 0 | ||||||||||||||||||||||||
| 1658 | if (r1.stretch != r2.stretch) return r1.stretch < r2.stretch; never executed: return r1.stretch < r2.stretch;
| 0 | ||||||||||||||||||||||||
| 1659 | if (r1.styleHint != r2.styleHint) return r1.styleHint < r2.styleHint; never executed: return r1.styleHint < r2.styleHint;
| 0 | ||||||||||||||||||||||||
| 1660 | if (r1.styleStrategy != r2.styleStrategy) return r1.styleStrategy < r2.styleStrategy; never executed: return r1.styleStrategy < r2.styleStrategy;
| 0 | ||||||||||||||||||||||||
| 1661 | if (r1.family != r2.family) return r1.family < r2.family; never executed: return r1.family < r2.family;
| 0 | ||||||||||||||||||||||||
| 1662 | if (f.d->capital != d->capital) return f.d->capital < d->capital; never executed: return f.d->capital < d->capital;
| 0 | ||||||||||||||||||||||||
| 1663 | - | |||||||||||||||||||||||||
| 1664 | if (f.d->letterSpacingIsAbsolute != d->letterSpacingIsAbsolute) return f.d->letterSpacingIsAbsolute < d->letterSpacingIsAbsolute; never executed: return f.d->letterSpacingIsAbsolute < d->letterSpacingIsAbsolute;
| 0 | ||||||||||||||||||||||||
| 1665 | if (f.d->letterSpacing != d->letterSpacing) return f.d->letterSpacing < d->letterSpacing; never executed: return f.d->letterSpacing < d->letterSpacing;
| 0 | ||||||||||||||||||||||||
| 1666 | if (f.d->wordSpacing != d->wordSpacing) return f.d->wordSpacing < d->wordSpacing; never executed: return f.d->wordSpacing < d->wordSpacing;
| 0 | ||||||||||||||||||||||||
| 1667 | - | |||||||||||||||||||||||||
| 1668 | int f1attrs = (f.d->underline << 3) + (f.d->overline << 2) + (f.d->strikeOut<<1) + f.d->kerning; | - | ||||||||||||||||||||||||
| 1669 | int f2attrs = (d->underline << 3) + (d->overline << 2) + (d->strikeOut<<1) + d->kerning; | - | ||||||||||||||||||||||||
| 1670 | return f1attrs < f2attrs; never executed: return f1attrs < f2attrs; | 0 | ||||||||||||||||||||||||
| 1671 | } | - | ||||||||||||||||||||||||
| 1672 | - | |||||||||||||||||||||||||
| 1673 | - | |||||||||||||||||||||||||
| 1674 | /*! | - | ||||||||||||||||||||||||
| 1675 | Returns \c true if this font is different from \a f; otherwise | - | ||||||||||||||||||||||||
| 1676 | returns \c false. | - | ||||||||||||||||||||||||
| 1677 | - | |||||||||||||||||||||||||
| 1678 | Two QFonts are considered to be different if their font attributes | - | ||||||||||||||||||||||||
| 1679 | are different. | - | ||||||||||||||||||||||||
| 1680 | - | |||||||||||||||||||||||||
| 1681 | \sa operator==() | - | ||||||||||||||||||||||||
| 1682 | */ | - | ||||||||||||||||||||||||
| 1683 | bool QFont::operator!=(const QFont &f) const | - | ||||||||||||||||||||||||
| 1684 | { | - | ||||||||||||||||||||||||
| 1685 | return !(operator==(f)); never executed: return !(operator==(f)); | 0 | ||||||||||||||||||||||||
| 1686 | } | - | ||||||||||||||||||||||||
| 1687 | - | |||||||||||||||||||||||||
| 1688 | /*! | - | ||||||||||||||||||||||||
| 1689 | Returns the font as a QVariant | - | ||||||||||||||||||||||||
| 1690 | */ | - | ||||||||||||||||||||||||
| 1691 | QFont::operator QVariant() const | - | ||||||||||||||||||||||||
| 1692 | { | - | ||||||||||||||||||||||||
| 1693 | return QVariant(QVariant::Font, this); never executed: return QVariant(QVariant::Font, this); | 0 | ||||||||||||||||||||||||
| 1694 | } | - | ||||||||||||||||||||||||
| 1695 | - | |||||||||||||||||||||||||
| 1696 | /*! | - | ||||||||||||||||||||||||
| 1697 | Returns \c true if this font and \a f are copies of each other, i.e. | - | ||||||||||||||||||||||||
| 1698 | one of them was created as a copy of the other and neither has | - | ||||||||||||||||||||||||
| 1699 | been modified since. This is much stricter than equality. | - | ||||||||||||||||||||||||
| 1700 | - | |||||||||||||||||||||||||
| 1701 | \sa operator=(), operator==() | - | ||||||||||||||||||||||||
| 1702 | */ | - | ||||||||||||||||||||||||
| 1703 | bool QFont::isCopyOf(const QFont & f) const | - | ||||||||||||||||||||||||
| 1704 | { | - | ||||||||||||||||||||||||
| 1705 | return d == f.d; never executed: return d == f.d; | 0 | ||||||||||||||||||||||||
| 1706 | } | - | ||||||||||||||||||||||||
| 1707 | - | |||||||||||||||||||||||||
| 1708 | #if QT_DEPRECATED_SINCE(5, 5) | - | ||||||||||||||||||||||||
| 1709 | /*! | - | ||||||||||||||||||||||||
| 1710 | \deprecated | - | ||||||||||||||||||||||||
| 1711 | - | |||||||||||||||||||||||||
| 1712 | Returns \c true if raw mode is used for font name matching; otherwise | - | ||||||||||||||||||||||||
| 1713 | returns \c false. | - | ||||||||||||||||||||||||
| 1714 | - | |||||||||||||||||||||||||
| 1715 | \sa setRawMode() | - | ||||||||||||||||||||||||
| 1716 | */ | - | ||||||||||||||||||||||||
| 1717 | bool QFont::rawMode() const | - | ||||||||||||||||||||||||
| 1718 | { | - | ||||||||||||||||||||||||
| 1719 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 1720 | } | - | ||||||||||||||||||||||||
| 1721 | #endif | - | ||||||||||||||||||||||||
| 1722 | - | |||||||||||||||||||||||||
| 1723 | /*! | - | ||||||||||||||||||||||||
| 1724 | Returns a new QFont that has attributes copied from \a other that | - | ||||||||||||||||||||||||
| 1725 | have not been previously set on this font. | - | ||||||||||||||||||||||||
| 1726 | */ | - | ||||||||||||||||||||||||
| 1727 | QFont QFont::resolve(const QFont &other) const | - | ||||||||||||||||||||||||
| 1728 | { | - | ||||||||||||||||||||||||
| 1729 | if (resolve_mask == 0 || (resolve_mask == other.resolve_mask && *this == other)) {
| 0 | ||||||||||||||||||||||||
| 1730 | QFont o(other); | - | ||||||||||||||||||||||||
| 1731 | o.resolve_mask = resolve_mask; | - | ||||||||||||||||||||||||
| 1732 | return o; never executed: return o; | 0 | ||||||||||||||||||||||||
| 1733 | } | - | ||||||||||||||||||||||||
| 1734 | - | |||||||||||||||||||||||||
| 1735 | QFont font(*this); | - | ||||||||||||||||||||||||
| 1736 | font.detach(); | - | ||||||||||||||||||||||||
| 1737 | font.d->resolve(resolve_mask, other.d.data()); | - | ||||||||||||||||||||||||
| 1738 | - | |||||||||||||||||||||||||
| 1739 | return font; never executed: return font; | 0 | ||||||||||||||||||||||||
| 1740 | } | - | ||||||||||||||||||||||||
| 1741 | - | |||||||||||||||||||||||||
| 1742 | /*! | - | ||||||||||||||||||||||||
| 1743 | \fn uint QFont::resolve() const | - | ||||||||||||||||||||||||
| 1744 | \internal | - | ||||||||||||||||||||||||
| 1745 | */ | - | ||||||||||||||||||||||||
| 1746 | - | |||||||||||||||||||||||||
| 1747 | /*! | - | ||||||||||||||||||||||||
| 1748 | \fn void QFont::resolve(uint mask) | - | ||||||||||||||||||||||||
| 1749 | \internal | - | ||||||||||||||||||||||||
| 1750 | */ | - | ||||||||||||||||||||||||
| 1751 | - | |||||||||||||||||||||||||
| 1752 | - | |||||||||||||||||||||||||
| 1753 | /***************************************************************************** | - | ||||||||||||||||||||||||
| 1754 | QFont substitution management | - | ||||||||||||||||||||||||
| 1755 | *****************************************************************************/ | - | ||||||||||||||||||||||||
| 1756 | - | |||||||||||||||||||||||||
| 1757 | typedef QHash<QString, QStringList> QFontSubst; | - | ||||||||||||||||||||||||
| 1758 | Q_GLOBAL_STATIC(QFontSubst, globalFontSubst) never executed: end of blocknever executed: guard.store(QtGlobalStatic::Destroyed);never executed: return &holder.value;
| 0 | ||||||||||||||||||||||||
| 1759 | - | |||||||||||||||||||||||||
| 1760 | /*! | - | ||||||||||||||||||||||||
| 1761 | Returns the first family name to be used whenever \a familyName is | - | ||||||||||||||||||||||||
| 1762 | specified. The lookup is case insensitive. | - | ||||||||||||||||||||||||
| 1763 | - | |||||||||||||||||||||||||
| 1764 | If there is no substitution for \a familyName, \a familyName is | - | ||||||||||||||||||||||||
| 1765 | returned. | - | ||||||||||||||||||||||||
| 1766 | - | |||||||||||||||||||||||||
| 1767 | To obtain a list of substitutions use substitutes(). | - | ||||||||||||||||||||||||
| 1768 | - | |||||||||||||||||||||||||
| 1769 | \sa setFamily(), insertSubstitutions(), insertSubstitution(), removeSubstitutions() | - | ||||||||||||||||||||||||
| 1770 | */ | - | ||||||||||||||||||||||||
| 1771 | QString QFont::substitute(const QString &familyName) | - | ||||||||||||||||||||||||
| 1772 | { | - | ||||||||||||||||||||||||
| 1773 | QFontSubst *fontSubst = globalFontSubst(); | - | ||||||||||||||||||||||||
| 1774 | Q_ASSERT(fontSubst != 0); | - | ||||||||||||||||||||||||
| 1775 | QFontSubst::ConstIterator it = fontSubst->constFind(familyName.toLower()); | - | ||||||||||||||||||||||||
| 1776 | if (it != fontSubst->constEnd() && !(*it).isEmpty())
| 0 | ||||||||||||||||||||||||
| 1777 | return (*it).first(); never executed: return (*it).first(); | 0 | ||||||||||||||||||||||||
| 1778 | - | |||||||||||||||||||||||||
| 1779 | return familyName; never executed: return familyName; | 0 | ||||||||||||||||||||||||
| 1780 | } | - | ||||||||||||||||||||||||
| 1781 | - | |||||||||||||||||||||||||
| 1782 | - | |||||||||||||||||||||||||
| 1783 | /*! | - | ||||||||||||||||||||||||
| 1784 | Returns a list of family names to be used whenever \a familyName | - | ||||||||||||||||||||||||
| 1785 | is specified. The lookup is case insensitive. | - | ||||||||||||||||||||||||
| 1786 | - | |||||||||||||||||||||||||
| 1787 | If there is no substitution for \a familyName, an empty list is | - | ||||||||||||||||||||||||
| 1788 | returned. | - | ||||||||||||||||||||||||
| 1789 | - | |||||||||||||||||||||||||
| 1790 | \sa substitute(), insertSubstitutions(), insertSubstitution(), removeSubstitutions() | - | ||||||||||||||||||||||||
| 1791 | */ | - | ||||||||||||||||||||||||
| 1792 | QStringList QFont::substitutes(const QString &familyName) | - | ||||||||||||||||||||||||
| 1793 | { | - | ||||||||||||||||||||||||
| 1794 | QFontSubst *fontSubst = globalFontSubst(); | - | ||||||||||||||||||||||||
| 1795 | Q_ASSERT(fontSubst != 0); | - | ||||||||||||||||||||||||
| 1796 | return fontSubst->value(familyName.toLower(), QStringList()); never executed: return fontSubst->value(familyName.toLower(), QStringList()); | 0 | ||||||||||||||||||||||||
| 1797 | } | - | ||||||||||||||||||||||||
| 1798 | - | |||||||||||||||||||||||||
| 1799 | - | |||||||||||||||||||||||||
| 1800 | /*! | - | ||||||||||||||||||||||||
| 1801 | Inserts \a substituteName into the substitution | - | ||||||||||||||||||||||||
| 1802 | table for the family \a familyName. | - | ||||||||||||||||||||||||
| 1803 | - | |||||||||||||||||||||||||
| 1804 | \sa insertSubstitutions(), removeSubstitutions(), substitutions(), substitute(), substitutes() | - | ||||||||||||||||||||||||
| 1805 | */ | - | ||||||||||||||||||||||||
| 1806 | void QFont::insertSubstitution(const QString &familyName, | - | ||||||||||||||||||||||||
| 1807 | const QString &substituteName) | - | ||||||||||||||||||||||||
| 1808 | { | - | ||||||||||||||||||||||||
| 1809 | QFontSubst *fontSubst = globalFontSubst(); | - | ||||||||||||||||||||||||
| 1810 | Q_ASSERT(fontSubst != 0); | - | ||||||||||||||||||||||||
| 1811 | QStringList &list = (*fontSubst)[familyName.toLower()]; | - | ||||||||||||||||||||||||
| 1812 | QString s = substituteName.toLower(); | - | ||||||||||||||||||||||||
| 1813 | if (!list.contains(s))
| 0 | ||||||||||||||||||||||||
| 1814 | list.append(s); never executed: list.append(s); | 0 | ||||||||||||||||||||||||
| 1815 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1816 | - | |||||||||||||||||||||||||
| 1817 | - | |||||||||||||||||||||||||
| 1818 | /*! | - | ||||||||||||||||||||||||
| 1819 | Inserts the list of families \a substituteNames into the | - | ||||||||||||||||||||||||
| 1820 | substitution list for \a familyName. | - | ||||||||||||||||||||||||
| 1821 | - | |||||||||||||||||||||||||
| 1822 | \sa insertSubstitution(), removeSubstitutions(), substitutions(), substitute() | - | ||||||||||||||||||||||||
| 1823 | */ | - | ||||||||||||||||||||||||
| 1824 | void QFont::insertSubstitutions(const QString &familyName, | - | ||||||||||||||||||||||||
| 1825 | const QStringList &substituteNames) | - | ||||||||||||||||||||||||
| 1826 | { | - | ||||||||||||||||||||||||
| 1827 | QFontSubst *fontSubst = globalFontSubst(); | - | ||||||||||||||||||||||||
| 1828 | Q_ASSERT(fontSubst != 0); | - | ||||||||||||||||||||||||
| 1829 | QStringList &list = (*fontSubst)[familyName.toLower()]; | - | ||||||||||||||||||||||||
| 1830 | foreach (const QString &substituteName, substituteNames) { | - | ||||||||||||||||||||||||
| 1831 | const QString lowerSubstituteName = substituteName.toLower(); | - | ||||||||||||||||||||||||
| 1832 | if (!list.contains(lowerSubstituteName))
| 0 | ||||||||||||||||||||||||
| 1833 | list.append(lowerSubstituteName); never executed: list.append(lowerSubstituteName); | 0 | ||||||||||||||||||||||||
| 1834 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1835 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1836 | - | |||||||||||||||||||||||||
| 1837 | /*! | - | ||||||||||||||||||||||||
| 1838 | Removes all the substitutions for \a familyName. | - | ||||||||||||||||||||||||
| 1839 | - | |||||||||||||||||||||||||
| 1840 | \sa insertSubstitutions(), insertSubstitution(), substitutions(), substitute() | - | ||||||||||||||||||||||||
| 1841 | \since 5.0 | - | ||||||||||||||||||||||||
| 1842 | */ | - | ||||||||||||||||||||||||
| 1843 | void QFont::removeSubstitutions(const QString &familyName) | - | ||||||||||||||||||||||||
| 1844 | { | - | ||||||||||||||||||||||||
| 1845 | QFontSubst *fontSubst = globalFontSubst(); | - | ||||||||||||||||||||||||
| 1846 | Q_ASSERT(fontSubst != 0); | - | ||||||||||||||||||||||||
| 1847 | fontSubst->remove(familyName.toLower()); | - | ||||||||||||||||||||||||
| 1848 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1849 | - | |||||||||||||||||||||||||
| 1850 | /*! | - | ||||||||||||||||||||||||
| 1851 | \fn void QFont::removeSubstitution(const QString &familyName) | - | ||||||||||||||||||||||||
| 1852 | - | |||||||||||||||||||||||||
| 1853 | \obsolete | - | ||||||||||||||||||||||||
| 1854 | - | |||||||||||||||||||||||||
| 1855 | This function is deprecated. Use removeSubstitutions() instead. | - | ||||||||||||||||||||||||
| 1856 | */ | - | ||||||||||||||||||||||||
| 1857 | - | |||||||||||||||||||||||||
| 1858 | /*! | - | ||||||||||||||||||||||||
| 1859 | Returns a sorted list of substituted family names. | - | ||||||||||||||||||||||||
| 1860 | - | |||||||||||||||||||||||||
| 1861 | \sa insertSubstitution(), removeSubstitution(), substitute() | - | ||||||||||||||||||||||||
| 1862 | */ | - | ||||||||||||||||||||||||
| 1863 | QStringList QFont::substitutions() | - | ||||||||||||||||||||||||
| 1864 | { | - | ||||||||||||||||||||||||
| 1865 | QFontSubst *fontSubst = globalFontSubst(); | - | ||||||||||||||||||||||||
| 1866 | Q_ASSERT(fontSubst != 0); | - | ||||||||||||||||||||||||
| 1867 | QStringList ret = fontSubst->keys(); | - | ||||||||||||||||||||||||
| 1868 | - | |||||||||||||||||||||||||
| 1869 | ret.sort(); | - | ||||||||||||||||||||||||
| 1870 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1871 | } | - | ||||||||||||||||||||||||
| 1872 | - | |||||||||||||||||||||||||
| 1873 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 1874 | /* \internal | - | ||||||||||||||||||||||||
| 1875 | Internal function. Converts boolean font settings to an unsigned | - | ||||||||||||||||||||||||
| 1876 | 8-bit number. Used for serialization etc. | - | ||||||||||||||||||||||||
| 1877 | */ | - | ||||||||||||||||||||||||
| 1878 | static quint8 get_font_bits(int version, const QFontPrivate *f) | - | ||||||||||||||||||||||||
| 1879 | { | - | ||||||||||||||||||||||||
| 1880 | Q_ASSERT(f != 0); | - | ||||||||||||||||||||||||
| 1881 | quint8 bits = 0; | - | ||||||||||||||||||||||||
| 1882 | if (f->request.style)
| 0 | ||||||||||||||||||||||||
| 1883 | bits |= 0x01; never executed: bits |= 0x01; | 0 | ||||||||||||||||||||||||
| 1884 | if (f->underline)
| 0 | ||||||||||||||||||||||||
| 1885 | bits |= 0x02; never executed: bits |= 0x02; | 0 | ||||||||||||||||||||||||
| 1886 | if (f->overline)
| 0 | ||||||||||||||||||||||||
| 1887 | bits |= 0x40; never executed: bits |= 0x40; | 0 | ||||||||||||||||||||||||
| 1888 | if (f->strikeOut)
| 0 | ||||||||||||||||||||||||
| 1889 | bits |= 0x04; never executed: bits |= 0x04; | 0 | ||||||||||||||||||||||||
| 1890 | if (f->request.fixedPitch)
| 0 | ||||||||||||||||||||||||
| 1891 | bits |= 0x08; never executed: bits |= 0x08; | 0 | ||||||||||||||||||||||||
| 1892 | // if (f.hintSetByUser) | - | ||||||||||||||||||||||||
| 1893 | // bits |= 0x10; | - | ||||||||||||||||||||||||
| 1894 | if (version >= QDataStream::Qt_4_0) {
| 0 | ||||||||||||||||||||||||
| 1895 | if (f->kerning)
| 0 | ||||||||||||||||||||||||
| 1896 | bits |= 0x10; never executed: bits |= 0x10; | 0 | ||||||||||||||||||||||||
| 1897 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1898 | if (f->request.style == QFont::StyleOblique)
| 0 | ||||||||||||||||||||||||
| 1899 | bits |= 0x80; never executed: bits |= 0x80; | 0 | ||||||||||||||||||||||||
| 1900 | return bits; never executed: return bits; | 0 | ||||||||||||||||||||||||
| 1901 | } | - | ||||||||||||||||||||||||
| 1902 | - | |||||||||||||||||||||||||
| 1903 | static quint8 get_extended_font_bits(const QFontPrivate *f) | - | ||||||||||||||||||||||||
| 1904 | { | - | ||||||||||||||||||||||||
| 1905 | Q_ASSERT(f != 0); | - | ||||||||||||||||||||||||
| 1906 | quint8 bits = 0; | - | ||||||||||||||||||||||||
| 1907 | if (f->request.ignorePitch)
| 0 | ||||||||||||||||||||||||
| 1908 | bits |= 0x01; never executed: bits |= 0x01; | 0 | ||||||||||||||||||||||||
| 1909 | if (f->letterSpacingIsAbsolute)
| 0 | ||||||||||||||||||||||||
| 1910 | bits |= 0x02; never executed: bits |= 0x02; | 0 | ||||||||||||||||||||||||
| 1911 | return bits; never executed: return bits; | 0 | ||||||||||||||||||||||||
| 1912 | } | - | ||||||||||||||||||||||||
| 1913 | - | |||||||||||||||||||||||||
| 1914 | /* \internal | - | ||||||||||||||||||||||||
| 1915 | Internal function. Sets boolean font settings from an unsigned | - | ||||||||||||||||||||||||
| 1916 | 8-bit number. Used for serialization etc. | - | ||||||||||||||||||||||||
| 1917 | */ | - | ||||||||||||||||||||||||
| 1918 | static void set_font_bits(int version, quint8 bits, QFontPrivate *f) | - | ||||||||||||||||||||||||
| 1919 | { | - | ||||||||||||||||||||||||
| 1920 | Q_ASSERT(f != 0); | - | ||||||||||||||||||||||||
| 1921 | f->request.style = (bits & 0x01) != 0 ? QFont::StyleItalic : QFont::StyleNormal;
| 0 | ||||||||||||||||||||||||
| 1922 | f->underline = (bits & 0x02) != 0; | - | ||||||||||||||||||||||||
| 1923 | f->overline = (bits & 0x40) != 0; | - | ||||||||||||||||||||||||
| 1924 | f->strikeOut = (bits & 0x04) != 0; | - | ||||||||||||||||||||||||
| 1925 | f->request.fixedPitch = (bits & 0x08) != 0; | - | ||||||||||||||||||||||||
| 1926 | // f->hintSetByUser = (bits & 0x10) != 0; | - | ||||||||||||||||||||||||
| 1927 | if (version >= QDataStream::Qt_4_0)
| 0 | ||||||||||||||||||||||||
| 1928 | f->kerning = (bits & 0x10) != 0; never executed: f->kerning = (bits & 0x10) != 0; | 0 | ||||||||||||||||||||||||
| 1929 | if ((bits & 0x80) != 0)
| 0 | ||||||||||||||||||||||||
| 1930 | f->request.style = QFont::StyleOblique; never executed: f->request.style = QFont::StyleOblique; | 0 | ||||||||||||||||||||||||
| 1931 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1932 | - | |||||||||||||||||||||||||
| 1933 | static void set_extended_font_bits(quint8 bits, QFontPrivate *f) | - | ||||||||||||||||||||||||
| 1934 | { | - | ||||||||||||||||||||||||
| 1935 | Q_ASSERT(f != 0); | - | ||||||||||||||||||||||||
| 1936 | f->request.ignorePitch = (bits & 0x01) != 0; | - | ||||||||||||||||||||||||
| 1937 | f->letterSpacingIsAbsolute = (bits & 0x02) != 0; | - | ||||||||||||||||||||||||
| 1938 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1939 | #endif | - | ||||||||||||||||||||||||
| 1940 | - | |||||||||||||||||||||||||
| 1941 | #if QT_DEPRECATED_SINCE(5, 3) | - | ||||||||||||||||||||||||
| 1942 | /*! | - | ||||||||||||||||||||||||
| 1943 | \fn QString QFont::rawName() const | - | ||||||||||||||||||||||||
| 1944 | \deprecated | - | ||||||||||||||||||||||||
| 1945 | - | |||||||||||||||||||||||||
| 1946 | Returns the name of the font within the underlying window system. | - | ||||||||||||||||||||||||
| 1947 | - | |||||||||||||||||||||||||
| 1948 | On X11, this function will return an empty string. | - | ||||||||||||||||||||||||
| 1949 | - | |||||||||||||||||||||||||
| 1950 | Using the return value of this function is usually \e not \e | - | ||||||||||||||||||||||||
| 1951 | portable. | - | ||||||||||||||||||||||||
| 1952 | - | |||||||||||||||||||||||||
| 1953 | \sa setRawName() | - | ||||||||||||||||||||||||
| 1954 | */ | - | ||||||||||||||||||||||||
| 1955 | QString QFont::rawName() const | - | ||||||||||||||||||||||||
| 1956 | { | - | ||||||||||||||||||||||||
| 1957 | return QLatin1String("unknown"); never executed: return QLatin1String("unknown"); | 0 | ||||||||||||||||||||||||
| 1958 | } | - | ||||||||||||||||||||||||
| 1959 | - | |||||||||||||||||||||||||
| 1960 | /*! | - | ||||||||||||||||||||||||
| 1961 | \fn void QFont::setRawName(const QString &name) | - | ||||||||||||||||||||||||
| 1962 | \deprecated | - | ||||||||||||||||||||||||
| 1963 | - | |||||||||||||||||||||||||
| 1964 | Sets a font by its system specific name. | - | ||||||||||||||||||||||||
| 1965 | - | |||||||||||||||||||||||||
| 1966 | A font set with setRawName() is still a full-featured QFont. It can | - | ||||||||||||||||||||||||
| 1967 | be queried (for example with italic()) or modified (for example with | - | ||||||||||||||||||||||||
| 1968 | setItalic()) and is therefore also suitable for rendering rich text. | - | ||||||||||||||||||||||||
| 1969 | - | |||||||||||||||||||||||||
| 1970 | If Qt's internal font database cannot resolve the raw name, the | - | ||||||||||||||||||||||||
| 1971 | font becomes a raw font with \a name as its family. | - | ||||||||||||||||||||||||
| 1972 | - | |||||||||||||||||||||||||
| 1973 | \sa rawName(), setFamily() | - | ||||||||||||||||||||||||
| 1974 | */ | - | ||||||||||||||||||||||||
| 1975 | void QFont::setRawName(const QString &) | - | ||||||||||||||||||||||||
| 1976 | { | - | ||||||||||||||||||||||||
| 1977 | } | - | ||||||||||||||||||||||||
| 1978 | #endif | - | ||||||||||||||||||||||||
| 1979 | - | |||||||||||||||||||||||||
| 1980 | /*! | - | ||||||||||||||||||||||||
| 1981 | Returns the font's key, a textual representation of a font. It is | - | ||||||||||||||||||||||||
| 1982 | typically used as the key for a cache or dictionary of fonts. | - | ||||||||||||||||||||||||
| 1983 | - | |||||||||||||||||||||||||
| 1984 | \sa QMap | - | ||||||||||||||||||||||||
| 1985 | */ | - | ||||||||||||||||||||||||
| 1986 | QString QFont::key() const | - | ||||||||||||||||||||||||
| 1987 | { | - | ||||||||||||||||||||||||
| 1988 | return toString(); never executed: return toString(); | 0 | ||||||||||||||||||||||||
| 1989 | } | - | ||||||||||||||||||||||||
| 1990 | - | |||||||||||||||||||||||||
| 1991 | /*! | - | ||||||||||||||||||||||||
| 1992 | Returns a description of the font. The description is a | - | ||||||||||||||||||||||||
| 1993 | comma-separated list of the attributes, perfectly suited for use | - | ||||||||||||||||||||||||
| 1994 | in QSettings. | - | ||||||||||||||||||||||||
| 1995 | - | |||||||||||||||||||||||||
| 1996 | \sa fromString() | - | ||||||||||||||||||||||||
| 1997 | */ | - | ||||||||||||||||||||||||
| 1998 | QString QFont::toString() const | - | ||||||||||||||||||||||||
| 1999 | { | - | ||||||||||||||||||||||||
| 2000 | const QChar comma(QLatin1Char(',')); | - | ||||||||||||||||||||||||
| 2001 | return family() + comma + never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2002 | QString::number( pointSizeF()) + comma + never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2003 | QString::number( pixelSize()) + comma + never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2004 | QString::number((int) styleHint()) + comma + never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2005 | QString::number( weight()) + comma + never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2006 | QString::number((int) style()) + comma + never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2007 | QString::number((int) underline()) + comma + never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2008 | QString::number((int) strikeOut()) + comma + never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2009 | QString::number((int)fixedPitch()) + comma + never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2010 | QString::number((int) false); never executed: return family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + QString::number( weight()) + comma + QString::number((int) style()) + comma + QString::number((int) underline()) + comma + QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); | 0 | ||||||||||||||||||||||||
| 2011 | } | - | ||||||||||||||||||||||||
| 2012 | - | |||||||||||||||||||||||||
| 2013 | /*! | - | ||||||||||||||||||||||||
| 2014 | Returns the hash value for \a font. If specified, \a seed is used | - | ||||||||||||||||||||||||
| 2015 | to initialize the hash. | - | ||||||||||||||||||||||||
| 2016 | - | |||||||||||||||||||||||||
| 2017 | \relates QFont | - | ||||||||||||||||||||||||
| 2018 | \since 5.3 | - | ||||||||||||||||||||||||
| 2019 | */ | - | ||||||||||||||||||||||||
| 2020 | uint qHash(const QFont &font, uint seed) Q_DECL_NOTHROW | - | ||||||||||||||||||||||||
| 2021 | { | - | ||||||||||||||||||||||||
| 2022 | return qHash(QFontPrivate::get(font)->request, seed); never executed: return qHash(QFontPrivate::get(font)->request, seed); | 0 | ||||||||||||||||||||||||
| 2023 | } | - | ||||||||||||||||||||||||
| 2024 | - | |||||||||||||||||||||||||
| 2025 | - | |||||||||||||||||||||||||
| 2026 | /*! | - | ||||||||||||||||||||||||
| 2027 | Sets this font to match the description \a descrip. The description | - | ||||||||||||||||||||||||
| 2028 | is a comma-separated list of the font attributes, as returned by | - | ||||||||||||||||||||||||
| 2029 | toString(). | - | ||||||||||||||||||||||||
| 2030 | - | |||||||||||||||||||||||||
| 2031 | \sa toString() | - | ||||||||||||||||||||||||
| 2032 | */ | - | ||||||||||||||||||||||||
| 2033 | bool QFont::fromString(const QString &descrip) | - | ||||||||||||||||||||||||
| 2034 | { | - | ||||||||||||||||||||||||
| 2035 | QStringList l(descrip.split(QLatin1Char(','))); | - | ||||||||||||||||||||||||
| 2036 | - | |||||||||||||||||||||||||
| 2037 | int count = l.count(); | - | ||||||||||||||||||||||||
| 2038 | if (!count || (count > 2 && count < 9) || count > 11) {
| 0 | ||||||||||||||||||||||||
| 2039 | qWarning("QFont::fromString: Invalid description '%s'", | - | ||||||||||||||||||||||||
| 2040 | descrip.isEmpty() ? "(empty)" : descrip.toLatin1().data()); | - | ||||||||||||||||||||||||
| 2041 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 2042 | } | - | ||||||||||||||||||||||||
| 2043 | - | |||||||||||||||||||||||||
| 2044 | setFamily(l[0]); | - | ||||||||||||||||||||||||
| 2045 | if (count > 1 && l[1].toDouble() > 0.0)
| 0 | ||||||||||||||||||||||||
| 2046 | setPointSizeF(l[1].toDouble()); never executed: setPointSizeF(l[1].toDouble()); | 0 | ||||||||||||||||||||||||
| 2047 | if (count == 9) {
| 0 | ||||||||||||||||||||||||
| 2048 | setStyleHint((StyleHint) l[2].toInt()); | - | ||||||||||||||||||||||||
| 2049 | setWeight(qMax(qMin(99, l[3].toInt()), 0)); | - | ||||||||||||||||||||||||
| 2050 | setItalic(l[4].toInt()); | - | ||||||||||||||||||||||||
| 2051 | setUnderline(l[5].toInt()); | - | ||||||||||||||||||||||||
| 2052 | setStrikeOut(l[6].toInt()); | - | ||||||||||||||||||||||||
| 2053 | setFixedPitch(l[7].toInt()); | - | ||||||||||||||||||||||||
| 2054 | } else if (count == 10) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 2055 | if (l[2].toInt() > 0)
| 0 | ||||||||||||||||||||||||
| 2056 | setPixelSize(l[2].toInt()); never executed: setPixelSize(l[2].toInt()); | 0 | ||||||||||||||||||||||||
| 2057 | setStyleHint((StyleHint) l[3].toInt()); | - | ||||||||||||||||||||||||
| 2058 | setWeight(qMax(qMin(99, l[4].toInt()), 0)); | - | ||||||||||||||||||||||||
| 2059 | setStyle((QFont::Style)l[5].toInt()); | - | ||||||||||||||||||||||||
| 2060 | setUnderline(l[6].toInt()); | - | ||||||||||||||||||||||||
| 2061 | setStrikeOut(l[7].toInt()); | - | ||||||||||||||||||||||||
| 2062 | setFixedPitch(l[8].toInt()); | - | ||||||||||||||||||||||||
| 2063 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2064 | if (count >= 9 && !d->request.fixedPitch) // assume 'false' fixedPitch equals default
| 0 | ||||||||||||||||||||||||
| 2065 | d->request.ignorePitch = true; never executed: d->request.ignorePitch = true; | 0 | ||||||||||||||||||||||||
| 2066 | - | |||||||||||||||||||||||||
| 2067 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 2068 | } | - | ||||||||||||||||||||||||
| 2069 | - | |||||||||||||||||||||||||
| 2070 | /*! \fn void QFont::initialize() | - | ||||||||||||||||||||||||
| 2071 | \internal | - | ||||||||||||||||||||||||
| 2072 | - | |||||||||||||||||||||||||
| 2073 | Internal function that initializes the font system. The font cache | - | ||||||||||||||||||||||||
| 2074 | and font dict do not alloc the keys. The key is a QString which is | - | ||||||||||||||||||||||||
| 2075 | shared between QFontPrivate and QXFontName. | - | ||||||||||||||||||||||||
| 2076 | */ | - | ||||||||||||||||||||||||
| 2077 | void QFont::initialize() | - | ||||||||||||||||||||||||
| 2078 | { | - | ||||||||||||||||||||||||
| 2079 | } | - | ||||||||||||||||||||||||
| 2080 | - | |||||||||||||||||||||||||
| 2081 | /*! \fn void QFont::cleanup() | - | ||||||||||||||||||||||||
| 2082 | \internal | - | ||||||||||||||||||||||||
| 2083 | - | |||||||||||||||||||||||||
| 2084 | Internal function that cleans up the font system. | - | ||||||||||||||||||||||||
| 2085 | */ | - | ||||||||||||||||||||||||
| 2086 | void QFont::cleanup() | - | ||||||||||||||||||||||||
| 2087 | { | - | ||||||||||||||||||||||||
| 2088 | QFontCache::cleanup(); | - | ||||||||||||||||||||||||
| 2089 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2090 | - | |||||||||||||||||||||||||
| 2091 | /*! \internal | - | ||||||||||||||||||||||||
| 2092 | - | |||||||||||||||||||||||||
| 2093 | Internal function that dumps font cache statistics. | - | ||||||||||||||||||||||||
| 2094 | */ | - | ||||||||||||||||||||||||
| 2095 | void QFont::cacheStatistics() | - | ||||||||||||||||||||||||
| 2096 | { | - | ||||||||||||||||||||||||
| 2097 | } | - | ||||||||||||||||||||||||
| 2098 | - | |||||||||||||||||||||||||
| 2099 | /*! | - | ||||||||||||||||||||||||
| 2100 | \fn QString QFont::lastResortFamily() const | - | ||||||||||||||||||||||||
| 2101 | - | |||||||||||||||||||||||||
| 2102 | Returns the "last resort" font family name. | - | ||||||||||||||||||||||||
| 2103 | - | |||||||||||||||||||||||||
| 2104 | The current implementation tries a wide variety of common fonts, | - | ||||||||||||||||||||||||
| 2105 | returning the first one it finds. Is is possible that no family is | - | ||||||||||||||||||||||||
| 2106 | found in which case an empty string is returned. | - | ||||||||||||||||||||||||
| 2107 | - | |||||||||||||||||||||||||
| 2108 | \sa lastResortFont() | - | ||||||||||||||||||||||||
| 2109 | */ | - | ||||||||||||||||||||||||
| 2110 | QString QFont::lastResortFamily() const | - | ||||||||||||||||||||||||
| 2111 | { | - | ||||||||||||||||||||||||
| 2112 | return QString::fromLatin1("helvetica"); never executed: return QString::fromLatin1("helvetica"); | 0 | ||||||||||||||||||||||||
| 2113 | } | - | ||||||||||||||||||||||||
| 2114 | - | |||||||||||||||||||||||||
| 2115 | extern QStringList qt_fallbacksForFamily(const QString &family, QFont::Style style, | - | ||||||||||||||||||||||||
| 2116 | QFont::StyleHint styleHint, QChar::Script script); | - | ||||||||||||||||||||||||
| 2117 | - | |||||||||||||||||||||||||
| 2118 | /*! | - | ||||||||||||||||||||||||
| 2119 | \fn QString QFont::defaultFamily() const | - | ||||||||||||||||||||||||
| 2120 | - | |||||||||||||||||||||||||
| 2121 | Returns the family name that corresponds to the current style | - | ||||||||||||||||||||||||
| 2122 | hint. | - | ||||||||||||||||||||||||
| 2123 | - | |||||||||||||||||||||||||
| 2124 | \sa StyleHint, styleHint(), setStyleHint() | - | ||||||||||||||||||||||||
| 2125 | */ | - | ||||||||||||||||||||||||
| 2126 | QString QFont::defaultFamily() const | - | ||||||||||||||||||||||||
| 2127 | { | - | ||||||||||||||||||||||||
| 2128 | const QStringList fallbacks = qt_fallbacksForFamily(QString(), QFont::StyleNormal | - | ||||||||||||||||||||||||
| 2129 | , QFont::StyleHint(d->request.styleHint), QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2130 | if (!fallbacks.isEmpty())
| 0 | ||||||||||||||||||||||||
| 2131 | return fallbacks.first(); never executed: return fallbacks.first(); | 0 | ||||||||||||||||||||||||
| 2132 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 2133 | } | - | ||||||||||||||||||||||||
| 2134 | - | |||||||||||||||||||||||||
| 2135 | /*! | - | ||||||||||||||||||||||||
| 2136 | \fn QString QFont::lastResortFont() const | - | ||||||||||||||||||||||||
| 2137 | - | |||||||||||||||||||||||||
| 2138 | Returns a "last resort" font name for the font matching algorithm. | - | ||||||||||||||||||||||||
| 2139 | This is used if the last resort family is not available. It will | - | ||||||||||||||||||||||||
| 2140 | always return a name, if necessary returning something like | - | ||||||||||||||||||||||||
| 2141 | "fixed" or "system". | - | ||||||||||||||||||||||||
| 2142 | - | |||||||||||||||||||||||||
| 2143 | The current implementation tries a wide variety of common fonts, | - | ||||||||||||||||||||||||
| 2144 | returning the first one it finds. The implementation may change | - | ||||||||||||||||||||||||
| 2145 | at any time, but this function will always return a string | - | ||||||||||||||||||||||||
| 2146 | containing something. | - | ||||||||||||||||||||||||
| 2147 | - | |||||||||||||||||||||||||
| 2148 | It is theoretically possible that there really isn't a | - | ||||||||||||||||||||||||
| 2149 | lastResortFont() in which case Qt will abort with an error | - | ||||||||||||||||||||||||
| 2150 | message. We have not been able to identify a case where this | - | ||||||||||||||||||||||||
| 2151 | happens. Please \l{bughowto.html}{report it as a bug} if | - | ||||||||||||||||||||||||
| 2152 | it does, preferably with a list of the fonts you have installed. | - | ||||||||||||||||||||||||
| 2153 | - | |||||||||||||||||||||||||
| 2154 | \sa lastResortFamily() | - | ||||||||||||||||||||||||
| 2155 | */ | - | ||||||||||||||||||||||||
| 2156 | QString QFont::lastResortFont() const | - | ||||||||||||||||||||||||
| 2157 | { | - | ||||||||||||||||||||||||
| 2158 | qFatal("QFont::lastResortFont: Cannot find any reasonable font"); | - | ||||||||||||||||||||||||
| 2159 | // Shut compiler up | - | ||||||||||||||||||||||||
| 2160 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 2161 | } | - | ||||||||||||||||||||||||
| 2162 | - | |||||||||||||||||||||||||
| 2163 | /***************************************************************************** | - | ||||||||||||||||||||||||
| 2164 | QFont stream functions | - | ||||||||||||||||||||||||
| 2165 | *****************************************************************************/ | - | ||||||||||||||||||||||||
| 2166 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 2167 | - | |||||||||||||||||||||||||
| 2168 | /*! | - | ||||||||||||||||||||||||
| 2169 | \relates QFont | - | ||||||||||||||||||||||||
| 2170 | - | |||||||||||||||||||||||||
| 2171 | Writes the font \a font to the data stream \a s. (toString() | - | ||||||||||||||||||||||||
| 2172 | writes to a text stream.) | - | ||||||||||||||||||||||||
| 2173 | - | |||||||||||||||||||||||||
| 2174 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||||||||||||||
| 2175 | */ | - | ||||||||||||||||||||||||
| 2176 | QDataStream &operator<<(QDataStream &s, const QFont &font) | - | ||||||||||||||||||||||||
| 2177 | { | - | ||||||||||||||||||||||||
| 2178 | if (s.version() == 1) {
| 0 | ||||||||||||||||||||||||
| 2179 | s << font.d->request.family.toLatin1(); | - | ||||||||||||||||||||||||
| 2180 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2181 | s << font.d->request.family; | - | ||||||||||||||||||||||||
| 2182 | if (s.version() >= QDataStream::Qt_5_4)
| 0 | ||||||||||||||||||||||||
| 2183 | s << font.d->request.styleName; never executed: s << font.d->request.styleName; | 0 | ||||||||||||||||||||||||
| 2184 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2185 | - | |||||||||||||||||||||||||
| 2186 | if (s.version() >= QDataStream::Qt_4_0) {
| 0 | ||||||||||||||||||||||||
| 2187 | // 4.0 | - | ||||||||||||||||||||||||
| 2188 | double pointSize = font.d->request.pointSize; | - | ||||||||||||||||||||||||
| 2189 | qint32 pixelSize = font.d->request.pixelSize; | - | ||||||||||||||||||||||||
| 2190 | s << pointSize; | - | ||||||||||||||||||||||||
| 2191 | s << pixelSize; | - | ||||||||||||||||||||||||
| 2192 | } else if (s.version() <= 3) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 2193 | qint16 pointSize = (qint16) (font.d->request.pointSize * 10); | - | ||||||||||||||||||||||||
| 2194 | if (pointSize < 0) {
| 0 | ||||||||||||||||||||||||
| 2195 | pointSize = (qint16)QFontInfo(font).pointSize() * 10; | - | ||||||||||||||||||||||||
| 2196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2197 | s << pointSize; | - | ||||||||||||||||||||||||
| 2198 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2199 | s << (qint16) (font.d->request.pointSize * 10); | - | ||||||||||||||||||||||||
| 2200 | s << (qint16) font.d->request.pixelSize; | - | ||||||||||||||||||||||||
| 2201 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2202 | - | |||||||||||||||||||||||||
| 2203 | s << (quint8) font.d->request.styleHint; | - | ||||||||||||||||||||||||
| 2204 | if (s.version() >= QDataStream::Qt_3_1) {
| 0 | ||||||||||||||||||||||||
| 2205 | // Continue writing 8 bits for versions < 5.4 so that we don't write too much, | - | ||||||||||||||||||||||||
| 2206 | // even though we need 16 to store styleStrategy, so there is some data loss. | - | ||||||||||||||||||||||||
| 2207 | if (s.version() >= QDataStream::Qt_5_4)
| 0 | ||||||||||||||||||||||||
| 2208 | s << (quint16) font.d->request.styleStrategy; never executed: s << (quint16) font.d->request.styleStrategy; | 0 | ||||||||||||||||||||||||
| 2209 | else | - | ||||||||||||||||||||||||
| 2210 | s << (quint8) font.d->request.styleStrategy; never executed: s << (quint8) font.d->request.styleStrategy; | 0 | ||||||||||||||||||||||||
| 2211 | } | - | ||||||||||||||||||||||||
| 2212 | s << (quint8) 0 | - | ||||||||||||||||||||||||
| 2213 | << (quint8) font.d->request.weight | - | ||||||||||||||||||||||||
| 2214 | << get_font_bits(s.version(), font.d.data()); | - | ||||||||||||||||||||||||
| 2215 | if (s.version() >= QDataStream::Qt_4_3)
| 0 | ||||||||||||||||||||||||
| 2216 | s << (quint16)font.d->request.stretch; never executed: s << (quint16)font.d->request.stretch; | 0 | ||||||||||||||||||||||||
| 2217 | if (s.version() >= QDataStream::Qt_4_4)
| 0 | ||||||||||||||||||||||||
| 2218 | s << get_extended_font_bits(font.d.data()); never executed: s << get_extended_font_bits(font.d.data()); | 0 | ||||||||||||||||||||||||
| 2219 | if (s.version() >= QDataStream::Qt_4_5) {
| 0 | ||||||||||||||||||||||||
| 2220 | s << font.d->letterSpacing.value(); | - | ||||||||||||||||||||||||
| 2221 | s << font.d->wordSpacing.value(); | - | ||||||||||||||||||||||||
| 2222 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2223 | if (s.version() >= QDataStream::Qt_5_4)
| 0 | ||||||||||||||||||||||||
| 2224 | s << (quint8)font.d->request.hintingPreference; never executed: s << (quint8)font.d->request.hintingPreference; | 0 | ||||||||||||||||||||||||
| 2225 | if (s.version() >= QDataStream::Qt_5_6)
| 0 | ||||||||||||||||||||||||
| 2226 | s << (quint8)font.d->capital; never executed: s << (quint8)font.d->capital; | 0 | ||||||||||||||||||||||||
| 2227 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||
| 2228 | } | - | ||||||||||||||||||||||||
| 2229 | - | |||||||||||||||||||||||||
| 2230 | - | |||||||||||||||||||||||||
| 2231 | /*! | - | ||||||||||||||||||||||||
| 2232 | \relates QFont | - | ||||||||||||||||||||||||
| 2233 | - | |||||||||||||||||||||||||
| 2234 | Reads the font \a font from the data stream \a s. (fromString() | - | ||||||||||||||||||||||||
| 2235 | reads from a text stream.) | - | ||||||||||||||||||||||||
| 2236 | - | |||||||||||||||||||||||||
| 2237 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||||||||||||||
| 2238 | */ | - | ||||||||||||||||||||||||
| 2239 | QDataStream &operator>>(QDataStream &s, QFont &font) | - | ||||||||||||||||||||||||
| 2240 | { | - | ||||||||||||||||||||||||
| 2241 | font.d = new QFontPrivate; | - | ||||||||||||||||||||||||
| 2242 | font.resolve_mask = QFont::AllPropertiesResolved; | - | ||||||||||||||||||||||||
| 2243 | - | |||||||||||||||||||||||||
| 2244 | quint8 styleHint, charSet, weight, bits; | - | ||||||||||||||||||||||||
| 2245 | quint16 styleStrategy = QFont::PreferDefault; | - | ||||||||||||||||||||||||
| 2246 | - | |||||||||||||||||||||||||
| 2247 | if (s.version() == 1) {
| 0 | ||||||||||||||||||||||||
| 2248 | QByteArray fam; | - | ||||||||||||||||||||||||
| 2249 | s >> fam; | - | ||||||||||||||||||||||||
| 2250 | font.d->request.family = QString::fromLatin1(fam); | - | ||||||||||||||||||||||||
| 2251 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2252 | s >> font.d->request.family; | - | ||||||||||||||||||||||||
| 2253 | if (s.version() >= QDataStream::Qt_5_4)
| 0 | ||||||||||||||||||||||||
| 2254 | s >> font.d->request.styleName; never executed: s >> font.d->request.styleName; | 0 | ||||||||||||||||||||||||
| 2255 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2256 | - | |||||||||||||||||||||||||
| 2257 | if (s.version() >= QDataStream::Qt_4_0) {
| 0 | ||||||||||||||||||||||||
| 2258 | // 4.0 | - | ||||||||||||||||||||||||
| 2259 | double pointSize; | - | ||||||||||||||||||||||||
| 2260 | qint32 pixelSize; | - | ||||||||||||||||||||||||
| 2261 | s >> pointSize; | - | ||||||||||||||||||||||||
| 2262 | s >> pixelSize; | - | ||||||||||||||||||||||||
| 2263 | font.d->request.pointSize = qreal(pointSize); | - | ||||||||||||||||||||||||
| 2264 | font.d->request.pixelSize = pixelSize; | - | ||||||||||||||||||||||||
| 2265 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2266 | qint16 pointSize, pixelSize = -1; | - | ||||||||||||||||||||||||
| 2267 | s >> pointSize; | - | ||||||||||||||||||||||||
| 2268 | if (s.version() >= 4)
| 0 | ||||||||||||||||||||||||
| 2269 | s >> pixelSize; never executed: s >> pixelSize; | 0 | ||||||||||||||||||||||||
| 2270 | font.d->request.pointSize = qreal(pointSize / 10.); | - | ||||||||||||||||||||||||
| 2271 | font.d->request.pixelSize = pixelSize; | - | ||||||||||||||||||||||||
| 2272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2273 | s >> styleHint; | - | ||||||||||||||||||||||||
| 2274 | if (s.version() >= QDataStream::Qt_3_1) {
| 0 | ||||||||||||||||||||||||
| 2275 | if (s.version() >= QDataStream::Qt_5_4) {
| 0 | ||||||||||||||||||||||||
| 2276 | s >> styleStrategy; | - | ||||||||||||||||||||||||
| 2277 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2278 | quint8 tempStyleStrategy; | - | ||||||||||||||||||||||||
| 2279 | s >> tempStyleStrategy; | - | ||||||||||||||||||||||||
| 2280 | styleStrategy = tempStyleStrategy; | - | ||||||||||||||||||||||||
| 2281 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2282 | } | - | ||||||||||||||||||||||||
| 2283 | - | |||||||||||||||||||||||||
| 2284 | s >> charSet; | - | ||||||||||||||||||||||||
| 2285 | s >> weight; | - | ||||||||||||||||||||||||
| 2286 | s >> bits; | - | ||||||||||||||||||||||||
| 2287 | - | |||||||||||||||||||||||||
| 2288 | font.d->request.styleHint = styleHint; | - | ||||||||||||||||||||||||
| 2289 | font.d->request.styleStrategy = styleStrategy; | - | ||||||||||||||||||||||||
| 2290 | font.d->request.weight = weight; | - | ||||||||||||||||||||||||
| 2291 | - | |||||||||||||||||||||||||
| 2292 | set_font_bits(s.version(), bits, font.d.data()); | - | ||||||||||||||||||||||||
| 2293 | - | |||||||||||||||||||||||||
| 2294 | if (s.version() >= QDataStream::Qt_4_3) {
| 0 | ||||||||||||||||||||||||
| 2295 | quint16 stretch; | - | ||||||||||||||||||||||||
| 2296 | s >> stretch; | - | ||||||||||||||||||||||||
| 2297 | font.d->request.stretch = stretch; | - | ||||||||||||||||||||||||
| 2298 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2299 | - | |||||||||||||||||||||||||
| 2300 | if (s.version() >= QDataStream::Qt_4_4) {
| 0 | ||||||||||||||||||||||||
| 2301 | quint8 extendedBits; | - | ||||||||||||||||||||||||
| 2302 | s >> extendedBits; | - | ||||||||||||||||||||||||
| 2303 | set_extended_font_bits(extendedBits, font.d.data()); | - | ||||||||||||||||||||||||
| 2304 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2305 | if (s.version() >= QDataStream::Qt_4_5) {
| 0 | ||||||||||||||||||||||||
| 2306 | int value; | - | ||||||||||||||||||||||||
| 2307 | s >> value; | - | ||||||||||||||||||||||||
| 2308 | font.d->letterSpacing.setValue(value); | - | ||||||||||||||||||||||||
| 2309 | s >> value; | - | ||||||||||||||||||||||||
| 2310 | font.d->wordSpacing.setValue(value); | - | ||||||||||||||||||||||||
| 2311 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2312 | if (s.version() >= QDataStream::Qt_5_4) {
| 0 | ||||||||||||||||||||||||
| 2313 | quint8 value; | - | ||||||||||||||||||||||||
| 2314 | s >> value; | - | ||||||||||||||||||||||||
| 2315 | font.d->request.hintingPreference = QFont::HintingPreference(value); | - | ||||||||||||||||||||||||
| 2316 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2317 | if (s.version() >= QDataStream::Qt_5_6) {
| 0 | ||||||||||||||||||||||||
| 2318 | quint8 value; | - | ||||||||||||||||||||||||
| 2319 | s >> value; | - | ||||||||||||||||||||||||
| 2320 | font.d->capital = QFont::Capitalization(value); | - | ||||||||||||||||||||||||
| 2321 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2322 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||
| 2323 | } | - | ||||||||||||||||||||||||
| 2324 | - | |||||||||||||||||||||||||
| 2325 | #endif // QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 2326 | - | |||||||||||||||||||||||||
| 2327 | - | |||||||||||||||||||||||||
| 2328 | /***************************************************************************** | - | ||||||||||||||||||||||||
| 2329 | QFontInfo member functions | - | ||||||||||||||||||||||||
| 2330 | *****************************************************************************/ | - | ||||||||||||||||||||||||
| 2331 | - | |||||||||||||||||||||||||
| 2332 | /*! | - | ||||||||||||||||||||||||
| 2333 | \class QFontInfo | - | ||||||||||||||||||||||||
| 2334 | \reentrant | - | ||||||||||||||||||||||||
| 2335 | - | |||||||||||||||||||||||||
| 2336 | \brief The QFontInfo class provides general information about fonts. | - | ||||||||||||||||||||||||
| 2337 | \inmodule QtGui | - | ||||||||||||||||||||||||
| 2338 | - | |||||||||||||||||||||||||
| 2339 | \ingroup appearance | - | ||||||||||||||||||||||||
| 2340 | \ingroup shared | - | ||||||||||||||||||||||||
| 2341 | - | |||||||||||||||||||||||||
| 2342 | The QFontInfo class provides the same access functions as QFont, | - | ||||||||||||||||||||||||
| 2343 | e.g. family(), pointSize(), italic(), weight(), fixedPitch(), | - | ||||||||||||||||||||||||
| 2344 | styleHint() etc. But whilst the QFont access functions return the | - | ||||||||||||||||||||||||
| 2345 | values that were set, a QFontInfo object returns the values that | - | ||||||||||||||||||||||||
| 2346 | apply to the font that will actually be used to draw the text. | - | ||||||||||||||||||||||||
| 2347 | - | |||||||||||||||||||||||||
| 2348 | For example, when the program asks for a 25pt Courier font on a | - | ||||||||||||||||||||||||
| 2349 | machine that has a non-scalable 24pt Courier font, QFont will | - | ||||||||||||||||||||||||
| 2350 | (normally) use the 24pt Courier for rendering. In this case, | - | ||||||||||||||||||||||||
| 2351 | QFont::pointSize() returns 25 and QFontInfo::pointSize() returns | - | ||||||||||||||||||||||||
| 2352 | 24. | - | ||||||||||||||||||||||||
| 2353 | - | |||||||||||||||||||||||||
| 2354 | There are three ways to create a QFontInfo object. | - | ||||||||||||||||||||||||
| 2355 | \list 1 | - | ||||||||||||||||||||||||
| 2356 | \li Calling the QFontInfo constructor with a QFont creates a font | - | ||||||||||||||||||||||||
| 2357 | info object for a screen-compatible font, i.e. the font cannot be | - | ||||||||||||||||||||||||
| 2358 | a printer font. If the font is changed later, the font | - | ||||||||||||||||||||||||
| 2359 | info object is \e not updated. | - | ||||||||||||||||||||||||
| 2360 | - | |||||||||||||||||||||||||
| 2361 | (Note: If you use a printer font the values returned may be | - | ||||||||||||||||||||||||
| 2362 | inaccurate. Printer fonts are not always accessible so the nearest | - | ||||||||||||||||||||||||
| 2363 | screen font is used if a printer font is supplied.) | - | ||||||||||||||||||||||||
| 2364 | - | |||||||||||||||||||||||||
| 2365 | \li QWidget::fontInfo() returns the font info for a widget's font. | - | ||||||||||||||||||||||||
| 2366 | This is equivalent to calling QFontInfo(widget->font()). If the | - | ||||||||||||||||||||||||
| 2367 | widget's font is changed later, the font info object is \e not | - | ||||||||||||||||||||||||
| 2368 | updated. | - | ||||||||||||||||||||||||
| 2369 | - | |||||||||||||||||||||||||
| 2370 | \li QPainter::fontInfo() returns the font info for a painter's | - | ||||||||||||||||||||||||
| 2371 | current font. If the painter's font is changed later, the font | - | ||||||||||||||||||||||||
| 2372 | info object is \e not updated. | - | ||||||||||||||||||||||||
| 2373 | \endlist | - | ||||||||||||||||||||||||
| 2374 | - | |||||||||||||||||||||||||
| 2375 | \sa QFont, QFontMetrics, QFontDatabase | - | ||||||||||||||||||||||||
| 2376 | */ | - | ||||||||||||||||||||||||
| 2377 | - | |||||||||||||||||||||||||
| 2378 | /*! | - | ||||||||||||||||||||||||
| 2379 | Constructs a font info object for \a font. | - | ||||||||||||||||||||||||
| 2380 | - | |||||||||||||||||||||||||
| 2381 | The font must be screen-compatible, i.e. a font you use when | - | ||||||||||||||||||||||||
| 2382 | drawing text in \l{QWidget}{widgets} or \l{QPixmap}{pixmaps}, not QPicture or QPrinter. | - | ||||||||||||||||||||||||
| 2383 | - | |||||||||||||||||||||||||
| 2384 | The font info object holds the information for the font that is | - | ||||||||||||||||||||||||
| 2385 | passed in the constructor at the time it is created, and is not | - | ||||||||||||||||||||||||
| 2386 | updated if the font's attributes are changed later. | - | ||||||||||||||||||||||||
| 2387 | - | |||||||||||||||||||||||||
| 2388 | Use QPainter::fontInfo() to get the font info when painting. | - | ||||||||||||||||||||||||
| 2389 | This will give correct results also when painting on paint device | - | ||||||||||||||||||||||||
| 2390 | that is not screen-compatible. | - | ||||||||||||||||||||||||
| 2391 | */ | - | ||||||||||||||||||||||||
| 2392 | QFontInfo::QFontInfo(const QFont &font) | - | ||||||||||||||||||||||||
| 2393 | : d(font.d.data()) | - | ||||||||||||||||||||||||
| 2394 | { | - | ||||||||||||||||||||||||
| 2395 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2396 | - | |||||||||||||||||||||||||
| 2397 | /*! | - | ||||||||||||||||||||||||
| 2398 | Constructs a copy of \a fi. | - | ||||||||||||||||||||||||
| 2399 | */ | - | ||||||||||||||||||||||||
| 2400 | QFontInfo::QFontInfo(const QFontInfo &fi) | - | ||||||||||||||||||||||||
| 2401 | : d(fi.d.data()) | - | ||||||||||||||||||||||||
| 2402 | { | - | ||||||||||||||||||||||||
| 2403 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2404 | - | |||||||||||||||||||||||||
| 2405 | /*! | - | ||||||||||||||||||||||||
| 2406 | Destroys the font info object. | - | ||||||||||||||||||||||||
| 2407 | */ | - | ||||||||||||||||||||||||
| 2408 | QFontInfo::~QFontInfo() | - | ||||||||||||||||||||||||
| 2409 | { | - | ||||||||||||||||||||||||
| 2410 | } | - | ||||||||||||||||||||||||
| 2411 | - | |||||||||||||||||||||||||
| 2412 | /*! | - | ||||||||||||||||||||||||
| 2413 | Assigns the font info in \a fi. | - | ||||||||||||||||||||||||
| 2414 | */ | - | ||||||||||||||||||||||||
| 2415 | QFontInfo &QFontInfo::operator=(const QFontInfo &fi) | - | ||||||||||||||||||||||||
| 2416 | { | - | ||||||||||||||||||||||||
| 2417 | d = fi.d.data(); | - | ||||||||||||||||||||||||
| 2418 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
| 2419 | } | - | ||||||||||||||||||||||||
| 2420 | - | |||||||||||||||||||||||||
| 2421 | /*! | - | ||||||||||||||||||||||||
| 2422 | \fn void QFontInfo::swap(QFontInfo &other) | - | ||||||||||||||||||||||||
| 2423 | \since 5.0 | - | ||||||||||||||||||||||||
| 2424 | - | |||||||||||||||||||||||||
| 2425 | Swaps this font info instance with \a other. This function is very | - | ||||||||||||||||||||||||
| 2426 | fast and never fails. | - | ||||||||||||||||||||||||
| 2427 | */ | - | ||||||||||||||||||||||||
| 2428 | - | |||||||||||||||||||||||||
| 2429 | /*! | - | ||||||||||||||||||||||||
| 2430 | Returns the family name of the matched window system font. | - | ||||||||||||||||||||||||
| 2431 | - | |||||||||||||||||||||||||
| 2432 | \sa QFont::family() | - | ||||||||||||||||||||||||
| 2433 | */ | - | ||||||||||||||||||||||||
| 2434 | QString QFontInfo::family() const | - | ||||||||||||||||||||||||
| 2435 | { | - | ||||||||||||||||||||||||
| 2436 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2437 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2438 | return engine->fontDef.family; never executed: return engine->fontDef.family; | 0 | ||||||||||||||||||||||||
| 2439 | } | - | ||||||||||||||||||||||||
| 2440 | - | |||||||||||||||||||||||||
| 2441 | /*! | - | ||||||||||||||||||||||||
| 2442 | \since 4.8 | - | ||||||||||||||||||||||||
| 2443 | - | |||||||||||||||||||||||||
| 2444 | Returns the style name of the matched window system font on | - | ||||||||||||||||||||||||
| 2445 | systems that support it. | - | ||||||||||||||||||||||||
| 2446 | - | |||||||||||||||||||||||||
| 2447 | \sa QFont::styleName() | - | ||||||||||||||||||||||||
| 2448 | */ | - | ||||||||||||||||||||||||
| 2449 | QString QFontInfo::styleName() const | - | ||||||||||||||||||||||||
| 2450 | { | - | ||||||||||||||||||||||||
| 2451 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2452 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2453 | return engine->fontDef.styleName; never executed: return engine->fontDef.styleName; | 0 | ||||||||||||||||||||||||
| 2454 | } | - | ||||||||||||||||||||||||
| 2455 | - | |||||||||||||||||||||||||
| 2456 | /*! | - | ||||||||||||||||||||||||
| 2457 | Returns the point size of the matched window system font. | - | ||||||||||||||||||||||||
| 2458 | - | |||||||||||||||||||||||||
| 2459 | \sa pointSizeF(), QFont::pointSize() | - | ||||||||||||||||||||||||
| 2460 | */ | - | ||||||||||||||||||||||||
| 2461 | int QFontInfo::pointSize() const | - | ||||||||||||||||||||||||
| 2462 | { | - | ||||||||||||||||||||||||
| 2463 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2464 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2465 | return qRound(engine->fontDef.pointSize); never executed: return qRound(engine->fontDef.pointSize); | 0 | ||||||||||||||||||||||||
| 2466 | } | - | ||||||||||||||||||||||||
| 2467 | - | |||||||||||||||||||||||||
| 2468 | /*! | - | ||||||||||||||||||||||||
| 2469 | Returns the point size of the matched window system font. | - | ||||||||||||||||||||||||
| 2470 | - | |||||||||||||||||||||||||
| 2471 | \sa QFont::pointSizeF() | - | ||||||||||||||||||||||||
| 2472 | */ | - | ||||||||||||||||||||||||
| 2473 | qreal QFontInfo::pointSizeF() const | - | ||||||||||||||||||||||||
| 2474 | { | - | ||||||||||||||||||||||||
| 2475 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2476 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2477 | return engine->fontDef.pointSize; never executed: return engine->fontDef.pointSize; | 0 | ||||||||||||||||||||||||
| 2478 | } | - | ||||||||||||||||||||||||
| 2479 | - | |||||||||||||||||||||||||
| 2480 | /*! | - | ||||||||||||||||||||||||
| 2481 | Returns the pixel size of the matched window system font. | - | ||||||||||||||||||||||||
| 2482 | - | |||||||||||||||||||||||||
| 2483 | \sa QFont::pointSize() | - | ||||||||||||||||||||||||
| 2484 | */ | - | ||||||||||||||||||||||||
| 2485 | int QFontInfo::pixelSize() const | - | ||||||||||||||||||||||||
| 2486 | { | - | ||||||||||||||||||||||||
| 2487 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2488 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2489 | return engine->fontDef.pixelSize; never executed: return engine->fontDef.pixelSize; | 0 | ||||||||||||||||||||||||
| 2490 | } | - | ||||||||||||||||||||||||
| 2491 | - | |||||||||||||||||||||||||
| 2492 | /*! | - | ||||||||||||||||||||||||
| 2493 | Returns the italic value of the matched window system font. | - | ||||||||||||||||||||||||
| 2494 | - | |||||||||||||||||||||||||
| 2495 | \sa QFont::italic() | - | ||||||||||||||||||||||||
| 2496 | */ | - | ||||||||||||||||||||||||
| 2497 | bool QFontInfo::italic() const | - | ||||||||||||||||||||||||
| 2498 | { | - | ||||||||||||||||||||||||
| 2499 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2500 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2501 | return engine->fontDef.style != QFont::StyleNormal; never executed: return engine->fontDef.style != QFont::StyleNormal; | 0 | ||||||||||||||||||||||||
| 2502 | } | - | ||||||||||||||||||||||||
| 2503 | - | |||||||||||||||||||||||||
| 2504 | /*! | - | ||||||||||||||||||||||||
| 2505 | Returns the style value of the matched window system font. | - | ||||||||||||||||||||||||
| 2506 | - | |||||||||||||||||||||||||
| 2507 | \sa QFont::style() | - | ||||||||||||||||||||||||
| 2508 | */ | - | ||||||||||||||||||||||||
| 2509 | QFont::Style QFontInfo::style() const | - | ||||||||||||||||||||||||
| 2510 | { | - | ||||||||||||||||||||||||
| 2511 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2512 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2513 | return (QFont::Style)engine->fontDef.style; never executed: return (QFont::Style)engine->fontDef.style; | 0 | ||||||||||||||||||||||||
| 2514 | } | - | ||||||||||||||||||||||||
| 2515 | - | |||||||||||||||||||||||||
| 2516 | /*! | - | ||||||||||||||||||||||||
| 2517 | Returns the weight of the matched window system font. | - | ||||||||||||||||||||||||
| 2518 | - | |||||||||||||||||||||||||
| 2519 | \sa QFont::weight(), bold() | - | ||||||||||||||||||||||||
| 2520 | */ | - | ||||||||||||||||||||||||
| 2521 | int QFontInfo::weight() const | - | ||||||||||||||||||||||||
| 2522 | { | - | ||||||||||||||||||||||||
| 2523 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2524 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2525 | return engine->fontDef.weight; never executed: return engine->fontDef.weight; | 0 | ||||||||||||||||||||||||
| 2526 | - | |||||||||||||||||||||||||
| 2527 | } | - | ||||||||||||||||||||||||
| 2528 | - | |||||||||||||||||||||||||
| 2529 | /*! | - | ||||||||||||||||||||||||
| 2530 | \fn bool QFontInfo::bold() const | - | ||||||||||||||||||||||||
| 2531 | - | |||||||||||||||||||||||||
| 2532 | Returns \c true if weight() would return a value greater than | - | ||||||||||||||||||||||||
| 2533 | QFont::Normal; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 2534 | - | |||||||||||||||||||||||||
| 2535 | \sa weight(), QFont::bold() | - | ||||||||||||||||||||||||
| 2536 | */ | - | ||||||||||||||||||||||||
| 2537 | - | |||||||||||||||||||||||||
| 2538 | /*! | - | ||||||||||||||||||||||||
| 2539 | Returns the underline value of the matched window system font. | - | ||||||||||||||||||||||||
| 2540 | - | |||||||||||||||||||||||||
| 2541 | \sa QFont::underline() | - | ||||||||||||||||||||||||
| 2542 | - | |||||||||||||||||||||||||
| 2543 | \internal | - | ||||||||||||||||||||||||
| 2544 | - | |||||||||||||||||||||||||
| 2545 | Here we read the underline flag directly from the QFont. | - | ||||||||||||||||||||||||
| 2546 | This is OK for X11 and for Windows because we always get what we want. | - | ||||||||||||||||||||||||
| 2547 | */ | - | ||||||||||||||||||||||||
| 2548 | bool QFontInfo::underline() const | - | ||||||||||||||||||||||||
| 2549 | { | - | ||||||||||||||||||||||||
| 2550 | return d->underline; never executed: return d->underline; | 0 | ||||||||||||||||||||||||
| 2551 | } | - | ||||||||||||||||||||||||
| 2552 | - | |||||||||||||||||||||||||
| 2553 | /*! | - | ||||||||||||||||||||||||
| 2554 | Returns the overline value of the matched window system font. | - | ||||||||||||||||||||||||
| 2555 | - | |||||||||||||||||||||||||
| 2556 | \sa QFont::overline() | - | ||||||||||||||||||||||||
| 2557 | - | |||||||||||||||||||||||||
| 2558 | \internal | - | ||||||||||||||||||||||||
| 2559 | - | |||||||||||||||||||||||||
| 2560 | Here we read the overline flag directly from the QFont. | - | ||||||||||||||||||||||||
| 2561 | This is OK for X11 and for Windows because we always get what we want. | - | ||||||||||||||||||||||||
| 2562 | */ | - | ||||||||||||||||||||||||
| 2563 | bool QFontInfo::overline() const | - | ||||||||||||||||||||||||
| 2564 | { | - | ||||||||||||||||||||||||
| 2565 | return d->overline; never executed: return d->overline; | 0 | ||||||||||||||||||||||||
| 2566 | } | - | ||||||||||||||||||||||||
| 2567 | - | |||||||||||||||||||||||||
| 2568 | /*! | - | ||||||||||||||||||||||||
| 2569 | Returns the strikeout value of the matched window system font. | - | ||||||||||||||||||||||||
| 2570 | - | |||||||||||||||||||||||||
| 2571 | \sa QFont::strikeOut() | - | ||||||||||||||||||||||||
| 2572 | - | |||||||||||||||||||||||||
| 2573 | \internal Here we read the strikeOut flag directly from the QFont. | - | ||||||||||||||||||||||||
| 2574 | This is OK for X11 and for Windows because we always get what we want. | - | ||||||||||||||||||||||||
| 2575 | */ | - | ||||||||||||||||||||||||
| 2576 | bool QFontInfo::strikeOut() const | - | ||||||||||||||||||||||||
| 2577 | { | - | ||||||||||||||||||||||||
| 2578 | return d->strikeOut; never executed: return d->strikeOut; | 0 | ||||||||||||||||||||||||
| 2579 | } | - | ||||||||||||||||||||||||
| 2580 | - | |||||||||||||||||||||||||
| 2581 | /*! | - | ||||||||||||||||||||||||
| 2582 | Returns the fixed pitch value of the matched window system font. | - | ||||||||||||||||||||||||
| 2583 | - | |||||||||||||||||||||||||
| 2584 | \sa QFont::fixedPitch() | - | ||||||||||||||||||||||||
| 2585 | */ | - | ||||||||||||||||||||||||
| 2586 | bool QFontInfo::fixedPitch() const | - | ||||||||||||||||||||||||
| 2587 | { | - | ||||||||||||||||||||||||
| 2588 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2589 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2590 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||
| 2591 | if (!engine->fontDef.fixedPitchComputed) { | - | ||||||||||||||||||||||||
| 2592 | QChar ch[2] = { QLatin1Char('i'), QLatin1Char('m') }; | - | ||||||||||||||||||||||||
| 2593 | QGlyphLayoutArray<2> g; | - | ||||||||||||||||||||||||
| 2594 | int l = 2; | - | ||||||||||||||||||||||||
| 2595 | if (!engine->stringToCMap(ch, 2, &g, &l, 0)) | - | ||||||||||||||||||||||||
| 2596 | Q_UNREACHABLE(); | - | ||||||||||||||||||||||||
| 2597 | Q_ASSERT(l == 2); | - | ||||||||||||||||||||||||
| 2598 | engine->fontDef.fixedPitch = g.advances[0] == g.advances[1]; | - | ||||||||||||||||||||||||
| 2599 | engine->fontDef.fixedPitchComputed = true; | - | ||||||||||||||||||||||||
| 2600 | } | - | ||||||||||||||||||||||||
| 2601 | #endif | - | ||||||||||||||||||||||||
| 2602 | return engine->fontDef.fixedPitch; never executed: return engine->fontDef.fixedPitch; | 0 | ||||||||||||||||||||||||
| 2603 | } | - | ||||||||||||||||||||||||
| 2604 | - | |||||||||||||||||||||||||
| 2605 | /*! | - | ||||||||||||||||||||||||
| 2606 | Returns the style of the matched window system font. | - | ||||||||||||||||||||||||
| 2607 | - | |||||||||||||||||||||||||
| 2608 | Currently only returns the style hint set in QFont. | - | ||||||||||||||||||||||||
| 2609 | - | |||||||||||||||||||||||||
| 2610 | \sa QFont::styleHint(), QFont::StyleHint | - | ||||||||||||||||||||||||
| 2611 | */ | - | ||||||||||||||||||||||||
| 2612 | QFont::StyleHint QFontInfo::styleHint() const | - | ||||||||||||||||||||||||
| 2613 | { | - | ||||||||||||||||||||||||
| 2614 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2615 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2616 | return (QFont::StyleHint) engine->fontDef.styleHint; never executed: return (QFont::StyleHint) engine->fontDef.styleHint; | 0 | ||||||||||||||||||||||||
| 2617 | } | - | ||||||||||||||||||||||||
| 2618 | - | |||||||||||||||||||||||||
| 2619 | #if QT_DEPRECATED_SINCE(5, 5) | - | ||||||||||||||||||||||||
| 2620 | /*! | - | ||||||||||||||||||||||||
| 2621 | \deprecated | - | ||||||||||||||||||||||||
| 2622 | - | |||||||||||||||||||||||||
| 2623 | Returns \c true if the font is a raw mode font; otherwise returns | - | ||||||||||||||||||||||||
| 2624 | false. | - | ||||||||||||||||||||||||
| 2625 | - | |||||||||||||||||||||||||
| 2626 | If it is a raw mode font, all other functions in QFontInfo will | - | ||||||||||||||||||||||||
| 2627 | return the same values set in the QFont, regardless of the font | - | ||||||||||||||||||||||||
| 2628 | actually used. | - | ||||||||||||||||||||||||
| 2629 | - | |||||||||||||||||||||||||
| 2630 | \sa QFont::rawMode() | - | ||||||||||||||||||||||||
| 2631 | */ | - | ||||||||||||||||||||||||
| 2632 | bool QFontInfo::rawMode() const | - | ||||||||||||||||||||||||
| 2633 | { | - | ||||||||||||||||||||||||
| 2634 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 2635 | } | - | ||||||||||||||||||||||||
| 2636 | #endif | - | ||||||||||||||||||||||||
| 2637 | - | |||||||||||||||||||||||||
| 2638 | /*! | - | ||||||||||||||||||||||||
| 2639 | Returns \c true if the matched window system font is exactly the same | - | ||||||||||||||||||||||||
| 2640 | as the one specified by the font; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 2641 | - | |||||||||||||||||||||||||
| 2642 | \sa QFont::exactMatch() | - | ||||||||||||||||||||||||
| 2643 | */ | - | ||||||||||||||||||||||||
| 2644 | bool QFontInfo::exactMatch() const | - | ||||||||||||||||||||||||
| 2645 | { | - | ||||||||||||||||||||||||
| 2646 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2647 | Q_ASSERT(engine != 0); | - | ||||||||||||||||||||||||
| 2648 | return d->request.exactMatch(engine->fontDef); never executed: return d->request.exactMatch(engine->fontDef); | 0 | ||||||||||||||||||||||||
| 2649 | } | - | ||||||||||||||||||||||||
| 2650 | - | |||||||||||||||||||||||||
| 2651 | - | |||||||||||||||||||||||||
| 2652 | - | |||||||||||||||||||||||||
| 2653 | - | |||||||||||||||||||||||||
| 2654 | // ********************************************************************** | - | ||||||||||||||||||||||||
| 2655 | // QFontCache | - | ||||||||||||||||||||||||
| 2656 | // ********************************************************************** | - | ||||||||||||||||||||||||
| 2657 | - | |||||||||||||||||||||||||
| 2658 | #ifdef QFONTCACHE_DEBUG | - | ||||||||||||||||||||||||
| 2659 | // fast timeouts for debugging | - | ||||||||||||||||||||||||
| 2660 | static const int fast_timeout = 1000; // 1s | - | ||||||||||||||||||||||||
| 2661 | static const int slow_timeout = 5000; // 5s | - | ||||||||||||||||||||||||
| 2662 | #else | - | ||||||||||||||||||||||||
| 2663 | static const int fast_timeout = 10000; // 10s | - | ||||||||||||||||||||||||
| 2664 | static const int slow_timeout = 300000; // 5m | - | ||||||||||||||||||||||||
| 2665 | #endif // QFONTCACHE_DEBUG | - | ||||||||||||||||||||||||
| 2666 | - | |||||||||||||||||||||||||
| 2667 | const uint QFontCache::min_cost = 4*1024; // 4mb | - | ||||||||||||||||||||||||
| 2668 | - | |||||||||||||||||||||||||
| 2669 | #ifdef QT_NO_THREAD | - | ||||||||||||||||||||||||
| 2670 | Q_GLOBAL_STATIC(QFontCache, theFontCache) | - | ||||||||||||||||||||||||
| 2671 | - | |||||||||||||||||||||||||
| 2672 | QFontCache *QFontCache::instance() | - | ||||||||||||||||||||||||
| 2673 | { | - | ||||||||||||||||||||||||
| 2674 | return theFontCache(); | - | ||||||||||||||||||||||||
| 2675 | } | - | ||||||||||||||||||||||||
| 2676 | - | |||||||||||||||||||||||||
| 2677 | void QFontCache::cleanup() | - | ||||||||||||||||||||||||
| 2678 | { | - | ||||||||||||||||||||||||
| 2679 | } | - | ||||||||||||||||||||||||
| 2680 | #else | - | ||||||||||||||||||||||||
| 2681 | Q_GLOBAL_STATIC(QThreadStorage<QFontCache *>, theFontCache) never executed: end of blocknever executed: guard.store(QtGlobalStatic::Destroyed);never executed: return &holder.value;
| 0 | ||||||||||||||||||||||||
| 2682 | - | |||||||||||||||||||||||||
| 2683 | QFontCache *QFontCache::instance() | - | ||||||||||||||||||||||||
| 2684 | { | - | ||||||||||||||||||||||||
| 2685 | QFontCache *&fontCache = theFontCache()->localData(); | - | ||||||||||||||||||||||||
| 2686 | if (!fontCache)
| 0 | ||||||||||||||||||||||||
| 2687 | fontCache = new QFontCache; never executed: fontCache = new QFontCache; | 0 | ||||||||||||||||||||||||
| 2688 | return fontCache; never executed: return fontCache; | 0 | ||||||||||||||||||||||||
| 2689 | } | - | ||||||||||||||||||||||||
| 2690 | - | |||||||||||||||||||||||||
| 2691 | void QFontCache::cleanup() | - | ||||||||||||||||||||||||
| 2692 | { | - | ||||||||||||||||||||||||
| 2693 | QThreadStorage<QFontCache *> *cache = 0; | - | ||||||||||||||||||||||||
| 2694 | QT_TRY { | - | ||||||||||||||||||||||||
| 2695 | cache = theFontCache(); | - | ||||||||||||||||||||||||
| 2696 | } QT_CATCH (const std::bad_alloc &) { never executed: end of blockdead code: { } | - | ||||||||||||||||||||||||
| 2697 | // no cache - just ignore dead code: { } | - | ||||||||||||||||||||||||
| 2698 | } dead code: { } | - | ||||||||||||||||||||||||
| 2699 | if (cache && cache->hasLocalData())
| 0 | ||||||||||||||||||||||||
| 2700 | cache->setLocalData(0); never executed: cache->setLocalData(0); | 0 | ||||||||||||||||||||||||
| 2701 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2702 | #endif // QT_NO_THREAD | - | ||||||||||||||||||||||||
| 2703 | - | |||||||||||||||||||||||||
| 2704 | QBasicAtomicInt font_cache_id = Q_BASIC_ATOMIC_INITIALIZER(1); | - | ||||||||||||||||||||||||
| 2705 | - | |||||||||||||||||||||||||
| 2706 | QFontCache::QFontCache() | - | ||||||||||||||||||||||||
| 2707 | : QObject(), total_cost(0), max_cost(min_cost), | - | ||||||||||||||||||||||||
| 2708 | current_timestamp(0), fast(false), timer_id(-1), | - | ||||||||||||||||||||||||
| 2709 | m_id(font_cache_id.fetchAndAddRelaxed(1)) | - | ||||||||||||||||||||||||
| 2710 | { | - | ||||||||||||||||||||||||
| 2711 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2712 | - | |||||||||||||||||||||||||
| 2713 | QFontCache::~QFontCache() | - | ||||||||||||||||||||||||
| 2714 | { | - | ||||||||||||||||||||||||
| 2715 | clear(); | - | ||||||||||||||||||||||||
| 2716 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2717 | - | |||||||||||||||||||||||||
| 2718 | void QFontCache::clear() | - | ||||||||||||||||||||||||
| 2719 | { | - | ||||||||||||||||||||||||
| 2720 | { | - | ||||||||||||||||||||||||
| 2721 | EngineDataCache::Iterator it = engineDataCache.begin(), | - | ||||||||||||||||||||||||
| 2722 | end = engineDataCache.end(); | - | ||||||||||||||||||||||||
| 2723 | while (it != end) {
| 0 | ||||||||||||||||||||||||
| 2724 | QFontEngineData *data = it.value(); | - | ||||||||||||||||||||||||
| 2725 | for (int i = 0; i < QChar::ScriptCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 2726 | if (data->engines[i]) {
| 0 | ||||||||||||||||||||||||
| 2727 | if (!data->engines[i]->ref.deref()) {
| 0 | ||||||||||||||||||||||||
| 2728 | Q_ASSERT(engineCacheCount.value(data->engines[i]) == 0); | - | ||||||||||||||||||||||||
| 2729 | delete data->engines[i]; | - | ||||||||||||||||||||||||
| 2730 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2731 | data->engines[i] = 0; | - | ||||||||||||||||||||||||
| 2732 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2733 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2734 | if (!data->ref.deref()) {
| 0 | ||||||||||||||||||||||||
| 2735 | delete data; | - | ||||||||||||||||||||||||
| 2736 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2737 | FC_DEBUG("QFontCache::clear: engineData %p still has refcount %d", dead code: QMessageLogger(__FILE__, 2737, __PRETTY_FUNCTION__).debug("QFontCache::clear: engineData %p still has refcount %d", data, data->ref.load()); | - | ||||||||||||||||||||||||
| 2738 | data, data->ref.load()); dead code: QMessageLogger(__FILE__, 2737, __PRETTY_FUNCTION__).debug("QFontCache::clear: engineData %p still has refcount %d", data, data->ref.load()); | - | ||||||||||||||||||||||||
| 2739 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2740 | ++it; | - | ||||||||||||||||||||||||
| 2741 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2742 | } | - | ||||||||||||||||||||||||
| 2743 | - | |||||||||||||||||||||||||
| 2744 | engineDataCache.clear(); | - | ||||||||||||||||||||||||
| 2745 | - | |||||||||||||||||||||||||
| 2746 | - | |||||||||||||||||||||||||
| 2747 | bool mightHaveEnginesLeftForCleanup; | - | ||||||||||||||||||||||||
| 2748 | do { | - | ||||||||||||||||||||||||
| 2749 | mightHaveEnginesLeftForCleanup = false; | - | ||||||||||||||||||||||||
| 2750 | for (EngineCache::Iterator it = engineCache.begin(), end = engineCache.end(); | - | ||||||||||||||||||||||||
| 2751 | it != end; ++it) {
| 0 | ||||||||||||||||||||||||
| 2752 | QFontEngine *engine = it.value().data; | - | ||||||||||||||||||||||||
| 2753 | if (engine) {
| 0 | ||||||||||||||||||||||||
| 2754 | const int cacheCount = --engineCacheCount[engine]; | - | ||||||||||||||||||||||||
| 2755 | Q_ASSERT(cacheCount >= 0); | - | ||||||||||||||||||||||||
| 2756 | if (!engine->ref.deref()) {
| 0 | ||||||||||||||||||||||||
| 2757 | Q_ASSERT(cacheCount == 0); | - | ||||||||||||||||||||||||
| 2758 | mightHaveEnginesLeftForCleanup = engine->type() == QFontEngine::Multi; | - | ||||||||||||||||||||||||
| 2759 | delete engine; | - | ||||||||||||||||||||||||
| 2760 | } else if (cacheCount == 0) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 2761 | FC_DEBUG("QFontCache::clear: engine %p still has refcount %d", dead code: QMessageLogger(__FILE__, 2761, __PRETTY_FUNCTION__).debug("QFontCache::clear: engine %p still has refcount %d", engine, engine->ref.load()); | - | ||||||||||||||||||||||||
| 2762 | engine, engine->ref.load()); dead code: QMessageLogger(__FILE__, 2761, __PRETTY_FUNCTION__).debug("QFontCache::clear: engine %p still has refcount %d", engine, engine->ref.load()); | - | ||||||||||||||||||||||||
| 2763 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2764 | it.value().data = 0; | - | ||||||||||||||||||||||||
| 2765 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2766 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2767 | } while (mightHaveEnginesLeftForCleanup); never executed: end of block
| 0 | ||||||||||||||||||||||||
| 2768 | - | |||||||||||||||||||||||||
| 2769 | engineCache.clear(); | - | ||||||||||||||||||||||||
| 2770 | engineCacheCount.clear(); | - | ||||||||||||||||||||||||
| 2771 | - | |||||||||||||||||||||||||
| 2772 | - | |||||||||||||||||||||||||
| 2773 | total_cost = 0; | - | ||||||||||||||||||||||||
| 2774 | max_cost = min_cost; | - | ||||||||||||||||||||||||
| 2775 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2776 | - | |||||||||||||||||||||||||
| 2777 | - | |||||||||||||||||||||||||
| 2778 | QFontEngineData *QFontCache::findEngineData(const QFontDef &def) const | - | ||||||||||||||||||||||||
| 2779 | { | - | ||||||||||||||||||||||||
| 2780 | EngineDataCache::ConstIterator it = engineDataCache.constFind(def); | - | ||||||||||||||||||||||||
| 2781 | if (it == engineDataCache.constEnd())
| 0 | ||||||||||||||||||||||||
| 2782 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2783 | - | |||||||||||||||||||||||||
| 2784 | // found | - | ||||||||||||||||||||||||
| 2785 | return it.value(); never executed: return it.value(); | 0 | ||||||||||||||||||||||||
| 2786 | } | - | ||||||||||||||||||||||||
| 2787 | - | |||||||||||||||||||||||||
| 2788 | void QFontCache::insertEngineData(const QFontDef &def, QFontEngineData *engineData) | - | ||||||||||||||||||||||||
| 2789 | { | - | ||||||||||||||||||||||||
| 2790 | #ifdef QFONTCACHE_DEBUG | - | ||||||||||||||||||||||||
| 2791 | FC_DEBUG("QFontCache: inserting new engine data %p", engineData); | - | ||||||||||||||||||||||||
| 2792 | if (engineDataCache.contains(def)) { | - | ||||||||||||||||||||||||
| 2793 | FC_DEBUG(" QFontCache already contains engine data %p for key=(%g %g %d %d %d)", | - | ||||||||||||||||||||||||
| 2794 | engineDataCache.value(def), def.pointSize, | - | ||||||||||||||||||||||||
| 2795 | def.pixelSize, def.weight, def.style, def.fixedPitch); | - | ||||||||||||||||||||||||
| 2796 | } | - | ||||||||||||||||||||||||
| 2797 | #endif | - | ||||||||||||||||||||||||
| 2798 | Q_ASSERT(!engineDataCache.contains(def)); | - | ||||||||||||||||||||||||
| 2799 | - | |||||||||||||||||||||||||
| 2800 | engineData->ref.ref(); | - | ||||||||||||||||||||||||
| 2801 | // Decrease now rather than waiting | - | ||||||||||||||||||||||||
| 2802 | if (total_cost > min_cost * 2 && engineDataCache.size() >= QFONTCACHE_DECREASE_TRIGGER_LIMIT)
| 0 | ||||||||||||||||||||||||
| 2803 | decreaseCache(); never executed: decreaseCache(); | 0 | ||||||||||||||||||||||||
| 2804 | - | |||||||||||||||||||||||||
| 2805 | engineDataCache.insert(def, engineData); | - | ||||||||||||||||||||||||
| 2806 | increaseCost(sizeof(QFontEngineData)); | - | ||||||||||||||||||||||||
| 2807 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2808 | - | |||||||||||||||||||||||||
| 2809 | QFontEngine *QFontCache::findEngine(const Key &key) | - | ||||||||||||||||||||||||
| 2810 | { | - | ||||||||||||||||||||||||
| 2811 | EngineCache::Iterator it = engineCache.find(key), | - | ||||||||||||||||||||||||
| 2812 | end = engineCache.end(); | - | ||||||||||||||||||||||||
| 2813 | if (it == end) return 0; never executed: return 0;
| 0 | ||||||||||||||||||||||||
| 2814 | - | |||||||||||||||||||||||||
| 2815 | Q_ASSERT(it.value().data != Q_NULLPTR); | - | ||||||||||||||||||||||||
| 2816 | Q_ASSERT(key.multi == (it.value().data->type() == QFontEngine::Multi)); | - | ||||||||||||||||||||||||
| 2817 | - | |||||||||||||||||||||||||
| 2818 | // found... update the hitcount and timestamp | - | ||||||||||||||||||||||||
| 2819 | updateHitCountAndTimeStamp(it.value()); | - | ||||||||||||||||||||||||
| 2820 | - | |||||||||||||||||||||||||
| 2821 | return it.value().data; never executed: return it.value().data; | 0 | ||||||||||||||||||||||||
| 2822 | } | - | ||||||||||||||||||||||||
| 2823 | - | |||||||||||||||||||||||||
| 2824 | void QFontCache::updateHitCountAndTimeStamp(Engine &value) | - | ||||||||||||||||||||||||
| 2825 | { | - | ||||||||||||||||||||||||
| 2826 | value.hits++; | - | ||||||||||||||||||||||||
| 2827 | value.timestamp = ++current_timestamp; | - | ||||||||||||||||||||||||
| 2828 | - | |||||||||||||||||||||||||
| 2829 | FC_DEBUG("QFontCache: found font engine\n" dead code: QMessageLogger(__FILE__, 2829, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type()); | - | ||||||||||||||||||||||||
| 2830 | " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", dead code: QMessageLogger(__FILE__, 2829, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type()); | - | ||||||||||||||||||||||||
| 2831 | value.data, value.timestamp, value.hits, dead code: QMessageLogger(__FILE__, 2829, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type()); | - | ||||||||||||||||||||||||
| 2832 | value.data->ref.load(), engineCacheCount.value(value.data), dead code: QMessageLogger(__FILE__, 2829, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type()); | - | ||||||||||||||||||||||||
| 2833 | value.data->type()); dead code: QMessageLogger(__FILE__, 2829, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type()); | - | ||||||||||||||||||||||||
| 2834 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2835 | - | |||||||||||||||||||||||||
| 2836 | void QFontCache::insertEngine(const Key &key, QFontEngine *engine, bool insertMulti) | - | ||||||||||||||||||||||||
| 2837 | { | - | ||||||||||||||||||||||||
| 2838 | Q_ASSERT(engine != Q_NULLPTR); | - | ||||||||||||||||||||||||
| 2839 | Q_ASSERT(key.multi == (engine->type() == QFontEngine::Multi)); | - | ||||||||||||||||||||||||
| 2840 | - | |||||||||||||||||||||||||
| 2841 | #ifdef QFONTCACHE_DEBUG | - | ||||||||||||||||||||||||
| 2842 | FC_DEBUG("QFontCache: inserting new engine %p, refcount %d", engine, engine->ref.load()); | - | ||||||||||||||||||||||||
| 2843 | if (!insertMulti && engineCache.contains(key)) { | - | ||||||||||||||||||||||||
| 2844 | FC_DEBUG(" QFontCache already contains engine %p for key=(%g %g %d %d %d)", | - | ||||||||||||||||||||||||
| 2845 | engineCache.value(key).data, key.def.pointSize, | - | ||||||||||||||||||||||||
| 2846 | key.def.pixelSize, key.def.weight, key.def.style, key.def.fixedPitch); | - | ||||||||||||||||||||||||
| 2847 | } | - | ||||||||||||||||||||||||
| 2848 | #endif | - | ||||||||||||||||||||||||
| 2849 | engine->ref.ref(); | - | ||||||||||||||||||||||||
| 2850 | // Decrease now rather than waiting | - | ||||||||||||||||||||||||
| 2851 | if (total_cost > min_cost * 2 && engineCache.size() >= QFONTCACHE_DECREASE_TRIGGER_LIMIT)
| 0 | ||||||||||||||||||||||||
| 2852 | decreaseCache(); never executed: decreaseCache(); | 0 | ||||||||||||||||||||||||
| 2853 | - | |||||||||||||||||||||||||
| 2854 | Engine data(engine); | - | ||||||||||||||||||||||||
| 2855 | data.timestamp = ++current_timestamp; | - | ||||||||||||||||||||||||
| 2856 | - | |||||||||||||||||||||||||
| 2857 | if (insertMulti)
| 0 | ||||||||||||||||||||||||
| 2858 | engineCache.insertMulti(key, data); never executed: engineCache.insertMulti(key, data); | 0 | ||||||||||||||||||||||||
| 2859 | else | - | ||||||||||||||||||||||||
| 2860 | engineCache.insert(key, data); never executed: engineCache.insert(key, data); | 0 | ||||||||||||||||||||||||
| 2861 | // only increase the cost if this is the first time we insert the engine | - | ||||||||||||||||||||||||
| 2862 | if (++engineCacheCount[engine] == 1)
| 0 | ||||||||||||||||||||||||
| 2863 | increaseCost(engine->cache_cost); never executed: increaseCost(engine->cache_cost); | 0 | ||||||||||||||||||||||||
| 2864 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2865 | - | |||||||||||||||||||||||||
| 2866 | void QFontCache::increaseCost(uint cost) | - | ||||||||||||||||||||||||
| 2867 | { | - | ||||||||||||||||||||||||
| 2868 | cost = (cost + 512) / 1024; // store cost in kb | - | ||||||||||||||||||||||||
| 2869 | cost = cost > 0 ? cost : 1;
| 0 | ||||||||||||||||||||||||
| 2870 | total_cost += cost; | - | ||||||||||||||||||||||||
| 2871 | - | |||||||||||||||||||||||||
| 2872 | FC_DEBUG(" COST: increased %u kb, total_cost %u kb, max_cost %u kb", dead code: QMessageLogger(__FILE__, 2872, __PRETTY_FUNCTION__).debug(" COST: increased %u kb, total_cost %u kb, max_cost %u kb", cost, total_cost, max_cost); | - | ||||||||||||||||||||||||
| 2873 | cost, total_cost, max_cost); dead code: QMessageLogger(__FILE__, 2872, __PRETTY_FUNCTION__).debug(" COST: increased %u kb, total_cost %u kb, max_cost %u kb", cost, total_cost, max_cost); | - | ||||||||||||||||||||||||
| 2874 | - | |||||||||||||||||||||||||
| 2875 | if (total_cost > max_cost) {
| 0 | ||||||||||||||||||||||||
| 2876 | max_cost = total_cost; | - | ||||||||||||||||||||||||
| 2877 | - | |||||||||||||||||||||||||
| 2878 | if (timer_id == -1 || ! fast) {
| 0 | ||||||||||||||||||||||||
| 2879 | FC_DEBUG(" TIMER: starting fast timer (%d ms)", fast_timeout); dead code: QMessageLogger(__FILE__, 2879, __PRETTY_FUNCTION__).debug(" TIMER: starting fast timer (%d ms)", fast_timeout); | - | ||||||||||||||||||||||||
| 2880 | - | |||||||||||||||||||||||||
| 2881 | if (timer_id != -1) killTimer(timer_id); never executed: killTimer(timer_id);
| 0 | ||||||||||||||||||||||||
| 2882 | timer_id = startTimer(fast_timeout); | - | ||||||||||||||||||||||||
| 2883 | fast = true; | - | ||||||||||||||||||||||||
| 2884 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2885 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2886 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2887 | - | |||||||||||||||||||||||||
| 2888 | void QFontCache::decreaseCost(uint cost) | - | ||||||||||||||||||||||||
| 2889 | { | - | ||||||||||||||||||||||||
| 2890 | cost = (cost + 512) / 1024; // cost is stored in kb | - | ||||||||||||||||||||||||
| 2891 | cost = cost > 0 ? cost : 1;
| 0 | ||||||||||||||||||||||||
| 2892 | Q_ASSERT(cost <= total_cost); | - | ||||||||||||||||||||||||
| 2893 | total_cost -= cost; | - | ||||||||||||||||||||||||
| 2894 | - | |||||||||||||||||||||||||
| 2895 | FC_DEBUG(" COST: decreased %u kb, total_cost %u kb, max_cost %u kb", dead code: QMessageLogger(__FILE__, 2895, __PRETTY_FUNCTION__).debug(" COST: decreased %u kb, total_cost %u kb, max_cost %u kb", cost, total_cost, max_cost); | - | ||||||||||||||||||||||||
| 2896 | cost, total_cost, max_cost); dead code: QMessageLogger(__FILE__, 2895, __PRETTY_FUNCTION__).debug(" COST: decreased %u kb, total_cost %u kb, max_cost %u kb", cost, total_cost, max_cost); | - | ||||||||||||||||||||||||
| 2897 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2898 | - | |||||||||||||||||||||||||
| 2899 | void QFontCache::timerEvent(QTimerEvent *) | - | ||||||||||||||||||||||||
| 2900 | { | - | ||||||||||||||||||||||||
| 2901 | FC_DEBUG("QFontCache::timerEvent: performing cache maintenance (timestamp %u)", dead code: QMessageLogger(__FILE__, 2901, __PRETTY_FUNCTION__).debug("QFontCache::timerEvent: performing cache maintenance (timestamp %u)", current_timestamp); | - | ||||||||||||||||||||||||
| 2902 | current_timestamp); dead code: QMessageLogger(__FILE__, 2901, __PRETTY_FUNCTION__).debug("QFontCache::timerEvent: performing cache maintenance (timestamp %u)", current_timestamp); | - | ||||||||||||||||||||||||
| 2903 | - | |||||||||||||||||||||||||
| 2904 | if (total_cost <= max_cost && max_cost <= min_cost) {
| 0 | ||||||||||||||||||||||||
| 2905 | FC_DEBUG(" cache redused sufficiently, stopping timer"); dead code: QMessageLogger(__FILE__, 2905, __PRETTY_FUNCTION__).debug(" cache redused sufficiently, stopping timer"); | - | ||||||||||||||||||||||||
| 2906 | - | |||||||||||||||||||||||||
| 2907 | killTimer(timer_id); | - | ||||||||||||||||||||||||
| 2908 | timer_id = -1; | - | ||||||||||||||||||||||||
| 2909 | fast = false; | - | ||||||||||||||||||||||||
| 2910 | - | |||||||||||||||||||||||||
| 2911 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2912 | } | - | ||||||||||||||||||||||||
| 2913 | decreaseCache(); | - | ||||||||||||||||||||||||
| 2914 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2915 | - | |||||||||||||||||||||||||
| 2916 | void QFontCache::decreaseCache() | - | ||||||||||||||||||||||||
| 2917 | { | - | ||||||||||||||||||||||||
| 2918 | // go through the cache and count up everything in use | - | ||||||||||||||||||||||||
| 2919 | uint in_use_cost = 0; | - | ||||||||||||||||||||||||
| 2920 | - | |||||||||||||||||||||||||
| 2921 | { | - | ||||||||||||||||||||||||
| 2922 | FC_DEBUG(" SWEEP engine data:"); dead code: QMessageLogger(__FILE__, 2922, __PRETTY_FUNCTION__).debug(" SWEEP engine data:"); | - | ||||||||||||||||||||||||
| 2923 | - | |||||||||||||||||||||||||
| 2924 | // make sure the cost of each engine data is at least 1kb | - | ||||||||||||||||||||||||
| 2925 | const uint engine_data_cost = | - | ||||||||||||||||||||||||
| 2926 | sizeof(QFontEngineData) > 1024 ? sizeof(QFontEngineData) : 1024;
| 0 | ||||||||||||||||||||||||
| 2927 | - | |||||||||||||||||||||||||
| 2928 | EngineDataCache::ConstIterator it = engineDataCache.constBegin(), | - | ||||||||||||||||||||||||
| 2929 | end = engineDataCache.constEnd(); | - | ||||||||||||||||||||||||
| 2930 | for (; it != end; ++it) {
| 0 | ||||||||||||||||||||||||
| 2931 | FC_DEBUG(" %p: ref %2d", it.value(), int(it.value()->ref.load())); dead code: QMessageLogger(__FILE__, 2931, __PRETTY_FUNCTION__).debug(" %p: ref %2d", it.value(), int(it.value()->ref.load())); | - | ||||||||||||||||||||||||
| 2932 | - | |||||||||||||||||||||||||
| 2933 | if (it.value()->ref.load() != 1)
| 0 | ||||||||||||||||||||||||
| 2934 | in_use_cost += engine_data_cost; never executed: in_use_cost += engine_data_cost; | 0 | ||||||||||||||||||||||||
| 2935 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2936 | } | - | ||||||||||||||||||||||||
| 2937 | - | |||||||||||||||||||||||||
| 2938 | { | - | ||||||||||||||||||||||||
| 2939 | FC_DEBUG(" SWEEP engine:"); dead code: QMessageLogger(__FILE__, 2939, __PRETTY_FUNCTION__).debug(" SWEEP engine:"); | - | ||||||||||||||||||||||||
| 2940 | - | |||||||||||||||||||||||||
| 2941 | EngineCache::ConstIterator it = engineCache.constBegin(), | - | ||||||||||||||||||||||||
| 2942 | end = engineCache.constEnd(); | - | ||||||||||||||||||||||||
| 2943 | for (; it != end; ++it) {
| 0 | ||||||||||||||||||||||||
| 2944 | FC_DEBUG(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", dead code: QMessageLogger(__FILE__, 2944, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->cache_cost); | - | ||||||||||||||||||||||||
| 2945 | it.value().data, it.value().timestamp, it.value().hits, dead code: QMessageLogger(__FILE__, 2944, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->cache_cost); | - | ||||||||||||||||||||||||
| 2946 | it.value().data->ref.load(), engineCacheCount.value(it.value().data), dead code: QMessageLogger(__FILE__, 2944, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->cache_cost); | - | ||||||||||||||||||||||||
| 2947 | it.value().data->cache_cost); dead code: QMessageLogger(__FILE__, 2944, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->cache_cost); | - | ||||||||||||||||||||||||
| 2948 | - | |||||||||||||||||||||||||
| 2949 | if (it.value().data->ref.load() != 0)
| 0 | ||||||||||||||||||||||||
| 2950 | in_use_cost += it.value().data->cache_cost / engineCacheCount.value(it.value().data); never executed: in_use_cost += it.value().data->cache_cost / engineCacheCount.value(it.value().data); | 0 | ||||||||||||||||||||||||
| 2951 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2952 | - | |||||||||||||||||||||||||
| 2953 | // attempt to make up for rounding errors | - | ||||||||||||||||||||||||
| 2954 | in_use_cost += engineCache.size(); | - | ||||||||||||||||||||||||
| 2955 | } | - | ||||||||||||||||||||||||
| 2956 | - | |||||||||||||||||||||||||
| 2957 | in_use_cost = (in_use_cost + 512) / 1024; // cost is stored in kb | - | ||||||||||||||||||||||||
| 2958 | - | |||||||||||||||||||||||||
| 2959 | /* | - | ||||||||||||||||||||||||
| 2960 | calculate the new maximum cost for the cache | - | ||||||||||||||||||||||||
| 2961 | - | |||||||||||||||||||||||||
| 2962 | NOTE: in_use_cost is *not* correct due to rounding errors in the | - | ||||||||||||||||||||||||
| 2963 | above algorithm. instead of worrying about getting the | - | ||||||||||||||||||||||||
| 2964 | calculation correct, we are more interested in speed, and use | - | ||||||||||||||||||||||||
| 2965 | in_use_cost as a floor for new_max_cost | - | ||||||||||||||||||||||||
| 2966 | */ | - | ||||||||||||||||||||||||
| 2967 | uint new_max_cost = qMax(qMax(max_cost / 2, in_use_cost), min_cost); | - | ||||||||||||||||||||||||
| 2968 | - | |||||||||||||||||||||||||
| 2969 | FC_DEBUG(" after sweep, in use %u kb, total %u kb, max %u kb, new max %u kb", dead code: QMessageLogger(__FILE__, 2969, __PRETTY_FUNCTION__).debug(" after sweep, in use %u kb, total %u kb, max %u kb, new max %u kb", in_use_cost, total_cost, max_cost, new_max_cost); | - | ||||||||||||||||||||||||
| 2970 | in_use_cost, total_cost, max_cost, new_max_cost); dead code: QMessageLogger(__FILE__, 2969, __PRETTY_FUNCTION__).debug(" after sweep, in use %u kb, total %u kb, max %u kb, new max %u kb", in_use_cost, total_cost, max_cost, new_max_cost); | - | ||||||||||||||||||||||||
| 2971 | - | |||||||||||||||||||||||||
| 2972 | if (new_max_cost == max_cost) {
| 0 | ||||||||||||||||||||||||
| 2973 | if (fast) {
| 0 | ||||||||||||||||||||||||
| 2974 | FC_DEBUG(" cannot shrink cache, slowing timer"); dead code: QMessageLogger(__FILE__, 2974, __PRETTY_FUNCTION__).debug(" cannot shrink cache, slowing timer"); | - | ||||||||||||||||||||||||
| 2975 | - | |||||||||||||||||||||||||
| 2976 | killTimer(timer_id); | - | ||||||||||||||||||||||||
| 2977 | timer_id = startTimer(slow_timeout); | - | ||||||||||||||||||||||||
| 2978 | fast = false; | - | ||||||||||||||||||||||||
| 2979 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2980 | - | |||||||||||||||||||||||||
| 2981 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2982 | } else if (! fast) {
| 0 | ||||||||||||||||||||||||
| 2983 | FC_DEBUG(" dropping into passing gear"); dead code: QMessageLogger(__FILE__, 2983, __PRETTY_FUNCTION__).debug(" dropping into passing gear"); | - | ||||||||||||||||||||||||
| 2984 | - | |||||||||||||||||||||||||
| 2985 | killTimer(timer_id); | - | ||||||||||||||||||||||||
| 2986 | timer_id = startTimer(fast_timeout); | - | ||||||||||||||||||||||||
| 2987 | fast = true; | - | ||||||||||||||||||||||||
| 2988 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2989 | - | |||||||||||||||||||||||||
| 2990 | max_cost = new_max_cost; | - | ||||||||||||||||||||||||
| 2991 | - | |||||||||||||||||||||||||
| 2992 | { | - | ||||||||||||||||||||||||
| 2993 | FC_DEBUG(" CLEAN engine data:"); dead code: QMessageLogger(__FILE__, 2993, __PRETTY_FUNCTION__).debug(" CLEAN engine data:"); | - | ||||||||||||||||||||||||
| 2994 | - | |||||||||||||||||||||||||
| 2995 | // clean out all unused engine data | - | ||||||||||||||||||||||||
| 2996 | EngineDataCache::Iterator it = engineDataCache.begin(); | - | ||||||||||||||||||||||||
| 2997 | while (it != engineDataCache.end()) {
| 0 | ||||||||||||||||||||||||
| 2998 | if (it.value()->ref.load() == 1) {
| 0 | ||||||||||||||||||||||||
| 2999 | FC_DEBUG(" %p", it.value()); dead code: QMessageLogger(__FILE__, 2999, __PRETTY_FUNCTION__).debug(" %p", it.value()); | - | ||||||||||||||||||||||||
| 3000 | decreaseCost(sizeof(QFontEngineData)); | - | ||||||||||||||||||||||||
| 3001 | it.value()->ref.deref(); | - | ||||||||||||||||||||||||
| 3002 | delete it.value(); | - | ||||||||||||||||||||||||
| 3003 | it = engineDataCache.erase(it); | - | ||||||||||||||||||||||||
| 3004 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3005 | ++it; | - | ||||||||||||||||||||||||
| 3006 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3007 | } | - | ||||||||||||||||||||||||
| 3008 | } | - | ||||||||||||||||||||||||
| 3009 | - | |||||||||||||||||||||||||
| 3010 | FC_DEBUG(" CLEAN engine:"); dead code: QMessageLogger(__FILE__, 3010, __PRETTY_FUNCTION__).debug(" CLEAN engine:"); | - | ||||||||||||||||||||||||
| 3011 | - | |||||||||||||||||||||||||
| 3012 | // clean out the engine cache just enough to get below our new max cost | - | ||||||||||||||||||||||||
| 3013 | bool cost_decreased; | - | ||||||||||||||||||||||||
| 3014 | do { | - | ||||||||||||||||||||||||
| 3015 | cost_decreased = false; | - | ||||||||||||||||||||||||
| 3016 | - | |||||||||||||||||||||||||
| 3017 | EngineCache::Iterator it = engineCache.begin(), | - | ||||||||||||||||||||||||
| 3018 | end = engineCache.end(); | - | ||||||||||||||||||||||||
| 3019 | // determine the oldest and least popular of the unused engines | - | ||||||||||||||||||||||||
| 3020 | uint oldest = ~0u; | - | ||||||||||||||||||||||||
| 3021 | uint least_popular = ~0u; | - | ||||||||||||||||||||||||
| 3022 | - | |||||||||||||||||||||||||
| 3023 | EngineCache::Iterator jt = end; | - | ||||||||||||||||||||||||
| 3024 | - | |||||||||||||||||||||||||
| 3025 | for ( ; it != end; ++it) {
| 0 | ||||||||||||||||||||||||
| 3026 | if (it.value().data->ref.load() != engineCacheCount.value(it.value().data))
| 0 | ||||||||||||||||||||||||
| 3027 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 3028 | - | |||||||||||||||||||||||||
| 3029 | if (it.value().timestamp < oldest && it.value().hits <= least_popular) {
| 0 | ||||||||||||||||||||||||
| 3030 | oldest = it.value().timestamp; | - | ||||||||||||||||||||||||
| 3031 | least_popular = it.value().hits; | - | ||||||||||||||||||||||||
| 3032 | jt = it; | - | ||||||||||||||||||||||||
| 3033 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3034 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3035 | - | |||||||||||||||||||||||||
| 3036 | it = jt; | - | ||||||||||||||||||||||||
| 3037 | if (it != end) {
| 0 | ||||||||||||||||||||||||
| 3038 | FC_DEBUG(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d", dead code: QMessageLogger(__FILE__, 3038, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->type()); | - | ||||||||||||||||||||||||
| 3039 | it.value().data, it.value().timestamp, it.value().hits, dead code: QMessageLogger(__FILE__, 3038, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->type()); | - | ||||||||||||||||||||||||
| 3040 | it.value().data->ref.load(), engineCacheCount.value(it.value().data), dead code: QMessageLogger(__FILE__, 3038, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->type()); | - | ||||||||||||||||||||||||
| 3041 | it.value().data->type()); dead code: QMessageLogger(__FILE__, 3038, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->type()); | - | ||||||||||||||||||||||||
| 3042 | - | |||||||||||||||||||||||||
| 3043 | QFontEngine *fontEngine = it.value().data; | - | ||||||||||||||||||||||||
| 3044 | // get rid of all occurrences | - | ||||||||||||||||||||||||
| 3045 | it = engineCache.begin(); | - | ||||||||||||||||||||||||
| 3046 | while (it != engineCache.end()) {
| 0 | ||||||||||||||||||||||||
| 3047 | if (it.value().data == fontEngine) {
| 0 | ||||||||||||||||||||||||
| 3048 | fontEngine->ref.deref(); | - | ||||||||||||||||||||||||
| 3049 | it = engineCache.erase(it); | - | ||||||||||||||||||||||||
| 3050 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3051 | ++it; | - | ||||||||||||||||||||||||
| 3052 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3053 | } | - | ||||||||||||||||||||||||
| 3054 | // and delete the last occurrence | - | ||||||||||||||||||||||||
| 3055 | Q_ASSERT(fontEngine->ref.load() == 0); | - | ||||||||||||||||||||||||
| 3056 | decreaseCost(fontEngine->cache_cost); | - | ||||||||||||||||||||||||
| 3057 | delete fontEngine; | - | ||||||||||||||||||||||||
| 3058 | engineCacheCount.remove(fontEngine); | - | ||||||||||||||||||||||||
| 3059 | - | |||||||||||||||||||||||||
| 3060 | cost_decreased = true; | - | ||||||||||||||||||||||||
| 3061 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3062 | } while (cost_decreased && total_cost > max_cost); never executed: end of block
| 0 | ||||||||||||||||||||||||
| 3063 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3064 | - | |||||||||||||||||||||||||
| 3065 | - | |||||||||||||||||||||||||
| 3066 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||
| 3067 | QDebug operator<<(QDebug stream, const QFont &font) | - | ||||||||||||||||||||||||
| 3068 | { | - | ||||||||||||||||||||||||
| 3069 | return stream << "QFont(" << font.toString() << ')'; never executed: return stream << "QFont(" << font.toString() << ')'; | 0 | ||||||||||||||||||||||||
| 3070 | } | - | ||||||||||||||||||||||||
| 3071 | #endif | - | ||||||||||||||||||||||||
| 3072 | - | |||||||||||||||||||||||||
| 3073 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |