Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qrawfont_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QRAWFONTPRIVATE_P_H
5#define QRAWFONTPRIVATE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/private/qtguiglobal_p.h>
19#include "qrawfont.h"
20
21#include "qfontengine_p.h"
22#include <QtCore/qthread.h>
23#include <QtCore/qthreadstorage.h>
24
25#if !defined(QT_NO_RAWFONT)
26
28
29namespace { class CustomFontFileLoader; }
30class Q_GUI_EXPORT QRawFontPrivate
31{
32public:
34 : fontEngine(nullptr)
35 , hintingPreference(QFont::PreferDefaultHinting)
36 , thread(nullptr)
37 {}
38
40 : fontEngine(other.fontEngine)
41 , hintingPreference(other.hintingPreference)
42 , thread(other.thread)
43 {
44#ifndef QT_NO_DEBUG
45 Q_ASSERT(fontEngine == nullptr || thread == QThread::currentThread());
46#endif
47 if (fontEngine != nullptr)
48 fontEngine->ref.ref();
49 }
50
52 {
53#ifndef QT_NO_DEBUG
54 Q_ASSERT(ref.loadRelaxed() == 0);
55#endif
56 cleanUp();
57 }
58
59 inline void cleanUp()
60 {
61 setFontEngine(nullptr);
62 hintingPreference = QFont::PreferDefaultHinting;
63 }
64
65 inline bool isValid() const
66 {
67#ifndef QT_NO_DEBUG
68 Q_ASSERT(fontEngine == nullptr || thread == QThread::currentThread());
69#endif
70 return fontEngine != nullptr;
71 }
72
74 {
75#ifndef QT_NO_DEBUG
76 Q_ASSERT(fontEngine == nullptr || thread == QThread::currentThread());
77#endif
78 if (fontEngine == engine)
79 return;
80
81 if (fontEngine != nullptr) {
82 if (!fontEngine->ref.deref())
83 delete fontEngine;
84#ifndef QT_NO_DEBUG
85 thread = nullptr;
86#endif
87 }
88
89 fontEngine = engine;
90
91 if (fontEngine != nullptr) {
92 fontEngine->ref.ref();
93#ifndef QT_NO_DEBUG
94 thread = QThread::currentThread();
95 Q_ASSERT(thread);
96#endif
97 }
98 }
99
100 void loadFromData(const QByteArray &fontData,
101 qreal pixelSize,
102 QFont::HintingPreference hintingPreference);
103
104 static QRawFontPrivate *get(const QRawFont &font) { return font.d.data(); }
105
109
110private:
111 QThread *thread;
112};
113
115
116#endif // QT_NO_RAWFONT
117
118#endif // QRAWFONTPRIVATE_P_H
\inmodule QtCore
Definition qatomic.h:112
\inmodule QtCore
Definition qbytearray.h:57
T * data() const noexcept
Returns a pointer to the shared data object.
\reentrant
Definition qfont.h:22
HintingPreference
Definition qfont.h:55
@ PreferDefaultHinting
Definition qfont.h:56
static QRawFontPrivate * get(const QRawFont &font)
Definition qrawfont_p.h:104
QRawFontPrivate(const QRawFontPrivate &other)
Definition qrawfont_p.h:39
QFont::HintingPreference hintingPreference
Definition qrawfont_p.h:107
QAtomicInt ref
Definition qrawfont_p.h:108
bool isValid() const
Definition qrawfont_p.h:65
QFontEngine * fontEngine
Definition qrawfont_p.h:106
void setFontEngine(QFontEngine *engine)
Definition qrawfont_p.h:73
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
static QThread * currentThread()
Definition qthread.cpp:1039
Combined button and popup list for selecting options.
GLint ref
GLenum GLsizeiptr const void * fontData
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
double qreal
Definition qtypes.h:187
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
QJSEngine engine
[0]