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
QFont::Tag Class Reference

The QFont::Tag type provides access to advanced font features. More...

#include <qfont.h>

+ Collaboration diagram for QFont::Tag:

Public Member Functions

constexpr Tag ()=default
 Default constructor, producing an invalid tag.
 
template<size_t N>
constexpr Q_IMPLICIT Tag (const char(&str)[N]) noexcept
 Constructs a tag from a string literal, str.
 
constexpr bool isValid () const noexcept
 Returns whether the tag is valid.
 
constexpr quint32 value () const noexcept
 Returns the numerical value of this tag.
 
QByteArray toString () const
 Returns the string representation of this tag as a byte array.
 

Static Public Member Functions

static constexpr std::optional< TagfromValue (quint32 value) noexcept
 Returns a tag constructed from value, or std::nullopt if the tag produced would be invalid.
 
static Q_GUI_EXPORT std::optional< TagfromString (QAnyStringView view) noexcept
 Returns a tag constructed from the string in view.
 

Friends

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, Tag)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, Tag &)
 Data stream operators for QFont::Tag.
 
Q_GUI_EXPORT QDebug operator<< (QDebug debug, Tag tag)
 
constexpr size_t qHash (Tag key, size_t seed=0) noexcept
 Returns the hash value for key, using seed to seed the calculation.
 
constexpr bool comparesEqual (const Tag &lhs, const Tag &rhs) noexcept
 
constexpr Qt::strong_ordering compareThreeWay (const Tag &lhs, const Tag &rhs) noexcept
 Compare lhs with rhs for equality and ordering.
 

Related Symbols

(Note that these are not member symbols.)

QDataStreamoperator>> (QDataStream &, QFont::Tag &)
 Data stream operators for QFont::Tag.
 

Detailed Description

The QFont::Tag type provides access to advanced font features.

Since
6.7 \inmodule QtGui

QFont provides access to advanced features when shaping text. A feature is defined by a tag, which can be represented as a four-character string, or as a 32bit integer value. This type represents such a tag in a type-safe way. It can be constructed from a four-character, 8bit string literal, or from a corresponding 32bit integer value. Using a shorter or longer string literal will result in a compile-time error.

// Correct
font.setFeature("frac");
// Wrong - won't compile
font.setFeature("fraction");
// Wrong - will produce runtime warning and fail
font.setFeature(u"fraction"_s);
\reentrant
Definition qfont.h:22
void setFeature(Tag tag, quint32 value)
Definition qfont.cpp:2574

The named constructors allow to create a tag from an 32bit integer or string value, and will return a std::nullopt when the input is invalid.

See also
QFont::setFeature(), QFont::featureTags()

Definition at line 214 of file qfont.h.

Constructor & Destructor Documentation

◆ Tag() [1/2]

QFont::Tag::Tag ( )
constexprdefault

Default constructor, producing an invalid tag.

◆ Tag() [2/2]

template<size_t N>
template< size_t N > QFont::Tag::Tag ( const char(&) str[N])
inlineconstexprnoexcept

Constructs a tag from a string literal, str.

The literal must be exactly four characters long.

font.setFeature("frac", 1);
See also
fromString(), fromValue()

Definition at line 219 of file qfont.h.

Member Function Documentation

◆ fromString()

std::optional< QFont::Tag > QFont::Tag::fromString ( QAnyStringView view)
staticnoexcept

Returns a tag constructed from the string in view.

The string must be exactly four characters long.

Returns std::nullopt if the input is not four characters long, or if the tag produced would be invalid.

See also
isValid(), fromValue()

Definition at line 2376 of file qfont.cpp.

References fromString(), qWarning, and view.

Referenced by fromString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromValue()

std::optional< QFont::Tag > QFont::Tag::fromValue ( quint32 value)
inlinestaticconstexprnoexcept

Returns a tag constructed from value, or std::nullopt if the tag produced would be invalid.

See also
isValid()

Definition at line 239 of file qfont.h.

◆ isValid()

bool QFont::Tag::isValid ( ) const
inlineconstexprnoexcept

Returns whether the tag is valid.

A tag is valid if its value is not zero.

See also
value(), fromValue(), fromString()

Definition at line 226 of file qfont.h.

◆ toString()

QByteArray QFont::Tag::toString ( ) const
inline

Returns the string representation of this tag as a byte array.

See also
fromString()

Definition at line 229 of file qfont.h.

References QByteArray().

+ Here is the call graph for this function:

◆ value()

quint32 QFont::Tag::value ( ) const
inlineconstexprnoexcept

Returns the numerical value of this tag.

See also
isValid(), fromValue()

Definition at line 227 of file qfont.h.

Referenced by QFreeTypeFontDatabase::addNamedInstancesForFace(), bindFont(), calculateActualItalic(), calculateActualWeight(), generateGlyphTables(), generateHead(), generateHhea(), generateMaxp(), generateName(), getFontDescription(), and QFontSubset::toTruetype().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ comparesEqual

bool QFont::Tag::comparesEqual ( const Tag & lhs,
const Tag & rhs )
friend

Definition at line 260 of file qfont.h.

◆ compareThreeWay

Qt::strong_ordering QFont::Tag::compareThreeWay ( const Tag & lhs,
const Tag & rhs )
friend

Compare lhs with rhs for equality and ordering.

Definition at line 262 of file qfont.h.

◆ operator<< [1/2]

Q_GUI_EXPORT QDataStream & operator<< ( QDataStream & stream,
QFont::Tag tag )
friend

Definition at line 2935 of file qfont.cpp.

◆ operator<< [2/2]

Q_GUI_EXPORT QDebug operator<< ( QDebug debug,
QFont::Tag tag )
friend

Definition at line 3829 of file qfont.cpp.

◆ operator>>() [1/2]

QDataStream & operator>> ( QDataStream & ,
QFont::Tag &  )
related

Data stream operators for QFont::Tag.

Definition at line 2941 of file qfont.cpp.

◆ operator>> [2/2]

QDataStream & operator>> ( QDataStream & stream,
QFont::Tag & tag )
friend

Data stream operators for QFont::Tag.

Definition at line 2941 of file qfont.cpp.

◆ qHash

size_t QFont::Tag::qHash ( QFont::Tag key,
size_t seed = 0 )
friend

Returns the hash value for key, using seed to seed the calculation.

Definition at line 256 of file qfont.h.


The documentation for this class was generated from the following files: