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.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 QRAWFONT_H
5#define QRAWFONT_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qstring.h>
9#include <QtCore/qiodevice.h>
10#include <QtCore/qglobal.h>
11#include <QtCore/qobject.h>
12#include <QtCore/qpoint.h>
13#include <QtGui/qfont.h>
14#include <QtGui/qtransform.h>
15#include <QtGui/qfontdatabase.h>
16
17#if !defined(QT_NO_RAWFONT)
18
20
21
22class QRawFontPrivate;
23class Q_GUI_EXPORT QRawFont
24{
25public:
28 SubPixelAntialiasing
29 };
30
32 SeparateAdvances = 0,
33 KernedAdvances = 1,
34 UseDesignMetrics = 2
35 };
36 Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)
37
38 QRawFont();
40 qreal pixelSize,
43 qreal pixelSize,
45 QRawFont(const QRawFont &other);
46 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QRawFont)
47 QRawFont &operator=(const QRawFont &other);
48 ~QRawFont();
49
50 void swap(QRawFont &other) noexcept { d.swap(other.d); }
51
52 bool isValid() const;
53
54 bool operator==(const QRawFont &other) const;
55 inline bool operator!=(const QRawFont &other) const
56 { return !operator==(other); }
57
58 QString familyName() const;
59 QString styleName() const;
60
61 QFont::Style style() const;
62 int weight() const;
63
64 QList<quint32> glyphIndexesForString(const QString &text) const;
65 inline QList<QPointF> advancesForGlyphIndexes(const QList<quint32> &glyphIndexes) const;
66 inline QList<QPointF> advancesForGlyphIndexes(const QList<quint32> &glyphIndexes,
67 LayoutFlags layoutFlags) const;
68 bool glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const;
69 bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const;
70 bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs, LayoutFlags layoutFlags) const;
71
72 QImage alphaMapForGlyph(quint32 glyphIndex,
73 AntialiasingType antialiasingType = SubPixelAntialiasing,
74 const QTransform &transform = QTransform()) const;
75 QPainterPath pathForGlyph(quint32 glyphIndex) const;
76 QRectF boundingRect(quint32 glyphIndex) const;
77
78 void setPixelSize(qreal pixelSize);
79 qreal pixelSize() const;
80
81 QFont::HintingPreference hintingPreference() const;
82
83 qreal ascent() const;
84 qreal capHeight() const;
85 qreal descent() const;
86 qreal leading() const;
87 qreal xHeight() const;
88 qreal averageCharWidth() const;
89 qreal maxCharWidth() const;
90 qreal lineThickness() const;
91 qreal underlinePosition() const;
92
93 qreal unitsPerEm() const;
94
95 void loadFromFile(const QString &fileName,
96 qreal pixelSize,
97 QFont::HintingPreference hintingPreference);
98
99 void loadFromData(const QByteArray &fontData,
100 qreal pixelSize,
101 QFont::HintingPreference hintingPreference);
102
103 bool supportsCharacter(uint ucs4) const;
104 bool supportsCharacter(QChar character) const;
105 QList<QFontDatabase::WritingSystem> supportedWritingSystems() const;
106
107 QByteArray fontTable(const char *tagName) const;
108 QByteArray fontTable(QFont::Tag tag) const;
109
110 static QRawFont fromFont(const QFont &font,
112
113private:
114 friend class QRawFontPrivate;
115 friend class QTextLayout;
116 friend class QTextEngine;
117
118 QExplicitlySharedDataPointer<QRawFontPrivate> d;
119};
120
121Q_DECLARE_SHARED(QRawFont)
122
123Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags)
124
125Q_GUI_EXPORT size_t qHash(const QRawFont &font, size_t seed = 0) noexcept;
126
127inline QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &glyphIndexes,
128 QRawFont::LayoutFlags layoutFlags) const
129{
130 QList<QPointF> advances(glyphIndexes.size());
131 if (advancesForGlyphIndexes(glyphIndexes.constData(), advances.data(), int(glyphIndexes.size()), layoutFlags))
132 return advances;
133 return QList<QPointF>();
134}
135
136inline QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &glyphIndexes) const
137{
139}
140
142
143#endif // QT_NO_RAWFONT
144
145#endif // QRAWFONT_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
WritingSystem
\value Any \value Latin \value Greek \value Cyrillic \value Armenian \value Hebrew \value Arabic \val...
\reentrant
Definition qfont.h:22
HintingPreference
Definition qfont.h:55
@ PreferDefaultHinting
Definition qfont.h:56
Style
This enum describes the different styles of glyphs that are used to display text.
Definition qfont.h:76
\inmodule QtGui
Definition qimage.h:37
Definition qlist.h:75
\inmodule QtGui
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
QList< QPointF > advancesForGlyphIndexes(const QList< quint32 > &glyphIndexes, LayoutFlags layoutFlags) const
QList< QPointF > advancesForGlyphIndexes(const QList< quint32 > &glyphIndexes) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrawfont.h:136
AntialiasingType
This enum represents the different ways a glyph can be rasterized in the function alphaMapForGlyph().
Definition qrawfont.h:26
@ PixelAntialiasing
Definition qrawfont.h:27
bool operator!=(const QRawFont &other) const
Returns true if this QRawFont is not equal to other.
Definition qrawfont.h:55
void swap(QRawFont &other) noexcept
Definition qrawfont.h:50
@ SeparateAdvances
Definition qrawfont.h:32
\inmodule QtCore\reentrant
Definition qrect.h:484
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\reentrant
Definition qtextlayout.h:70
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
QString text
Combined button and popup list for selecting options.
AudioChannelLayoutTag tag
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
GLenum const void GLbitfield GLsizei numGlyphs
GLuint GLuint GLfloat weight
GLenum GLsizeiptr const void * fontData
GLuint GLenum GLenum transform
static const QRectF boundingRect(const QPointF *points, int pointCount)
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
Q_GUI_EXPORT size_t qHash(const QRawFont &font, size_t seed=0) noexcept
unsigned int quint32
Definition qtypes.h:50
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QSharedPointer< T > other(t)
[5]
The QFont::Tag type provides access to advanced font features.
Definition qfont.h:215