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 = fontD->engineForScript(QUnicodeTables::Common);
rawFontD->fontEngine->ref.ref(); rawFontD->fontEngine->ref.ref();
QGlyphs glyphs; QGlyphRun glyphs;
glyphs.setFont(rawFont); glyphs.setRawFont(rawFont);
glyphs.setGlyphIndexes(glyphIndexes); glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions); glyphs.setPositions(positions);
painter->drawGlyphs(QPointF(), glyphs); painter->drawGlyphRun(QPointF(), glyphs);
break; break;
} }
#endif #endif

View File

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

View File

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

View File

@ -43,14 +43,14 @@
#if !defined(QT_NO_RAWFONT) #if !defined(QT_NO_RAWFONT)
#include "qglyphs.h" #include "qglyphrun.h"
#include "qglyphs_p.h" #include "qglyphrun_p.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
/*! /*!
\class QGlyphs \class QGlyphRun
\brief The QGlyphs class provides direct access to the internal glyphs in a font. \brief The QGlyphRun class provides direct access to the internal glyphs in a font.
\since 4.8 \since 4.8
\ingroup text \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 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 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. 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. 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 It is the user's responsibility to ensure that the selected font actually contains the
provided glyph indexes. provided glyph indexes.
QTextLayout::glyphs() or QTextFragment::glyphs() can be used to convert unicode encoded text QTextLayout::glyphRuns() or QTextFragment::glyphRuns() can be used to convert unicode encoded
into a list of QGlyphs objects, and QPainter::drawGlyphs() can be used to draw the glyphs. 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. \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 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 QGlyphs contains a reference to a QRawFont from a different 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 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. 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; d = other.d;
} }
/*! /*!
Destroys the QGlyphs. Destroys the QGlyphRun.
*/ */
QGlyphs::~QGlyphs() QGlyphRun::~QGlyphRun()
{ {
// Required for QExplicitlySharedDataPointer // Required for QExplicitlySharedDataPointer
} }
@ -110,26 +111,26 @@ QGlyphs::~QGlyphs()
/*! /*!
\internal \internal
*/ */
void QGlyphs::detach() void QGlyphRun::detach()
{ {
if (d->ref != 1) if (d->ref != 1)
d.detach(); 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; d = other.d;
return *this; 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. 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) return ((d == other.d)
|| (d->glyphIndexes == other.d->glyphIndexes || (d->glyphIndexes == other.d->glyphIndexes
@ -137,14 +138,14 @@ bool QGlyphs::operator==(const QGlyphs &other) const
&& d->overline == other.d->overline && d->overline == other.d->overline
&& d->underline == other.d->underline && d->underline == other.d->underline
&& d->strikeOut == other.d->strikeOut && 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. 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); return !(*this == other);
} }
@ -152,13 +153,13 @@ bool QGlyphs::operator!=(const QGlyphs &other) const
/*! /*!
\internal \internal
Adds together the lists of glyph indexes and positions in \a other and this QGlyphs 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 QGlyphs will be the same as in object and returns the result. The font in the returned QGlyphRun will be the same as in
this QGlyphs object. 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; ret += other;
return ret; return ret;
} }
@ -166,10 +167,10 @@ QGlyphs QGlyphs::operator+(const QGlyphs &other) const
/*! /*!
\internal \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. a reference to the current object.
*/ */
QGlyphs &QGlyphs::operator+=(const QGlyphs &other) QGlyphRun &QGlyphRun::operator+=(const QGlyphRun &other)
{ {
detach(); 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. 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(); 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() \sa setGlyphIndexes(), setPositions()
*/ */
QVector<quint32> QGlyphs::glyphIndexes() const QVector<quint32> QGlyphRun::glyphIndexes() const
{ {
return d->glyphIndexes; 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. be valid for the selected font.
*/ */
void QGlyphs::setGlyphIndexes(const QVector<quint32> &glyphIndexes) void QGlyphRun::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
{ {
detach(); detach();
d->glyphIndexes = glyphIndexes; 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. 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; 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 Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to
\a positions. \a positions.
*/ */
void QGlyphs::setPositions(const QVector<QPointF> &positions) void QGlyphRun::setPositions(const QVector<QPointF> &positions)
{ {
detach(); detach();
d->glyphPositions = positions; d->glyphPositions = positions;
} }
/*! /*!
Clears all data in the QGlyphs object. Clears all data in the QGlyphRun object.
*/ */
void QGlyphs::clear() void QGlyphRun::clear()
{ {
detach(); detach();
d->glyphPositions = QVector<QPointF>(); d->glyphPositions = QVector<QPointF>();
d->glyphIndexes = QVector<quint32>(); d->glyphIndexes = QVector<quint32>();
d->font = QRawFont(); d->rawFont = QRawFont();
d->strikeOut = false; d->strikeOut = false;
d->overline = false; d->overline = false;
d->underline = 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() \sa setOverline()
*/ */
bool QGlyphs::overline() const bool QGlyphRun::overline() const
{ {
return d->overline; return d->overline;
} }
/*! /*!
Indicates that this QGlyphs should be painted with an overline decoration if \a overline is true. Indicates that this QGlyphRun should be painted with an overline decoration if \a overline is true.
Otherwise the QGlyphs should be painted with no overline decoration. Otherwise the QGlyphRun should be painted with no overline decoration.
\sa overline() \sa overline()
*/ */
void QGlyphs::setOverline(bool overline) void QGlyphRun::setOverline(bool overline)
{ {
detach(); detach();
d->overline = overline; 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() \sa setUnderline()
*/ */
bool QGlyphs::underline() const bool QGlyphRun::underline() const
{ {
return d->underline; return d->underline;
} }
/*! /*!
Indicates that this QGlyphs should be painted with an underline decoration if \a underline is Indicates that this QGlyphRun should be painted with an underline decoration if \a underline is
true. Otherwise the QGlyphs should be painted with no underline decoration. true. Otherwise the QGlyphRun should be painted with no underline decoration.
\sa underline() \sa underline()
*/ */
void QGlyphs::setUnderline(bool underline) void QGlyphRun::setUnderline(bool underline)
{ {
detach(); detach();
d->underline = underline; 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() \sa setStrikeOut()
*/ */
bool QGlyphs::strikeOut() const bool QGlyphRun::strikeOut() const
{ {
return d->strikeOut; return d->strikeOut;
} }
/*! /*!
Indicates that this QGlyphs should be painted with an strike out decoration if \a strikeOut is Indicates that this QGlyphRun should be painted with an strike out decoration if \a strikeOut is
true. Otherwise the QGlyphs should be painted with no strike out decoration. true. Otherwise the QGlyphRun should be painted with no strike out decoration.
\sa strikeOut() \sa strikeOut()
*/ */
void QGlyphs::setStrikeOut(bool strikeOut) void QGlyphRun::setStrikeOut(bool strikeOut)
{ {
detach(); detach();
d->strikeOut = strikeOut; d->strikeOut = strikeOut;

View File

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

View File

@ -39,8 +39,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef QGLYPHS_P_H #ifndef QGLYPHRUN_P_H
#define QGLYPHS_P_H #define QGLYPHRUN_P_H
// //
// W A R N I N G // W A R N I N G
@ -53,7 +53,7 @@
// We mean it. // We mean it.
// //
#include "qglyphs.h" #include "qglyphrun.h"
#include "qrawfont.h" #include "qrawfont.h"
#include <qfont.h> #include <qfont.h>
@ -64,21 +64,21 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QGlyphsPrivate: public QSharedData class QGlyphRunPrivate: public QSharedData
{ {
public: public:
QGlyphsPrivate() QGlyphRunPrivate()
: overline(false) : overline(false)
, underline(false) , underline(false)
, strikeOut(false) , strikeOut(false)
{ {
} }
QGlyphsPrivate(const QGlyphsPrivate &other) QGlyphRunPrivate(const QGlyphRunPrivate &other)
: QSharedData(other) : QSharedData(other)
, glyphIndexes(other.glyphIndexes) , glyphIndexes(other.glyphIndexes)
, glyphPositions(other.glyphPositions) , glyphPositions(other.glyphPositions)
, font(other.font) , rawFont(other.rawFont)
, overline(other.overline) , overline(other.overline)
, underline(other.underline) , underline(other.underline)
, strikeOut(other.strikeOut) , strikeOut(other.strikeOut)
@ -87,7 +87,7 @@ public:
QVector<quint32> glyphIndexes; QVector<quint32> glyphIndexes;
QVector<QPointF> glyphPositions; QVector<QPointF> glyphPositions;
QRawFont font; QRawFont rawFont;
uint overline : 1; uint overline : 1;
uint underline : 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. 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 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 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. 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 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: QRawFont can be constructed in a number of ways:
\list \list
\o \l It can be constructed by calling QTextLayout::glyphs() or QTextFragment::glyphs(). The \o \l It can be constructed by calling QTextLayout::glyphRuns() or QTextFragment::glyphRuns().
returned QGlyphs objects will contain QRawFont objects which represent the actual fonts The returned QGlyphRun objects will contain QRawFont objects which represent the actual
used to render each portion of the text. 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 \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 will return a QRawFont object representing the font that will be selected as response to
the QFont query and the selected writing system. 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 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. 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, QImage QRawFont::alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialiasingType,
const QTransform &transform) const 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 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 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 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 QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const
{ {
@ -587,12 +587,12 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ
layout.beginLayout(); layout.beginLayout();
QTextLine line = layout.createLine(); QTextLine line = layout.createLine();
layout.endLayout(); layout.endLayout();
QList<QGlyphs> list = layout.glyphs(); QList<QGlyphRun> list = layout.glyphRuns();
if (list.size()) { if (list.size()) {
// Pick the one matches the family name we originally requested, // Pick the one matches the family name we originally requested,
// if none of them match, just pick the first one // if none of them match, just pick the first one
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
QGlyphs glyphs = list.at(i); QGlyphRun glyphs = list.at(i);
QRawFont rawfont = glyphs.font(); QRawFont rawfont = glyphs.font();
if (rawfont.familyName() == font.family()) if (rawfont.familyName() == font.family())
return rawfont; return rawfont;

View File

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

View File

@ -49,7 +49,7 @@
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtGui/qevent.h> #include <QtGui/qevent.h>
#include <QtGui/qtextformat.h> #include <QtGui/qtextformat.h>
#include <QtGui/qglyphs.h> #include <QtGui/qglyphrun.h>
#include <QtGui/qtextcursor.h> #include <QtGui/qtextcursor.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -174,7 +174,7 @@ public:
qreal maximumWidth() const; qreal maximumWidth() const;
#if !defined(QT_NO_RAWFONT) #if !defined(QT_NO_RAWFONT)
QList<QGlyphs> glyphs() const; QList<QGlyphRun> glyphRuns() const;
#endif #endif
QTextEngine *engine() const { return d; } QTextEngine *engine() const { return d; }
@ -249,7 +249,7 @@ private:
void layout_helper(int numGlyphs); void layout_helper(int numGlyphs);
#if !defined(QT_NO_RAWFONT) #if !defined(QT_NO_RAWFONT)
QList<QGlyphs> glyphs(int from, int length) const; QList<QGlyphRun> glyphs(int from, int length) const;
#endif #endif
friend class QTextLayout; 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 Returns the glyphs of this text fragment. The positions of the glyphs are
relative to the position of the QTextBlock's layout. 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) #if !defined(QT_NO_RAWFONT)
QList<QGlyphs> QTextFragment::glyphs() const QList<QGlyphRun> QTextFragment::glyphRuns() const
{ {
if (!p || !n) if (!p || !n)
return QList<QGlyphs>(); return QList<QGlyphRun>();
int pos = position(); int pos = position();
int len = length(); int len = length();
if (len == 0) if (len == 0)
return QList<QGlyphs>(); return QList<QGlyphRun>();
int blockNode = p->blockMap().findNode(pos); int blockNode = p->blockMap().findNode(pos);
const QTextBlockData *blockData = p->blockMap().fragment(blockNode); const QTextBlockData *blockData = p->blockMap().fragment(blockNode);
QTextLayout *layout = blockData->layout; QTextLayout *layout = blockData->layout;
QList<QGlyphs> ret; QList<QGlyphRun> ret;
for (int i=0; i<layout->lineCount(); ++i) { for (int i=0; i<layout->lineCount(); ++i) {
QTextLine textLine = layout->lineAt(i); QTextLine textLine = layout->lineAt(i);
ret += textLine.glyphs(pos, len); ret += textLine.glyphs(pos, len);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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