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
qwindowsfontenginedirectwrite_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 QWINDOWSFONTENGINEDIRECTWRITE_H
5#define QWINDOWSFONTENGINEDIRECTWRITE_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/qtguiglobal.h>
19#include <QtGui/private/qtgui-config_p.h>
20
22
23#include <QtGui/private/qfontengine_p.h>
24#include <QtCore/QSharedPointer>
25
26#include <dwrite_2.h>
27
28struct IDWriteFont;
29struct IDWriteFontFace;
30struct IDWriteFontFile;
31struct IDWriteFactory;
32struct IDWriteBitmapRenderTarget;
33struct IDWriteGdiInterop;
34struct IDWriteGlyphRunAnalysis;
35struct IDWriteColorGlyphRunEnumerator;
36
37#if QT_CONFIG(directwritecolrv1)
38struct IDWriteFontFace7;
39struct IDWritePaintReader;
40struct DWRITE_PAINT_ELEMENT;
41#endif
42
43QT_BEGIN_NAMESPACE
44
45class QWindowsFontEngineData;
46class QColrPaintGraphRenderer;
47
48class Q_GUI_EXPORT QWindowsFontEngineDirectWrite : public QFontEngine
49{
50 Q_DISABLE_COPY_MOVE(QWindowsFontEngineDirectWrite)
51public:
52 explicit QWindowsFontEngineDirectWrite(IDWriteFontFace *directWriteFontFace,
53 qreal pixelSize,
54 const QSharedPointer<QWindowsFontEngineData> &d);
55 ~QWindowsFontEngineDirectWrite() override;
56
57 void initFontInfo(const QFontDef &request, int dpi);
58
59 QFixed lineThickness() const override;
60 QFixed underlinePosition() const override;
61 bool getSfntTableData(uint tag, uchar *buffer, uint *length) const override;
62 QFixed emSquareSize() const override;
63
64 glyph_t glyphIndex(uint ucs4) const override;
65 int stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
66 ShaperFlags flags) const override;
67 void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags) const override;
68
69 void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
70 QPainterPath *path, QTextItem::RenderFlags flags) override;
71
72 glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) override;
73 glyph_metrics_t boundingBox(glyph_t g) override;
74 glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, const QFixedPoint&,
75 const QTransform &matrix, GlyphFormat) override;
76
77 QFixed capHeight() const override;
78 QFixed xHeight() const override;
79 qreal maxCharWidth() const override;
80 FaceId faceId() const override;
81
82 bool supportsHorizontalSubPixelPositions() const override;
83
84 HFONT createHFONT() const;
85
86 QImage alphaMapForGlyph(glyph_t glyph, const QFixedPoint &subPixelPosition) override;
87 QImage alphaMapForGlyph(glyph_t glyph,
88 const QFixedPoint &subPixelPosition,
89 const QTransform &t) override;
90 QImage alphaRGBMapForGlyph(glyph_t t,
91 const QFixedPoint &subPixelPosition,
92 const QTransform &xform) override;
93 QImage bitmapForGlyph(glyph_t,
94 const QFixedPoint &subPixelPosition,
95 const QTransform &t,
96 const QColor &color) override;
97
98 QFontEngine *cloneWithSize(qreal pixelSize) const override;
99 Qt::HANDLE handle() const override;
100
101 const QSharedPointer<QWindowsFontEngineData> &fontEngineData() const { return m_fontEngineData; }
102
103 static QString fontNameSubstitute(const QString &familyName);
104
105 IDWriteFontFace *directWriteFontFace() const { return m_directWriteFontFace; }
106
107 void setUniqueFamilyName(const QString &newName) { m_uniqueFamilyName = newName; }
108
109 void initializeHeightMetrics() const override;
110
111 Properties properties() const override;
112
113 QPainterPath unscaledGlyph(glyph_t glyph) const;
114 void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) override;
115
116 QList<QFontVariableAxis> variableAxes() const override;
117
118 bool expectsGammaCorrectedBlending(QFontEngine::GlyphFormat format) const override;
119
120private:
121#if QT_CONFIG(directwritecolrv1)
122 bool traverseColr1(IDWritePaintReader *paintReader,
123 IDWriteFontFace7 *face7,
124 const DWRITE_PAINT_ELEMENT *paintElement,
125 QColrPaintGraphRenderer *graphRenderer) const;
126 bool renderColr1GlyphRun(QImage *image,
127 const DWRITE_GLYPH_RUN *glyphRun,
128 const DWRITE_MATRIX &transform,
129 QColor color) const;
130#endif
131
132 QRect paintGraphBounds(glyph_t glyph, const DWRITE_MATRIX &transform) const;
133 QRect alphaTextureBounds(glyph_t glyph, const DWRITE_MATRIX &transform);
134 QRect colorBitmapBounds(glyph_t glyph, const DWRITE_MATRIX &transform);
135 bool renderColr0GlyphRun(QImage *image,
136 const DWRITE_COLOR_GLYPH_RUN *colorGlyphRun,
137 const DWRITE_MATRIX &transform,
138 DWRITE_RENDERING_MODE renderMode,
139 DWRITE_MEASURING_MODE measureMode,
140 DWRITE_GRID_FIT_MODE gridFitMode,
141 QColor color,
142 QRect boundingRect) const;
143 QImage renderColorGlyph(DWRITE_GLYPH_RUN *glyphRun,
144 const DWRITE_MATRIX &transform,
145 DWRITE_RENDERING_MODE renderMode,
146 DWRITE_MEASURING_MODE measureMode,
147 DWRITE_GRID_FIT_MODE gridFitMode,
148 QColor color,
149 QRect boundingRect) const;
150 QImage imageForGlyph(glyph_t t,
151 const QFixedPoint &subPixelPosition,
152 int margin,
153 const QTransform &xform,
154 const QColor &color = QColor());
155 void collectMetrics();
156 void renderGlyphRun(QImage *destination,
157 float r,
158 float g,
159 float b,
160 float a,
161 IDWriteGlyphRunAnalysis *glyphAnalysis,
162 const QRect &boundingRect,
163 DWRITE_RENDERING_MODE renderMode) const;
164 static QString filenameFromFontFile(IDWriteFontFile *fontFile);
165 DWRITE_RENDERING_MODE hintingPreferenceToRenderingMode(const QFontDef &fontDef) const;
166
167 const QSharedPointer<QWindowsFontEngineData> m_fontEngineData;
168
169 IDWriteFontFace *m_directWriteFontFace;
170 IDWriteBitmapRenderTarget *m_directWriteBitmapRenderTarget;
171
172 bool useSymmetricAntialiasing() const;
173
174 QFixed m_lineThickness;
175 QFixed m_underlinePosition;
176 int m_unitsPerEm;
177 QFixed m_capHeight;
178 QFixed m_xHeight;
179 QFixed m_maxAdvanceWidth;
180 FaceId m_faceId;
181 QString m_uniqueFamilyName;
182 QList<QFontVariableAxis> m_variableAxes;
183 DWRITE_PIXEL_GEOMETRY m_pixelGeometry = DWRITE_PIXEL_GEOMETRY_RGB;
184
185 mutable int m_useSymmetricAntialiasing = -1;
186};
187
188QT_END_NAMESPACE
189
190#endif // QWINDOWSFONTENGINEDIRECTWRITE_H
Font database for Windows.
Windows font engine using Direct Write.
Combined button and popup list for selecting options.
QT_REQUIRE_CONFIG(liburing)
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