diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-03-05 10:03:16 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-19 03:59:42 +0100 |
commit | 0ef4a55014b840ce7ef29b60174dfd7af6b0e801 (patch) | |
tree | 1071f01f011e94b3fb7a9a7d54483cbf527a720d /src/gui/text/qrawfont.h | |
parent | 237fbcbea57a91de9fa037e354307969affb6dd6 (diff) |
Perform kerning in QRawFont::advancesForGlyphIndexes
Being able to calculate advances for series of glyphs include kerning
is important to be able get kerning on QGlyphRun.
Note this kerning is only truetype kerning, since opentype kerning is performed
during shaping.
Change-Id: I8d7458066431cbdce699647056fd0d7a76b20aa2
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/gui/text/qrawfont.h')
-rw-r--r-- | src/gui/text/qrawfont.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index 9fee7f1e44..eb84a8fee7 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -65,6 +65,13 @@ public: SubPixelAntialiasing }; + enum LayoutFlag { + SeparateAdvances = 0, + KernedAdvances = 1, + UseDesignMetrics = 2 + }; + Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag) + QRawFont(); QRawFont(const QString &fileName, qreal pixelSize, @@ -93,8 +100,10 @@ public: QVector<quint32> glyphIndexesForString(const QString &text) const; inline QVector<QPointF> advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes) const; + inline QVector<QPointF> advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes, LayoutFlags layoutFlags) const; bool glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const; bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const; + bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs, LayoutFlags layoutFlags) const; QImage alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialiasingType = SubPixelAntialiasing, @@ -145,14 +154,21 @@ private: Q_DECLARE_SHARED(QRawFont) -inline QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes) const +Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags) + +inline QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes, QRawFont::LayoutFlags layoutFlags) const { QVector<QPointF> advances(glyphIndexes.size()); - if (advancesForGlyphIndexes(glyphIndexes.constData(), advances.data(), glyphIndexes.size())) + if (advancesForGlyphIndexes(glyphIndexes.constData(), advances.data(), glyphIndexes.size(), layoutFlags)) return advances; return QVector<QPointF>(); } +inline QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes) const +{ + return advancesForGlyphIndexes(glyphIndexes, QRawFont::SeparateAdvances); +} + QT_END_NAMESPACE #endif // QT_NO_RAWFONT |