Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowsfontdatabasebase_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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 QWINDOWSFONTDATABASEBASE_P_H
5#define QWINDOWSFONTDATABASEBASE_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 <qpa/qplatformfontdatabase.h>
19#include <QtGui/private/qtgui-config_p.h>
20#include <QtCore/QSharedPointer>
21#include <QtCore/QLoggingCategory>
22#include <QtCore/qt_windows.h>
23
24#if QT_CONFIG(directwrite)
25 struct IDWriteFactory;
26 struct IDWriteGdiInterop;
27 struct IDWriteFontFace;
28#endif
29
30QT_BEGIN_NAMESPACE
31
32#if QT_CONFIG(directwrite)
33 class QCustomFontFileLoader;
34#endif
35
36class QWindowsFontEngineData
37{
38 Q_DISABLE_COPY_MOVE(QWindowsFontEngineData)
39public:
40 QWindowsFontEngineData();
41 ~QWindowsFontEngineData();
42
43 uint pow_gamma[256];
44
45 bool clearTypeEnabled = false;
46 qreal fontSmoothingGamma;
47 HDC hdc = 0;
48#if QT_CONFIG(directwrite)
49 IDWriteFactory *directWriteFactory = nullptr;
50 IDWriteGdiInterop *directWriteGdiInterop = nullptr;
51#endif
52};
53
54class Q_GUI_EXPORT QWindowsFontDatabaseBase : public QPlatformFontDatabase
55{
56public:
57 QWindowsFontDatabaseBase();
58 ~QWindowsFontDatabaseBase() override;
59
60 QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override;
61 QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override;
62
63 void invalidate() override;
64
65 static int defaultVerticalDPI();
66
67 static QSharedPointer<QWindowsFontEngineData> data();
68#if QT_CONFIG(directwrite)
69 static void createDirectWriteFactory(IDWriteFactory **factory);
70#endif
71 static QFont systemDefaultFont();
72 static HFONT systemFont();
73 static LOGFONT fontDefToLOGFONT(const QFontDef &fontDef, const QString &faceName);
74 static QFont LOGFONT_to_QFont(const LOGFONT& lf, int verticalDPI = 0);
75
76 static QString familyForStyleHint(QFont::StyleHint styleHint);
77 static QStringList extraTryFontsForFamily(const QString &family);
78 static QStringList familiesForScript(QFontDatabasePrivate::ExtendedScript script);
79
80 class FontTable{};
81 class EmbeddedFont
82 {
83 public:
84 EmbeddedFont(const QByteArray &fontData) : m_fontData(fontData) {}
85
86 QString changeFamilyName(const QString &newFamilyName);
87 QByteArray data() const { return m_fontData; }
88 void updateFromOS2Table(QFontEngine *fontEngine);
89 FontTable *tableDirectoryEntry(const QByteArray &tagName);
90 QString familyName(FontTable *nameTableDirectory = nullptr);
91
92 private:
93 QByteArray m_fontData;
94 };
95
96 QFontDef sanitizeRequest(QFontDef request) const;
97
98protected:
99
100#if QT_CONFIG(directwrite)
101 QList<IDWriteFontFace *> createDirectWriteFaces(const QByteArray &fontData,
102 const QString &filename,
103 bool queryVariations = true) const;
104 IDWriteFontFace *createDirectWriteFace(const QByteArray &fontData);
105#endif
106
107private:
108 static bool init(QSharedPointer<QWindowsFontEngineData> data);
109
110#if QT_CONFIG(directwrite)
111 mutable std::unique_ptr<QCustomFontFileLoader> m_fontFileLoader;
112#endif
113};
114
115QT_END_NAMESPACE
116
117#endif // QWINDOWSFONTDATABASEBASE_P_H
Font database for Windows.
static QFont::Stretch fromDirectWriteStretch(DWRITE_FONT_STRETCH stretch)
static QFont::Weight fromDirectWriteWeight(DWRITE_FONT_WEIGHT weight)
static QFont::Style fromDirectWriteStyle(DWRITE_FONT_STYLE style)
QT_REQUIRE_CONFIG(directwrite3)
quint16 qt_getUShort(const unsigned char *p)
QFontNames qt_getCanonicalFontNames(const LOGFONT &lf)
QString qt_getEnglishName(const QString &familyName, bool includeStyle=false)
size_t qHash(const FontAndStyle &key, size_t seed) noexcept
bool qt_localizedName(const QString &name)
friend bool operator!=(const FontAndStyle &lhs, const FontAndStyle &rhs) noexcept
friend bool operator==(const FontAndStyle &lhs, const FontAndStyle &rhs) noexcept