Rename QGlyphs -> QGlyphRun

API clean-up for QGlyphRun:
1. QGlyphs -> QGlyphRun
2. QGlyphRun's font()/setFont() -> rawFont()/setRawFont()
3. QPainter::drawGlyphs() -> drawGlyphRun()
4. QTextLayout and QTextFragment's glyphs() -> glyphRuns()

Reviewed-by: Jiang Jiang
(cherry picked from commit 84ef364302728b68d2d29ea9c4ccbec32c7bb115)
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2011-05-10 09:43:00 +02:00
parent a35b2d58d9
commit 051ef6f294
17 changed files with 223 additions and 222 deletions

View File

@ -1778,12 +1778,12 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
rawFontD->fontEngine = fontD->engineForScript(QUnicodeTables::Common);
rawFontD->fontEngine->ref.ref();
QGlyphs glyphs;
glyphs.setFont(rawFont);
QGlyphRun glyphs;
glyphs.setRawFont(rawFont);
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
painter->drawGlyphs(QPointF(), glyphs);
painter->drawGlyphRun(QPointF(), glyphs);
break;
}
#endif

View File

@ -62,7 +62,7 @@
#include "qthread.h"
#include "qvarlengtharray.h"
#include "qstatictext.h"
#include "qglyphs.h"
#include "qglyphrun.h"
#include <private/qfontengine_p.h>
#include <private/qpaintengine_p.h>
@ -73,7 +73,7 @@
#include <private/qpaintengine_raster_p.h>
#include <private/qmath_p.h>
#include <private/qstatictext_p.h>
#include <private/qglyphs_p.h>
#include <private/qglyphrun_p.h>
#include <private/qstylehelper_p.h>
#include <private/qrawfont_p.h>
@ -5790,19 +5790,19 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR
\since 4.8
\sa QGlyphs::setFont(), QGlyphs::setPositions(), QGlyphs::setGlyphIndexes()
\sa QGlyphRun::setRawFont(), QGlyphRun::setPositions(), QGlyphRun::setGlyphIndexes()
*/
#if !defined(QT_NO_RAWFONT)
void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs)
void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun)
{
Q_D(QPainter);
QRawFont font = glyphs.font();
QRawFont font = glyphRun.rawFont();
if (!font.isValid())
return;
QVector<quint32> glyphIndexes = glyphs.glyphIndexes();
QVector<QPointF> glyphPositions = glyphs.positions();
QVector<quint32> glyphIndexes = glyphRun.glyphIndexes();
QVector<QPointF> glyphPositions = glyphRun.positions();
int count = qMin(glyphIndexes.size(), glyphPositions.size());
QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count);
@ -5825,8 +5825,8 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs)
fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition);
}
d->drawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count, font, glyphs.overline(),
glyphs.underline(), glyphs.strikeOut());
d->drawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count, font, glyphRun.overline(),
glyphRun.underline(), glyphRun.strikeOut());
}
void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, int glyphCount,

View File

@ -79,7 +79,7 @@ class QTextItem;
class QMatrix;
class QTransform;
class QStaticText;
class QGlyphs;
class QGlyphRun;
class QPainterPrivateDeleter;
@ -400,7 +400,7 @@ public:
Qt::LayoutDirection layoutDirection() const;
#if !defined(QT_NO_RAWFONT)
void drawGlyphs(const QPointF &position, const QGlyphs &glyphs);
void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun);
#endif
void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText);

View File

@ -43,14 +43,14 @@
#if !defined(QT_NO_RAWFONT)
#include "qglyphs.h"
#include "qglyphs_p.h"
#include "qglyphrun.h"
#include "qglyphrun_p.h"
QT_BEGIN_NAMESPACE
/*!
\class QGlyphs
\brief The QGlyphs class provides direct access to the internal glyphs in a font.
\class QGlyphRun
\brief The QGlyphRun class provides direct access to the internal glyphs in a font.
\since 4.8
\ingroup text
@ -67,42 +67,43 @@ QT_BEGIN_NAMESPACE
Under certain circumstances, it can be useful as an application developer to have more low-level
control over which glyphs in a specific font are drawn to the screen. This could for instance
be the case in applications that use an external font engine and text shaper together with Qt.
QGlyphs provides an interface to the raw data needed to get text on the screen. It
QGlyphRun provides an interface to the raw data needed to get text on the screen. It
contains a list of glyph indexes, a position for each glyph and a font.
It is the user's responsibility to ensure that the selected font actually contains the
provided glyph indexes.
QTextLayout::glyphs() or QTextFragment::glyphs() can be used to convert unicode encoded text
into a list of QGlyphs objects, and QPainter::drawGlyphs() can be used to draw the glyphs.
QTextLayout::glyphRuns() or QTextFragment::glyphRuns() can be used to convert unicode encoded
text into a list of QGlyphRun objects, and QPainter::drawGlyphRun() can be used to draw the
glyphs.
\note Please note that QRawFont is considered local to the thread in which it is constructed.
This in turn means that a new QRawFont will have to be created and set on the QGlyphs if it is
moved to a different thread. If the QGlyphs contains a reference to a QRawFont from a different
This in turn means that a new QRawFont will have to be created and set on the QGlyphRun if it is
moved to a different thread. If the QGlyphRun contains a reference to a QRawFont from a different
thread than the current, it will not be possible to draw the glyphs using a QPainter, as the
QRawFont is considered invalid and inaccessible in this case.
*/
/*!
Constructs an empty QGlyphs object.
Constructs an empty QGlyphRun object.
*/
QGlyphs::QGlyphs() : d(new QGlyphsPrivate)
QGlyphRun::QGlyphRun() : d(new QGlyphRunPrivate)
{
}
/*!
Constructs a QGlyphs object which is a copy of \a other.
Constructs a QGlyphRun object which is a copy of \a other.
*/
QGlyphs::QGlyphs(const QGlyphs &other)
QGlyphRun::QGlyphRun(const QGlyphRun &other)
{
d = other.d;
}
/*!
Destroys the QGlyphs.
Destroys the QGlyphRun.
*/
QGlyphs::~QGlyphs()
QGlyphRun::~QGlyphRun()
{
// Required for QExplicitlySharedDataPointer
}
@ -110,26 +111,26 @@ QGlyphs::~QGlyphs()
/*!
\internal
*/
void QGlyphs::detach()
void QGlyphRun::detach()
{
if (d->ref != 1)
d.detach();
}
/*!
Assigns \a other to this QGlyphs object.
Assigns \a other to this QGlyphRun object.
*/
QGlyphs &QGlyphs::operator=(const QGlyphs &other)
QGlyphRun &QGlyphRun::operator=(const QGlyphRun &other)
{
d = other.d;
return *this;
}
/*!
Compares \a other to this QGlyphs object. Returns true if the list of glyph indexes,
Compares \a other to this QGlyphRun object. Returns true if the list of glyph indexes,
the list of positions and the font are all equal, otherwise returns false.
*/
bool QGlyphs::operator==(const QGlyphs &other) const
bool QGlyphRun::operator==(const QGlyphRun &other) const
{
return ((d == other.d)
|| (d->glyphIndexes == other.d->glyphIndexes
@ -137,14 +138,14 @@ bool QGlyphs::operator==(const QGlyphs &other) const
&& d->overline == other.d->overline
&& d->underline == other.d->underline
&& d->strikeOut == other.d->strikeOut
&& d->font == other.d->font));
&& d->rawFont == other.d->rawFont));
}
/*!
Compares \a other to this QGlyphs object. Returns true if any of the list of glyph
Compares \a other to this QGlyphRun object. Returns true if any of the list of glyph
indexes, the list of positions or the font are different, otherwise returns false.
*/
bool QGlyphs::operator!=(const QGlyphs &other) const
bool QGlyphRun::operator!=(const QGlyphRun &other) const
{
return !(*this == other);
}
@ -152,13 +153,13 @@ bool QGlyphs::operator!=(const QGlyphs &other) const
/*!
\internal
Adds together the lists of glyph indexes and positions in \a other and this QGlyphs
object and returns the result. The font in the returned QGlyphs will be the same as in
this QGlyphs object.
Adds together the lists of glyph indexes and positions in \a other and this QGlyphRun
object and returns the result. The font in the returned QGlyphRun will be the same as in
this QGlyphRun object.
*/
QGlyphs QGlyphs::operator+(const QGlyphs &other) const
QGlyphRun QGlyphRun::operator+(const QGlyphRun &other) const
{
QGlyphs ret(*this);
QGlyphRun ret(*this);
ret += other;
return ret;
}
@ -166,10 +167,10 @@ QGlyphs QGlyphs::operator+(const QGlyphs &other) const
/*!
\internal
Appends the glyph indexes and positions in \a other to this QGlyphs object and returns
Appends the glyph indexes and positions in \a other to this QGlyphRun object and returns
a reference to the current object.
*/
QGlyphs &QGlyphs::operator+=(const QGlyphs &other)
QGlyphRun &QGlyphRun::operator+=(const QGlyphRun &other)
{
detach();
@ -180,41 +181,41 @@ QGlyphs &QGlyphs::operator+=(const QGlyphs &other)
}
/*!
Returns the font selected for this QGlyphs object.
Returns the font selected for this QGlyphRun object.
\sa setFont()
\sa setRawFont()
*/
QRawFont QGlyphs::font() const
QRawFont QGlyphRun::rawFont() const
{
return d->font;
return d->rawFont;
}
/*!
Sets the font in which to look up the glyph indexes to \a font.
\sa font(), setGlyphIndexes()
\sa rawFont(), setGlyphIndexes()
*/
void QGlyphs::setFont(const QRawFont &font)
void QGlyphRun::setRawFont(const QRawFont &rawFont)
{
detach();
d->font = font;
d->rawFont = rawFont;
}
/*!
Returns the glyph indexes for this QGlyphs object.
Returns the glyph indexes for this QGlyphRun object.
\sa setGlyphIndexes(), setPositions()
*/
QVector<quint32> QGlyphs::glyphIndexes() const
QVector<quint32> QGlyphRun::glyphIndexes() const
{
return d->glyphIndexes;
}
/*!
Set the glyph indexes for this QGlyphs object to \a glyphIndexes. The glyph indexes must
Set the glyph indexes for this QGlyphRun object to \a glyphIndexes. The glyph indexes must
be valid for the selected font.
*/
void QGlyphs::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
void QGlyphRun::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
{
detach();
d->glyphIndexes = glyphIndexes;
@ -223,7 +224,7 @@ void QGlyphs::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
/*!
Returns the position of the edge of the baseline for each glyph in this set of glyph indexes.
*/
QVector<QPointF> QGlyphs::positions() const
QVector<QPointF> QGlyphRun::positions() const
{
return d->glyphPositions;
}
@ -232,87 +233,87 @@ QVector<QPointF> QGlyphs::positions() const
Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to
\a positions.
*/
void QGlyphs::setPositions(const QVector<QPointF> &positions)
void QGlyphRun::setPositions(const QVector<QPointF> &positions)
{
detach();
d->glyphPositions = positions;
}
/*!
Clears all data in the QGlyphs object.
Clears all data in the QGlyphRun object.
*/
void QGlyphs::clear()
void QGlyphRun::clear()
{
detach();
d->glyphPositions = QVector<QPointF>();
d->glyphIndexes = QVector<quint32>();
d->font = QRawFont();
d->rawFont = QRawFont();
d->strikeOut = false;
d->overline = false;
d->underline = false;
}
/*!
Returns true if this QGlyphs should be painted with an overline decoration.
Returns true if this QGlyphRun should be painted with an overline decoration.
\sa setOverline()
*/
bool QGlyphs::overline() const
bool QGlyphRun::overline() const
{
return d->overline;
}
/*!
Indicates that this QGlyphs should be painted with an overline decoration if \a overline is true.
Otherwise the QGlyphs should be painted with no overline decoration.
Indicates that this QGlyphRun should be painted with an overline decoration if \a overline is true.
Otherwise the QGlyphRun should be painted with no overline decoration.
\sa overline()
*/
void QGlyphs::setOverline(bool overline)
void QGlyphRun::setOverline(bool overline)
{
detach();
d->overline = overline;
}
/*!
Returns true if this QGlyphs should be painted with an underline decoration.
Returns true if this QGlyphRun should be painted with an underline decoration.
\sa setUnderline()
*/
bool QGlyphs::underline() const
bool QGlyphRun::underline() const
{
return d->underline;
}
/*!
Indicates that this QGlyphs should be painted with an underline decoration if \a underline is
true. Otherwise the QGlyphs should be painted with no underline decoration.
Indicates that this QGlyphRun should be painted with an underline decoration if \a underline is
true. Otherwise the QGlyphRun should be painted with no underline decoration.
\sa underline()
*/
void QGlyphs::setUnderline(bool underline)
void QGlyphRun::setUnderline(bool underline)
{
detach();
d->underline = underline;
}
/*!
Returns true if this QGlyphs should be painted with a strike out decoration.
Returns true if this QGlyphRun should be painted with a strike out decoration.
\sa setStrikeOut()
*/
bool QGlyphs::strikeOut() const
bool QGlyphRun::strikeOut() const
{
return d->strikeOut;
}
/*!
Indicates that this QGlyphs should be painted with an strike out decoration if \a strikeOut is
true. Otherwise the QGlyphs should be painted with no strike out decoration.
Indicates that this QGlyphRun should be painted with an strike out decoration if \a strikeOut is
true. Otherwise the QGlyphRun should be painted with no strike out decoration.
\sa strikeOut()
*/
void QGlyphs::setStrikeOut(bool strikeOut)
void QGlyphRun::setStrikeOut(bool strikeOut)
{
detach();
d->strikeOut = strikeOut;

View File

@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef QGLYPHS_H
#define QGLYPHS_H
#ifndef QGLYPHRUN_H
#define QGLYPHRUN_H
#include <QtCore/qsharedpointer.h>
#include <QtCore/qvector.h>
@ -55,16 +55,16 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
class QGlyphsPrivate;
class Q_GUI_EXPORT QGlyphs
class QGlyphRunPrivate;
class Q_GUI_EXPORT QGlyphRun
{
public:
QGlyphs();
QGlyphs(const QGlyphs &other);
~QGlyphs();
QGlyphRun();
QGlyphRun(const QGlyphRun &other);
~QGlyphRun();
QRawFont font() const;
void setFont(const QRawFont &font);
QRawFont rawFont() const;
void setRawFont(const QRawFont &rawFont);
QVector<quint32> glyphIndexes() const;
void setGlyphIndexes(const QVector<quint32> &glyphIndexes);
@ -74,9 +74,9 @@ public:
void clear();
QGlyphs &operator=(const QGlyphs &other);
bool operator==(const QGlyphs &other) const;
bool operator!=(const QGlyphs &other) const;
QGlyphRun &operator=(const QGlyphRun &other);
bool operator==(const QGlyphRun &other) const;
bool operator!=(const QGlyphRun &other) const;
void setOverline(bool overline);
bool overline() const;
@ -88,14 +88,14 @@ public:
bool strikeOut() const;
private:
friend class QGlyphsPrivate;
friend class QGlyphRunPrivate;
friend class QTextLine;
QGlyphs operator+(const QGlyphs &other) const;
QGlyphs &operator+=(const QGlyphs &other);
QGlyphRun operator+(const QGlyphRun &other) const;
QGlyphRun &operator+=(const QGlyphRun &other);
void detach();
QExplicitlySharedDataPointer<QGlyphsPrivate> d;
QExplicitlySharedDataPointer<QGlyphRunPrivate> d;
};
QT_END_NAMESPACE

View File

@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef QGLYPHS_P_H
#define QGLYPHS_P_H
#ifndef QGLYPHRUN_P_H
#define QGLYPHRUN_P_H
//
// W A R N I N G
@ -53,7 +53,7 @@
// We mean it.
//
#include "qglyphs.h"
#include "qglyphrun.h"
#include "qrawfont.h"
#include <qfont.h>
@ -64,21 +64,21 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QGlyphsPrivate: public QSharedData
class QGlyphRunPrivate: public QSharedData
{
public:
QGlyphsPrivate()
QGlyphRunPrivate()
: overline(false)
, underline(false)
, strikeOut(false)
{
}
QGlyphsPrivate(const QGlyphsPrivate &other)
QGlyphRunPrivate(const QGlyphRunPrivate &other)
: QSharedData(other)
, glyphIndexes(other.glyphIndexes)
, glyphPositions(other.glyphPositions)
, font(other.font)
, rawFont(other.rawFont)
, overline(other.overline)
, underline(other.underline)
, strikeOut(other.strikeOut)
@ -87,7 +87,7 @@ public:
QVector<quint32> glyphIndexes;
QVector<QPointF> glyphPositions;
QRawFont font;
QRawFont rawFont;
uint overline : 1;
uint underline : 1;

View File

@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
A QRawFont object represents a single, physical instance of a given font in a given pixel size.
I.e. in the typical case it represents a set of TrueType or OpenType font tables and uses a
user specified pixel size to convert metrics into logical pixel units. In can be used in
combination with the QGlyphs class to draw specific glyph indexes at specific positions, and
combination with the QGlyphRun class to draw specific glyph indexes at specific positions, and
also have accessors to some relevant data in the physical font.
QRawFont only provides support for the main font technologies: GDI and DirectWrite on Windows
@ -87,9 +87,9 @@ QT_BEGIN_NAMESPACE
QRawFont can be constructed in a number of ways:
\list
\o \l It can be constructed by calling QTextLayout::glyphs() or QTextFragment::glyphs(). The
returned QGlyphs objects will contain QRawFont objects which represent the actual fonts
used to render each portion of the text.
\o \l It can be constructed by calling QTextLayout::glyphRuns() or QTextFragment::glyphRuns().
The returned QGlyphRun objects will contain QRawFont objects which represent the actual
fonts used to render each portion of the text.
\o \l It can be constructed by passing a QFont object to QRawFont::fromFont(). The function
will return a QRawFont object representing the font that will be selected as response to
the QFont query and the selected writing system.
@ -234,7 +234,7 @@ void QRawFont::loadFromData(const QByteArray &fontData,
the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of
QImage::Format_A8 and each pixel will contain the opacity of the pixel in the rasterization.
\sa pathForGlyph(), QPainter::drawGlyphs()
\sa pathForGlyph(), QPainter::drawGlyphRun()
*/
QImage QRawFont::alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialiasingType,
const QTransform &transform) const
@ -426,9 +426,9 @@ int QRawFont::weight() const
underlying font. Note that in cases where there are other tables in the font that affect the
shaping of the text, the returned glyph indexes will not correctly represent the rendering
of the text. To get the correctly shaped text, you can use QTextLayout to lay out and shape the
text, and then call QTextLayout::glyphs() to get the set of glyph index list and QRawFont pairs.
text, and then call QTextLayout::glyphRuns() to get the set of glyph index list and QRawFont pairs.
\sa advancesForGlyphIndexes(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs()
\sa advancesForGlyphIndexes(), QGlyphRun, QTextLayout::glyphRuns(), QTextFragment::glyphRuns()
*/
QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const
{
@ -587,12 +587,12 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ
layout.beginLayout();
QTextLine line = layout.createLine();
layout.endLayout();
QList<QGlyphs> list = layout.glyphs();
QList<QGlyphRun> list = layout.glyphRuns();
if (list.size()) {
// Pick the one matches the family name we originally requested,
// if none of them match, just pick the first one
for (int i = 0; i < list.size(); i++) {
QGlyphs glyphs = list.at(i);
QGlyphRun glyphs = list.at(i);
QRawFont rawfont = glyphs.font();
if (rawfont.familyName() == font.family())
return rawfont;

View File

@ -52,8 +52,8 @@
#include "qtextformat_p.h"
#include "qstyleoption.h"
#include "qpainterpath.h"
#include "qglyphs.h"
#include "qglyphs_p.h"
#include "qglyphrun.h"
#include "qglyphrun_p.h"
#include "qrawfont.h"
#include "qrawfont_p.h"
#include <limits.h>
@ -994,12 +994,12 @@ static inline QRectF clipIfValid(const QRectF &rect, const QRectF &clip)
\since 4.8
\sa draw(), QPainter::drawGlyphs()
\sa draw(), QPainter::drawGlyphRun()
*/
#if !defined(QT_NO_RAWFONT)
QList<QGlyphs> QTextLayout::glyphs() const
QList<QGlyphRun> QTextLayout::glyphRuns() const
{
QList<QGlyphs> glyphs;
QList<QGlyphRun> glyphs;
for (int i=0; i<d->lines.size(); ++i)
glyphs += QTextLine(i, d).glyphs(-1, -1);
@ -2095,15 +2095,15 @@ namespace {
\since 4.8
\sa QTextLayout::glyphs()
\sa QTextLayout::glyphRuns()
*/
#if !defined(QT_NO_RAWFONT)
QList<QGlyphs> QTextLine::glyphs(int from, int length) const
QList<QGlyphRun> QTextLine::glyphs(int from, int length) const
{
const QScriptLine &line = eng->lines[i];
if (line.length == 0)
return QList<QGlyphs>();
return QList<QGlyphRun>();
QHash<QFontEngine *, GlyphInfo> glyphLayoutHash;
@ -2168,7 +2168,7 @@ QList<QGlyphs> QTextLine::glyphs(int from, int length) const
}
}
QHash<QPair<QFontEngine *, int>, QGlyphs> glyphsHash;
QHash<QPair<QFontEngine *, int>, QGlyphRun> glyphsHash;
QList<QFontEngine *> keys = glyphLayoutHash.uniqueKeys();
for (int i=0; i<keys.size(); ++i) {
@ -2225,14 +2225,14 @@ QList<QGlyphs> QTextLine::glyphs(int from, int length) const
positions.append(positionsArray.at(i).toPointF() + pos);
}
QGlyphs glyphIndexes;
QGlyphRun glyphIndexes;
glyphIndexes.setGlyphIndexes(glyphs);
glyphIndexes.setPositions(positions);
glyphIndexes.setOverline(flags.testFlag(QTextItem::Overline));
glyphIndexes.setUnderline(flags.testFlag(QTextItem::Underline));
glyphIndexes.setStrikeOut(flags.testFlag(QTextItem::StrikeOut));
glyphIndexes.setFont(font);
glyphIndexes.setRawFont(font);
QPair<QFontEngine *, int> key(fontEngine, int(flags));
if (!glyphsHash.contains(key))

View File

@ -49,7 +49,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qevent.h>
#include <QtGui/qtextformat.h>
#include <QtGui/qglyphs.h>
#include <QtGui/qglyphrun.h>
#include <QtGui/qtextcursor.h>
QT_BEGIN_HEADER
@ -174,7 +174,7 @@ public:
qreal maximumWidth() const;
#if !defined(QT_NO_RAWFONT)
QList<QGlyphs> glyphs() const;
QList<QGlyphRun> glyphRuns() const;
#endif
QTextEngine *engine() const { return d; }
@ -249,7 +249,7 @@ private:
void layout_helper(int numGlyphs);
#if !defined(QT_NO_RAWFONT)
QList<QGlyphs> glyphs(int from, int length) const;
QList<QGlyphRun> glyphs(int from, int length) const;
#endif
friend class QTextLayout;

View File

@ -1664,25 +1664,25 @@ QTextBlock::iterator &QTextBlock::iterator::operator--()
Returns the glyphs of this text fragment. The positions of the glyphs are
relative to the position of the QTextBlock's layout.
\sa QGlyphs, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphs()
\sa QGlyphRun, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphRun()
*/
#if !defined(QT_NO_RAWFONT)
QList<QGlyphs> QTextFragment::glyphs() const
QList<QGlyphRun> QTextFragment::glyphRuns() const
{
if (!p || !n)
return QList<QGlyphs>();
return QList<QGlyphRun>();
int pos = position();
int len = length();
if (len == 0)
return QList<QGlyphs>();
return QList<QGlyphRun>();
int blockNode = p->blockMap().findNode(pos);
const QTextBlockData *blockData = p->blockMap().fragment(blockNode);
QTextLayout *layout = blockData->layout;
QList<QGlyphs> ret;
QList<QGlyphRun> ret;
for (int i=0; i<layout->lineCount(); ++i) {
QTextLine textLine = layout->lineAt(i);
ret += textLine.glyphs(pos, len);

View File

@ -44,7 +44,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qtextformat.h>
#include <QtGui/qglyphs.h>
#include <QtGui/qglyphrun.h>
QT_BEGIN_HEADER
@ -317,7 +317,7 @@ public:
QString text() const;
#if !defined(QT_NO_RAWFONT)
QList<QGlyphs> glyphs() const;
QList<QGlyphRun> glyphRuns() const;
#endif
private:

View File

@ -40,10 +40,10 @@ HEADERS += \
text/qtextodfwriter_p.h \
text/qstatictext_p.h \
text/qstatictext.h \
text/qglyphs.h \
text/qglyphs_p.h \
text/qrawfont.h \
text/qrawfont_p.h
text/qrawfont_p.h \
text/qglyphrun.h \
text/qglyphrun_p.h
SOURCES += \
text/qfont.cpp \
@ -74,8 +74,8 @@ SOURCES += \
text/qzip.cpp \
text/qtextodfwriter.cpp \
text/qstatictext.cpp \
text/qglyphs.cpp \
text/qrawfont.cpp
text/qrawfont.cpp \
text/qglyphrun.cpp
win32 {
SOURCES += \

View File

@ -58,7 +58,7 @@ SUBDIRS=\
qfontdialog \
qfontmetrics \
qformlayout \
qglyphs \
qglyphrun \
qgraphicsanchorlayout \
qgraphicsanchorlayout1 \
qgraphicseffect \

View File

@ -2,10 +2,10 @@ load(qttest_p4)
QT = core gui
SOURCES += \
tst_qglyphs.cpp
tst_qglyphrun.cpp
wince*|symbian*: {
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
}

View File

@ -41,14 +41,14 @@
#include <QtTest/QtTest>
#include <qglyphs.h>
#include <qglyphrun.h>
#include <qpainter.h>
#include <qtextlayout.h>
#include <qfontdatabase.h>
// #define DEBUG_SAVE_IMAGE
class tst_QGlyphs: public QObject
class tst_QGlyphRun: public QObject
{
Q_OBJECT
@ -82,9 +82,9 @@ private:
#if !defined(QT_NO_RAWFONT)
Q_DECLARE_METATYPE(QGlyphs);
Q_DECLARE_METATYPE(QGlyphRun);
void tst_QGlyphs::initTestCase()
void tst_QGlyphRun::initTestCase()
{
m_testFontId = QFontDatabase::addApplicationFont(SRCDIR "test.ttf");
QVERIFY(m_testFontId >= 0);
@ -94,19 +94,19 @@ void tst_QGlyphs::initTestCase()
QCOMPARE(QFontInfo(m_testFont).family(), QString::fromLatin1("QtsSpecialTestFont"));
}
void tst_QGlyphs::cleanupTestCase()
void tst_QGlyphRun::cleanupTestCase()
{
QFontDatabase::removeApplicationFont(m_testFontId);
}
void tst_QGlyphs::constructionAndDestruction()
void tst_QGlyphRun::constructionAndDestruction()
{
QGlyphs glyphIndexes;
QGlyphRun glyphIndexes;
}
static QGlyphs make_dummy_indexes()
static QGlyphRun make_dummy_indexes()
{
QGlyphs glyphs;
QGlyphRun glyphs;
QVector<quint32> glyphIndexes;
QVector<QPointF> positions;
@ -121,16 +121,16 @@ static QGlyphs make_dummy_indexes()
positions.append(QPointF(3, 4));
positions.append(QPointF(5, 6));
glyphs.setFont(QRawFont::fromFont(font));
glyphs.setRawFont(QRawFont::fromFont(font));
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
return glyphs;
}
void tst_QGlyphs::copyConstructor()
void tst_QGlyphRun::copyConstructor()
{
QGlyphs glyphs;
QGlyphRun glyphs;
{
QVector<quint32> glyphIndexes;
@ -146,40 +146,40 @@ void tst_QGlyphs::copyConstructor()
positions.append(QPointF(3, 4));
positions.append(QPointF(5, 6));
glyphs.setFont(QRawFont::fromFont(font));
glyphs.setRawFont(QRawFont::fromFont(font));
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
}
QGlyphs otherGlyphs(glyphs);
QCOMPARE(otherGlyphs.font(), glyphs.font());
QGlyphRun otherGlyphs(glyphs);
QCOMPARE(otherGlyphs.rawFont(), glyphs.rawFont());
QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes());
QCOMPARE(glyphs.positions(), otherGlyphs.positions());
}
void tst_QGlyphs::assignment()
void tst_QGlyphRun::assignment()
{
QGlyphs glyphs(make_dummy_indexes());
QGlyphRun glyphs(make_dummy_indexes());
QGlyphs otherGlyphs = glyphs;
QCOMPARE(otherGlyphs.font(), glyphs.font());
QGlyphRun otherGlyphs = glyphs;
QCOMPARE(otherGlyphs.rawFont(), glyphs.rawFont());
QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes());
QCOMPARE(glyphs.positions(), otherGlyphs.positions());
}
void tst_QGlyphs::equalsOperator_data()
void tst_QGlyphRun::equalsOperator_data()
{
QTest::addColumn<QGlyphs>("one");
QTest::addColumn<QGlyphs>("two");
QTest::addColumn<QGlyphRun>("one");
QTest::addColumn<QGlyphRun>("two");
QTest::addColumn<bool>("equals");
QGlyphs one(make_dummy_indexes());
QGlyphs two(make_dummy_indexes());
QGlyphRun one(make_dummy_indexes());
QGlyphRun two(make_dummy_indexes());
QTest::newRow("Identical") << one << two << true;
{
QGlyphs busted(two);
QGlyphRun busted(two);
QVector<QPointF> positions = busted.positions();
positions[2] += QPointF(1, 1);
@ -190,17 +190,17 @@ void tst_QGlyphs::equalsOperator_data()
}
{
QGlyphs busted(two);
QGlyphRun busted(two);
QFont font;
font.setPixelSize(busted.font().pixelSize() * 2);
busted.setFont(QRawFont::fromFont(font));
font.setPixelSize(busted.rawFont().pixelSize() * 2);
busted.setRawFont(QRawFont::fromFont(font));
QTest::newRow("Different fonts") << one << busted << false;
}
{
QGlyphs busted(two);
QGlyphRun busted(two);
QVector<quint32> glyphIndexes = busted.glyphIndexes();
glyphIndexes[2] += 1;
@ -211,10 +211,10 @@ void tst_QGlyphs::equalsOperator_data()
}
void tst_QGlyphs::equalsOperator()
void tst_QGlyphRun::equalsOperator()
{
QFETCH(QGlyphs, one);
QFETCH(QGlyphs, two);
QFETCH(QGlyphRun, one);
QFETCH(QGlyphRun, two);
QFETCH(bool, equals);
QCOMPARE(one == two, equals);
@ -222,7 +222,7 @@ void tst_QGlyphs::equalsOperator()
}
void tst_QGlyphs::textLayoutGlyphIndexes()
void tst_QGlyphRun::textLayoutGlyphIndexes()
{
QString s;
s.append(QLatin1Char('A'));
@ -234,17 +234,17 @@ void tst_QGlyphs::textLayoutGlyphIndexes()
layout.createLine();
layout.endLayout();
QList<QGlyphs> listOfGlyphs = layout.glyphs();
QList<QGlyphRun> listOfGlyphs = layout.glyphRuns();
QCOMPARE(listOfGlyphs.size(), 1);
QGlyphs glyphs = listOfGlyphs.at(0);
QGlyphRun glyphs = listOfGlyphs.at(0);
QCOMPARE(glyphs.glyphIndexes().size(), 2);
QCOMPARE(glyphs.glyphIndexes().at(0), quint32(2));
QCOMPARE(glyphs.glyphIndexes().at(1), quint32(1));
}
void tst_QGlyphs::drawExistingGlyphs()
void tst_QGlyphRun::drawExistingGlyphs()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@ -267,13 +267,13 @@ void tst_QGlyphs::drawExistingGlyphs()
layout.draw(&p, QPointF(50, 50));
}
QGlyphs glyphs = layout.glyphs().size() > 0
? layout.glyphs().at(0)
: QGlyphs();
QGlyphRun glyphs = layout.glyphRuns().size() > 0
? layout.glyphRuns().at(0)
: QGlyphRun();
{
QPainter p(&drawGlyphs);
p.drawGlyphs(QPointF(50, 50), glyphs);
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@ -284,7 +284,7 @@ void tst_QGlyphs::drawExistingGlyphs()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
void tst_QGlyphs::drawNonExistentGlyphs()
void tst_QGlyphRun::drawNonExistentGlyphs()
{
QVector<quint32> glyphIndexes;
glyphIndexes.append(3);
@ -292,10 +292,10 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QVector<QPointF> glyphPositions;
glyphPositions.append(QPointF(0, 0));
QGlyphs glyphs;
QGlyphRun glyphs;
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(glyphPositions);
glyphs.setFont(QRawFont::fromFont(m_testFont));
glyphs.setRawFont(QRawFont::fromFont(m_testFont));
QPixmap image(1000, 1000);
image.fill(Qt::white);
@ -303,7 +303,7 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QPixmap imageBefore = image;
{
QPainter p(&image);
p.drawGlyphs(QPointF(50, 50), glyphs);
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@ -313,7 +313,7 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QCOMPARE(image, imageBefore); // Should be unchanged
}
void tst_QGlyphs::drawMultiScriptText1()
void tst_QGlyphRun::drawMultiScriptText1()
{
QString text;
text += QChar(0x03D0); // Greek, beta
@ -329,7 +329,7 @@ void tst_QGlyphs::drawMultiScriptText1()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
QList<QGlyphs> glyphsList = textLayout.glyphs();
QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 1);
{
@ -339,8 +339,8 @@ void tst_QGlyphs::drawMultiScriptText1()
{
QPainter p(&drawGlyphs);
foreach (QGlyphs glyphs, glyphsList)
p.drawGlyphs(QPointF(50, 50), glyphs);
foreach (QGlyphRun glyphs, glyphsList)
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@ -352,7 +352,7 @@ void tst_QGlyphs::drawMultiScriptText1()
}
void tst_QGlyphs::drawMultiScriptText2()
void tst_QGlyphRun::drawMultiScriptText2()
{
QString text;
text += QChar(0x0621); // Arabic, Hamza
@ -369,7 +369,7 @@ void tst_QGlyphs::drawMultiScriptText2()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
QList<QGlyphs> glyphsList = textLayout.glyphs();
QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 2);
{
@ -379,8 +379,8 @@ void tst_QGlyphs::drawMultiScriptText2()
{
QPainter p(&drawGlyphs);
foreach (QGlyphs glyphs, glyphsList)
p.drawGlyphs(QPointF(50, 50), glyphs);
foreach (QGlyphRun glyphs, glyphsList)
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@ -391,13 +391,13 @@ void tst_QGlyphs::drawMultiScriptText2()
QCOMPARE(drawGlyphs, textLayoutDraw);
}
void tst_QGlyphs::detach()
void tst_QGlyphRun::detach()
{
QGlyphs glyphs;
QGlyphRun glyphs;
glyphs.setGlyphIndexes(QVector<quint32>() << 1 << 2 << 3);
QGlyphs otherGlyphs;
QGlyphRun otherGlyphs;
otherGlyphs = glyphs;
QCOMPARE(otherGlyphs.glyphIndexes(), glyphs.glyphIndexes());
@ -408,7 +408,7 @@ void tst_QGlyphs::detach()
QCOMPARE(glyphs.glyphIndexes(), QVector<quint32>() << 1 << 2 << 3);
}
void tst_QGlyphs::drawStruckOutText()
void tst_QGlyphRun::drawStruckOutText()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@ -432,13 +432,13 @@ void tst_QGlyphs::drawStruckOutText()
layout.draw(&p, QPointF(50, 50));
}
QGlyphs glyphs = layout.glyphs().size() > 0
? layout.glyphs().at(0)
: QGlyphs();
QGlyphRun glyphs = layout.glyphRuns().size() > 0
? layout.glyphRuns().at(0)
: QGlyphRun();
{
QPainter p(&drawGlyphs);
p.drawGlyphs(QPointF(50, 50), glyphs);
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@ -449,7 +449,7 @@ void tst_QGlyphs::drawStruckOutText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
void tst_QGlyphs::drawOverlinedText()
void tst_QGlyphRun::drawOverlinedText()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@ -473,13 +473,13 @@ void tst_QGlyphs::drawOverlinedText()
layout.draw(&p, QPointF(50, 50));
}
QGlyphs glyphs = layout.glyphs().size() > 0
? layout.glyphs().at(0)
: QGlyphs();
QGlyphRun glyphs = layout.glyphRuns().size() > 0
? layout.glyphRuns().at(0)
: QGlyphRun();
{
QPainter p(&drawGlyphs);
p.drawGlyphs(QPointF(50, 50), glyphs);
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@ -490,7 +490,7 @@ void tst_QGlyphs::drawOverlinedText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
void tst_QGlyphs::drawUnderlinedText()
void tst_QGlyphRun::drawUnderlinedText()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@ -514,13 +514,13 @@ void tst_QGlyphs::drawUnderlinedText()
layout.draw(&p, QPointF(50, 50));
}
QGlyphs glyphs = layout.glyphs().size() > 0
? layout.glyphs().at(0)
: QGlyphs();
QGlyphRun glyphs = layout.glyphRuns().size() > 0
? layout.glyphRuns().at(0)
: QGlyphRun();
{
QPainter p(&drawGlyphs);
p.drawGlyphs(QPointF(50, 50), glyphs);
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@ -531,7 +531,7 @@ void tst_QGlyphs::drawUnderlinedText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
void tst_QGlyphs::drawRightToLeft()
void tst_QGlyphRun::drawRightToLeft()
{
QString s;
s.append(QChar(1575));
@ -557,13 +557,13 @@ void tst_QGlyphs::drawRightToLeft()
layout.draw(&p, QPointF(50, 50));
}
QGlyphs glyphs = layout.glyphs().size() > 0
? layout.glyphs().at(0)
: QGlyphs();
QGlyphRun glyphs = layout.glyphRuns().size() > 0
? layout.glyphRuns().at(0)
: QGlyphRun();
{
QPainter p(&drawGlyphs);
p.drawGlyphs(QPointF(50, 50), glyphs);
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@ -577,6 +577,6 @@ void tst_QGlyphs::drawRightToLeft()
#endif // QT_NO_RAWFONT
QTEST_MAIN(tst_QGlyphs)
#include "tst_qglyphs.moc"
QTEST_MAIN(tst_QGlyphRun)
#include "tst_qglyphrun.moc"

View File

@ -296,12 +296,12 @@ void tst_QRawFont::textLayout()
layout.createLine();
layout.endLayout();
QList<QGlyphs> glyphss = layout.glyphs();
QCOMPARE(glyphss.size(), 1);
QList<QGlyphRun> glyphRuns = layout.glyphRuns();
QCOMPARE(glyphRuns.size(), 1);
QGlyphs glyphs = glyphss.at(0);
QGlyphRun glyphs = glyphRuns.at(0);
QRawFont rawFont = glyphs.font();
QRawFont rawFont = glyphs.rawFont();
QVERIFY(rawFont.isValid());
QCOMPARE(rawFont.familyName(), familyName);
QCOMPARE(rawFont.pixelSize(), 18.0);
@ -795,11 +795,11 @@ void tst_QRawFont::unsupportedWritingSystem()
layout.createLine();
layout.endLayout();
QList<QGlyphs> glyphss = layout.glyphs();
QCOMPARE(glyphss.size(), 1);
QList<QGlyphRun> glyphRuns = layout.glyphRuns();
QCOMPARE(glyphRuns.size(), 1);
QGlyphs glyphs = glyphss.at(0);
QRawFont layoutFont = glyphs.font();
QGlyphRun glyphs = glyphRuns.at(0);
QRawFont layoutFont = glyphs.rawFont();
QVERIFY(layoutFont.familyName() != QString::fromLatin1("QtBidiTestFont"));
QCOMPARE(layoutFont.pixelSize(), 12.0);