Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:08:16

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QRAWFONT_H
0005 #define QRAWFONT_H
0006 
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtCore/qstring.h>
0009 #include <QtCore/qiodevice.h>
0010 #include <QtCore/qglobal.h>
0011 #include <QtCore/qobject.h>
0012 #include <QtCore/qpoint.h>
0013 #include <QtGui/qfont.h>
0014 #include <QtGui/qtransform.h>
0015 #include <QtGui/qfontdatabase.h>
0016 
0017 #if !defined(QT_NO_RAWFONT)
0018 
0019 QT_BEGIN_NAMESPACE
0020 
0021 
0022 class QRawFontPrivate;
0023 class Q_GUI_EXPORT QRawFont
0024 {
0025 public:
0026     enum AntialiasingType {
0027         PixelAntialiasing,
0028         SubPixelAntialiasing
0029     };
0030 
0031     enum LayoutFlag {
0032         SeparateAdvances = 0,
0033         KernedAdvances = 1,
0034         UseDesignMetrics = 2
0035     };
0036     Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)
0037 
0038     QRawFont();
0039     QRawFont(const QString &fileName,
0040              qreal pixelSize,
0041              QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting);
0042     QRawFont(const QByteArray &fontData,
0043              qreal pixelSize,
0044              QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting);
0045     QRawFont(const QRawFont &other);
0046     QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QRawFont)
0047     QRawFont &operator=(const QRawFont &other);
0048     ~QRawFont();
0049 
0050     void swap(QRawFont &other) noexcept { d.swap(other.d); }
0051 
0052     bool isValid() const;
0053 
0054     bool operator==(const QRawFont &other) const;
0055     inline bool operator!=(const QRawFont &other) const
0056     { return !operator==(other); }
0057 
0058     QString familyName() const;
0059     QString styleName() const;
0060 
0061     QFont::Style style() const;
0062     int weight() const;
0063 
0064     QList<quint32> glyphIndexesForString(const QString &text) const;
0065     inline QList<QPointF> advancesForGlyphIndexes(const QList<quint32> &glyphIndexes) const;
0066     inline QList<QPointF> advancesForGlyphIndexes(const QList<quint32> &glyphIndexes,
0067                                                   LayoutFlags layoutFlags) const;
0068     bool glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const;
0069     bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const;
0070     bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs, LayoutFlags layoutFlags) const;
0071 
0072     QImage alphaMapForGlyph(quint32 glyphIndex,
0073                             AntialiasingType antialiasingType = SubPixelAntialiasing,
0074                             const QTransform &transform = QTransform()) const;
0075     QPainterPath pathForGlyph(quint32 glyphIndex) const;
0076     QRectF boundingRect(quint32 glyphIndex) const;
0077 
0078     void setPixelSize(qreal pixelSize);
0079     qreal pixelSize() const;
0080 
0081     QFont::HintingPreference hintingPreference() const;
0082 
0083     qreal ascent() const;
0084     qreal capHeight() const;
0085     qreal descent() const;
0086     qreal leading() const;
0087     qreal xHeight() const;
0088     qreal averageCharWidth() const;
0089     qreal maxCharWidth() const;
0090     qreal lineThickness() const;
0091     qreal underlinePosition() const;
0092 
0093     qreal unitsPerEm() const;
0094 
0095     void loadFromFile(const QString &fileName,
0096                       qreal pixelSize,
0097                       QFont::HintingPreference hintingPreference);
0098 
0099     void loadFromData(const QByteArray &fontData,
0100                       qreal pixelSize,
0101                       QFont::HintingPreference hintingPreference);
0102 
0103     bool supportsCharacter(uint ucs4) const;
0104     bool supportsCharacter(QChar character) const;
0105     QList<QFontDatabase::WritingSystem> supportedWritingSystems() const;
0106 
0107     QByteArray fontTable(const char *tagName) const;
0108     QByteArray fontTable(QFont::Tag tag) const;
0109 
0110     static QRawFont fromFont(const QFont &font,
0111                              QFontDatabase::WritingSystem writingSystem = QFontDatabase::Any);
0112 
0113 private:
0114     friend class QRawFontPrivate;
0115     friend class QTextLayout;
0116     friend class QTextEngine;
0117 
0118     QExplicitlySharedDataPointer<QRawFontPrivate> d;
0119 };
0120 
0121 Q_DECLARE_SHARED(QRawFont)
0122 
0123 Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags)
0124 
0125 Q_GUI_EXPORT size_t qHash(const QRawFont &font, size_t seed = 0) noexcept;
0126 
0127 inline QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &glyphIndexes,
0128                                                         QRawFont::LayoutFlags layoutFlags) const
0129 {
0130     QList<QPointF> advances(glyphIndexes.size());
0131     if (advancesForGlyphIndexes(glyphIndexes.constData(), advances.data(), int(glyphIndexes.size()), layoutFlags))
0132         return advances;
0133     return QList<QPointF>();
0134 }
0135 
0136 inline QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &glyphIndexes) const
0137 {
0138     return advancesForGlyphIndexes(glyphIndexes, QRawFont::SeparateAdvances);
0139 }
0140 
0141 QT_END_NAMESPACE
0142 
0143 #endif // QT_NO_RAWFONT
0144 
0145 #endif // QRAWFONT_H