diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-07-20 12:26:06 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-08-02 09:01:30 (GMT) |
commit | 7fb31670f080c224249279c35240a8eb95f8d877 (patch) | |
tree | 44eac011bf5e64d681a3ff7ef4eff634875ad0d7 /src/gui/text/qtextlayout.cpp | |
parent | d4da5248006e4a9f4d6a454bf754407a34a09407 (diff) | |
download | Qt-7fb31670f080c224249279c35240a8eb95f8d877.zip Qt-7fb31670f080c224249279c35240a8eb95f8d877.tar.gz Qt-7fb31670f080c224249279c35240a8eb95f8d877.tar.bz2 |
Add QTextFragment::glyphs() accessor
Add a function to retrieve fonts, glyph indexes and positions needed to
visualize the text in a QTextFragment to allow converting the text of
a QTextDocument to QGlyphs objects.
Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index aff88f6..531e46b 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1134,7 +1134,7 @@ QList<QGlyphs> QTextLayout::glyphs() const { QList<QGlyphs> glyphs; for (int i=0; i<d->lines.size(); ++i) - glyphs += QTextLine(i, d).glyphs(); + glyphs += QTextLine(i, d).glyphs(-1, -1); return glyphs; } @@ -2198,13 +2198,16 @@ namespace { /*! \internal - Returns the glyph indexes and positions for all glyphs in this QTextLine. + Returns the glyph indexes and positions for all glyphs in this QTextLine which reside in + QScriptItems that overlap with the range defined by \a from and \a length. The arguments + specify characters, relative to the text in the layout. Note that it is not possible to + use this function to retrieve a subset of the glyphs in a QScriptItem. \since 4.8 \sa QTextLayout::glyphs() */ -QList<QGlyphs> QTextLine::glyphs() const +QList<QGlyphs> QTextLine::glyphs(int from, int length) const { const QScriptLine &line = eng->lines[i]; @@ -2217,7 +2220,13 @@ QList<QGlyphs> QTextLine::glyphs() const qreal y = line.y.toReal() + line.base().toReal(); while (!iterator.atEnd()) { QScriptItem &si = iterator.next(); + if (si.analysis.flags >= QScriptAnalysis::TabOrObject) + continue; + QPointF pos(iterator.x.toReal(), y); + if (from >= 0 && length >= 0 && + (from >= si.position + eng->length(&si) || from + length <= si.position)) + continue; QFont font = eng->font(si); |