Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qwindowsfontdatabase_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
QWINDOWSFONTDATABASE_H
5
#
define
QWINDOWSFONTDATABASE_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
"qwindowsfontdatabasebase_p.h"
19
20
#
include
<
qpa
/
qplatformfontdatabase
.
h
>
21
#
include
<
QtCore
/
QSharedPointer
>
22
#
include
<
QtCore
/
QLoggingCategory
>
23
#
include
<
QtCore
/
qhashfunctions
.
h
>
24
#
include
<
QtCore
/
qmap
.
h
>
25
#
include
<
QtCore
/
qmutex
.
h
>
26
#
include
<
QtCore
/
qt_windows
.
h
>
27
28
QT_BEGIN_NAMESPACE
29
30
class
QDebug;
31
32
class
Q_GUI_EXPORT
QWindowsFontDatabase
:
public
QWindowsFontDatabaseBase
33
{
34
Q_DISABLE_COPY_MOVE(QWindowsFontDatabase)
35
public
:
36
enum
FontOptions {
37
// Relevant bits from QWindowsIntegration::Options
38
DontUseDirectWriteFonts = 0x40,
39
DontUseColorFonts = 0x80
40
};
41
42
QWindowsFontDatabase();
43
~QWindowsFontDatabase() override;
44
45
void
ensureFamilyPopulated(
const
QString &familyName);
46
47
void
populateFontDatabase() override;
48
void
invalidate() override;
49
void
removeApplicationFonts();
50
bool
supportsColrv0Fonts()
const
override;
51
52
void
populateFamily(
const
QString &familyName) override;
53
bool
populateFamilyAliases(
const
QString &missingFamily) override;
54
QFontEngine *fontEngine(
const
QFontDef &fontDef,
void
*handle) override;
55
QFontEngine *fontEngine(
const
QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override;
56
QStringList fallbacksForFamily(
const
QString &family, QFont::Style style, QFont::StyleHint styleHint, QFontDatabasePrivate::ExtendedScript script)
const
override;
57
QStringList addApplicationFont(
const
QByteArray &fontData,
const
QString &fileName, QFontDatabasePrivate::ApplicationFont *applicationFont =
nullptr
) override;
58
void
releaseHandle(
void
*handle) override;
59
QString fontDir()
const
override;
60
61
QFont defaultFont()
const
override {
return
systemDefaultFont(); }
62
bool
fontsAlwaysScalable()
const
override;
63
void
derefUniqueFont(
const
QString &uniqueFont);
64
void
refUniqueFont(
const
QString &uniqueFont);
65
bool
isPrivateFontFamily(
const
QString &family)
const
override;
66
67
static
QFontEngine *createEngine(
const
QFontDef &request,
const
QString &faceName,
68
int
dpi,
69
const
QSharedPointer<QWindowsFontEngineData> &data);
70
71
static
qreal fontSmoothingGamma();
72
73
static
void
setFontOptions(
unsigned
options);
74
static
unsigned
fontOptions();
75
76
#
ifndef
QT_NO_DEBUG_STREAM
77
static
void
debugFormat(QDebug &d,
const
LOGFONT &lf);
78
#
endif
// !QT_NO_DEBUG_STREAM
79
80
struct
FontHandle {
81
FontHandle(
const
QString &name) : faceName(name) {}
82
#
if
QT_CONFIG
(
directwrite
)
83
FontHandle(IDWriteFontFace *face,
const
QString &name);
84
#
endif
// !QT_NO_DIRECTWRITE
85
~FontHandle();
86
87
#
if
QT_CONFIG
(
directwrite
)
88
IDWriteFontFace *fontFace =
nullptr
;
89
#
endif
// !QT_NO_DIRECTWRITE
90
QString faceName;
91
};
92
93
private
:
94
void
addDefaultEUDCFont();
95
96
struct
WinApplicationFont {
97
HANDLE handle;
98
QString fileName;
99
};
100
101
QList<WinApplicationFont> m_applicationFonts;
102
103
struct
UniqueFontData {
104
HANDLE handle;
105
int
refCount;
106
};
107
108
QMutex m_uniqueFontDataMutex;
// protects m_uniqueFontData
109
QMap<QString, UniqueFontData> m_uniqueFontData;
110
111
static
unsigned
m_fontOptions;
112
QStringList m_eudcFonts;
113
bool
m_hasPopulatedAliases =
false
;
114
};
115
116
#
ifndef
QT_NO_DEBUG_STREAM
117
QDebug operator<<(QDebug,
const
QFontDef &def);
118
#
endif
119
120
inline
quint16
qt_getUShort
(
const
unsigned
char
*p)
121
{
122
quint16 val;
123
val = *p++ << 8;
124
val |= *p;
125
126
return
val;
127
}
128
129
struct
QFontNames
130
{
131
QString
name
;
// e.g. "DejaVu Sans Condensed"
132
QString
style
;
// e.g. "Italic"
133
QString
preferredName
;
// e.g. "DejaVu Sans"
134
QString
preferredStyle
;
// e.g. "Condensed Italic"
135
};
136
137
struct
QFontValues
138
{
139
quint16
weight
= 0;
140
bool
isItalic
=
false
;
141
bool
isOverstruck
=
false
;
142
bool
isUnderlined
=
false
;
143
};
144
145
bool
qt_localizedName
(
const
QString &name);
146
QString
qt_getEnglishName
(
const
QString &familyName,
bool
includeStyle =
false
);
147
QFontNames
qt_getCanonicalFontNames
(
const
LOGFONT &lf);
148
149
struct
FontAndStyle
{
150
QString
font
;
151
QString
style
;
152
153
friend
inline
bool
operator
==(
const
FontAndStyle
&lhs,
const
FontAndStyle
&rhs)
noexcept
154
{
return
lhs.font == rhs.font && lhs.style == rhs.style; }
155
friend
inline
bool
operator
!=(
const
FontAndStyle
&lhs,
const
FontAndStyle
&rhs)
noexcept
156
{
return
!
operator
==
(
lhs
,
rhs
)
; }
157
};
158
inline
size_t
qHash
(
const
FontAndStyle
&key, size_t seed)
noexcept
159
{
160
return
qHashMulti(seed, key.font, key.style);
161
}
162
163
QT_END_NAMESPACE
164
165
#
endif
// QWINDOWSFONTDATABASE_H
QWindowsDirectWriteFontDatabase
Definition
qwindowsdirectwritefontdatabase_p.h:31
QWindowsFontDatabase
Font database for Windows.
Definition
qwindowsfontdatabase_p.h:33
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
E_NOT_SUFFICIENT_BUFFER
#define E_NOT_SUFFICIENT_BUFFER
Definition
qwindowsdirectwritefontdatabase.cpp:23
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(directwrite3)
qt_getUShort
quint16 qt_getUShort(const unsigned char *p)
Definition
qwindowsfontdatabase_p.h:120
qt_getCanonicalFontNames
QFontNames qt_getCanonicalFontNames(const LOGFONT &lf)
Definition
qwindowsfontdatabase.cpp:406
qt_getEnglishName
QString qt_getEnglishName(const QString &familyName, bool includeStyle=false)
Definition
qwindowsfontdatabase.cpp:351
qHash
size_t qHash(const FontAndStyle &key, size_t seed) noexcept
Definition
qwindowsfontdatabase_p.h:158
qt_localizedName
bool qt_localizedName(const QString &name)
Definition
qwindowsfontdatabase.cpp:195
DirectWriteScope
Definition
qwindowsdirectwritefontdatabase.cpp:27
DirectWriteScope::~DirectWriteScope
~DirectWriteScope()
Definition
qwindowsdirectwritefontdatabase.cpp:29
DirectWriteScope::operator&
T ** operator&()
Definition
qwindowsdirectwritefontdatabase.cpp:34
DirectWriteScope::operator->
T * operator->()
Definition
qwindowsdirectwritefontdatabase.cpp:39
DirectWriteScope::DirectWriteScope
DirectWriteScope(T *res=nullptr)
Definition
qwindowsdirectwritefontdatabase.cpp:28
DirectWriteScope::operator*
T * operator*()
Definition
qwindowsdirectwritefontdatabase.cpp:44
FontAndStyle
Definition
qwindowsfontdatabase_p.h:149
FontAndStyle::font
QString font
Definition
qwindowsfontdatabase_p.h:150
FontAndStyle::style
QString style
Definition
qwindowsfontdatabase_p.h:151
FontAndStyle::operator!=
friend bool operator!=(const FontAndStyle &lhs, const FontAndStyle &rhs) noexcept
Definition
qwindowsfontdatabase_p.h:155
FontAndStyle::operator==
friend bool operator==(const FontAndStyle &lhs, const FontAndStyle &rhs) noexcept
Definition
qwindowsfontdatabase_p.h:153
QFontNames
Definition
qwindowsfontdatabase_p.h:130
QFontNames::style
QString style
Definition
qwindowsfontdatabase_p.h:132
QFontNames::name
QString name
Definition
qwindowsfontdatabase_p.h:131
QFontNames::preferredStyle
QString preferredStyle
Definition
qwindowsfontdatabase_p.h:134
QFontNames::preferredName
QString preferredName
Definition
qwindowsfontdatabase_p.h:133
QFontValues
Definition
qwindowsfontdatabase_p.h:138
QFontValues::isItalic
bool isItalic
Definition
qwindowsfontdatabase_p.h:140
QFontValues::isOverstruck
bool isOverstruck
Definition
qwindowsfontdatabase_p.h:141
QFontValues::weight
quint16 weight
Definition
qwindowsfontdatabase_p.h:139
QFontValues::isUnderlined
bool isUnderlined
Definition
qwindowsfontdatabase_p.h:142
qtbase
src
gui
text
windows
qwindowsfontdatabase_p.h
Generated on
for Qt by
1.18.0