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