From 051ef6f294e8cbfa1e30e99e7fd4cf5fb38393f4 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 10 May 2011 09:43:00 +0200 Subject: 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) --- src/gui/painting/qpaintbuffer.cpp | 6 +- src/gui/painting/qpainter.cpp | 18 +-- src/gui/painting/qpainter.h | 4 +- src/gui/text/qglyphrun.cpp | 324 ++++++++++++++++++++++++++++++++++++++ src/gui/text/qglyphrun.h | 107 +++++++++++++ src/gui/text/qglyphrun_p.h | 103 ++++++++++++ src/gui/text/qglyphs.cpp | 323 ------------------------------------- src/gui/text/qglyphs.h | 107 ------------- src/gui/text/qglyphs_p.h | 103 ------------ src/gui/text/qrawfont.cpp | 18 +-- src/gui/text/qtextlayout.cpp | 22 +-- src/gui/text/qtextlayout.h | 6 +- src/gui/text/qtextobject.cpp | 10 +- src/gui/text/qtextobject.h | 4 +- src/gui/text/text.pri | 10 +- 15 files changed, 583 insertions(+), 582 deletions(-) create mode 100644 src/gui/text/qglyphrun.cpp create mode 100644 src/gui/text/qglyphrun.h create mode 100644 src/gui/text/qglyphrun_p.h delete mode 100644 src/gui/text/qglyphs.cpp delete mode 100644 src/gui/text/qglyphs.h delete mode 100644 src/gui/text/qglyphs_p.h (limited to 'src') diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 7870defd22..4e639380ba 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -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 diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 016d480526..6c588cf32e 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -62,7 +62,7 @@ #include "qthread.h" #include "qvarlengtharray.h" #include "qstatictext.h" -#include "qglyphs.h" +#include "qglyphrun.h" #include #include @@ -73,7 +73,7 @@ #include #include #include -#include +#include #include #include @@ -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 glyphIndexes = glyphs.glyphIndexes(); - QVector glyphPositions = glyphs.positions(); + QVector glyphIndexes = glyphRun.glyphIndexes(); + QVector glyphPositions = glyphRun.positions(); int count = qMin(glyphIndexes.size(), glyphPositions.size()); QVarLengthArray 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, diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 4b2c447cca..e8cc3a6bdb 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -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); diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp new file mode 100644 index 0000000000..ea527886cd --- /dev/null +++ b/src/gui/text/qglyphrun.cpp @@ -0,0 +1,324 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qglobal.h" + +#if !defined(QT_NO_RAWFONT) + +#include "qglyphrun.h" +#include "qglyphrun_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QGlyphRun + \brief The QGlyphRun class provides direct access to the internal glyphs in a font. + \since 4.8 + + \ingroup text + \mainclass + + When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points + into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode + representation of the text and the QFont object will in this case serve as a convenient + abstraction that hides the details of what actually takes place when displaying the text + on-screen. For instance, by the time the text actually reaches the screen, it may be represented + by a set of fonts in addition to the one specified by the user, e.g. in case the originally + selected font did not support all the writing systems contained in the text. + + 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. + 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::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 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 QGlyphRun object. +*/ +QGlyphRun::QGlyphRun() : d(new QGlyphRunPrivate) +{ +} + +/*! + Constructs a QGlyphRun object which is a copy of \a other. +*/ +QGlyphRun::QGlyphRun(const QGlyphRun &other) +{ + d = other.d; +} + +/*! + Destroys the QGlyphRun. +*/ +QGlyphRun::~QGlyphRun() +{ + // Required for QExplicitlySharedDataPointer +} + +/*! + \internal +*/ +void QGlyphRun::detach() +{ + if (d->ref != 1) + d.detach(); +} + +/*! + Assigns \a other to this QGlyphRun object. +*/ +QGlyphRun &QGlyphRun::operator=(const QGlyphRun &other) +{ + d = other.d; + return *this; +} + +/*! + 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 QGlyphRun::operator==(const QGlyphRun &other) const +{ + return ((d == other.d) + || (d->glyphIndexes == other.d->glyphIndexes + && d->glyphPositions == other.d->glyphPositions + && d->overline == other.d->overline + && d->underline == other.d->underline + && d->strikeOut == other.d->strikeOut + && d->rawFont == other.d->rawFont)); +} + +/*! + 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 QGlyphRun::operator!=(const QGlyphRun &other) const +{ + return !(*this == other); +} + +/*! + \internal + + 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. +*/ +QGlyphRun QGlyphRun::operator+(const QGlyphRun &other) const +{ + QGlyphRun ret(*this); + ret += other; + return ret; +} + +/*! + \internal + + Appends the glyph indexes and positions in \a other to this QGlyphRun object and returns + a reference to the current object. +*/ +QGlyphRun &QGlyphRun::operator+=(const QGlyphRun &other) +{ + detach(); + + d->glyphIndexes += other.d->glyphIndexes; + d->glyphPositions += other.d->glyphPositions; + + return *this; +} + +/*! + Returns the font selected for this QGlyphRun object. + + \sa setRawFont() +*/ +QRawFont QGlyphRun::rawFont() const +{ + return d->rawFont; +} + +/*! + Sets the font in which to look up the glyph indexes to \a font. + + \sa rawFont(), setGlyphIndexes() +*/ +void QGlyphRun::setRawFont(const QRawFont &rawFont) +{ + detach(); + d->rawFont = rawFont; +} + +/*! + Returns the glyph indexes for this QGlyphRun object. + + \sa setGlyphIndexes(), setPositions() +*/ +QVector QGlyphRun::glyphIndexes() const +{ + return d->glyphIndexes; +} + +/*! + Set the glyph indexes for this QGlyphRun object to \a glyphIndexes. The glyph indexes must + be valid for the selected font. +*/ +void QGlyphRun::setGlyphIndexes(const QVector &glyphIndexes) +{ + detach(); + d->glyphIndexes = glyphIndexes; +} + +/*! + Returns the position of the edge of the baseline for each glyph in this set of glyph indexes. +*/ +QVector QGlyphRun::positions() const +{ + return d->glyphPositions; +} + +/*! + Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to + \a positions. +*/ +void QGlyphRun::setPositions(const QVector &positions) +{ + detach(); + d->glyphPositions = positions; +} + +/*! + Clears all data in the QGlyphRun object. +*/ +void QGlyphRun::clear() +{ + detach(); + d->glyphPositions = QVector(); + d->glyphIndexes = QVector(); + d->rawFont = QRawFont(); + d->strikeOut = false; + d->overline = false; + d->underline = false; +} + +/*! + Returns true if this QGlyphRun should be painted with an overline decoration. + + \sa setOverline() +*/ +bool QGlyphRun::overline() const +{ + return d->overline; +} + +/*! + 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 QGlyphRun::setOverline(bool overline) +{ + detach(); + d->overline = overline; +} + +/*! + Returns true if this QGlyphRun should be painted with an underline decoration. + + \sa setUnderline() +*/ +bool QGlyphRun::underline() const +{ + return d->underline; +} + +/*! + 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 QGlyphRun::setUnderline(bool underline) +{ + detach(); + d->underline = underline; +} + +/*! + Returns true if this QGlyphRun should be painted with a strike out decoration. + + \sa setStrikeOut() +*/ +bool QGlyphRun::strikeOut() const +{ + return d->strikeOut; +} + +/*! + 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 QGlyphRun::setStrikeOut(bool strikeOut) +{ + detach(); + d->strikeOut = strikeOut; +} + +QT_END_NAMESPACE + +#endif // QT_NO_RAWFONT diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h new file mode 100644 index 0000000000..dcc166ea3e --- /dev/null +++ b/src/gui/text/qglyphrun.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGLYPHRUN_H +#define QGLYPHRUN_H + +#include +#include +#include +#include + +#if !defined(QT_NO_RAWFONT) + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QGlyphRunPrivate; +class Q_GUI_EXPORT QGlyphRun +{ +public: + QGlyphRun(); + QGlyphRun(const QGlyphRun &other); + ~QGlyphRun(); + + QRawFont rawFont() const; + void setRawFont(const QRawFont &rawFont); + + QVector glyphIndexes() const; + void setGlyphIndexes(const QVector &glyphIndexes); + + QVector positions() const; + void setPositions(const QVector &positions); + + void clear(); + + QGlyphRun &operator=(const QGlyphRun &other); + bool operator==(const QGlyphRun &other) const; + bool operator!=(const QGlyphRun &other) const; + + void setOverline(bool overline); + bool overline() const; + + void setUnderline(bool underline); + bool underline() const; + + void setStrikeOut(bool strikeOut); + bool strikeOut() const; + +private: + friend class QGlyphRunPrivate; + friend class QTextLine; + + QGlyphRun operator+(const QGlyphRun &other) const; + QGlyphRun &operator+=(const QGlyphRun &other); + + void detach(); + QExplicitlySharedDataPointer d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QT_NO_RAWFONT + +#endif // QGLYPHS_H diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h new file mode 100644 index 0000000000..4aa01d6bda --- /dev/null +++ b/src/gui/text/qglyphrun_p.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGLYPHRUN_P_H +#define QGLYPHRUN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include "qglyphrun.h" +#include "qrawfont.h" + +#include + +#if !defined(QT_NO_RAWFONT) + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QGlyphRunPrivate: public QSharedData +{ +public: + QGlyphRunPrivate() + : overline(false) + , underline(false) + , strikeOut(false) + { + } + + QGlyphRunPrivate(const QGlyphRunPrivate &other) + : QSharedData(other) + , glyphIndexes(other.glyphIndexes) + , glyphPositions(other.glyphPositions) + , rawFont(other.rawFont) + , overline(other.overline) + , underline(other.underline) + , strikeOut(other.strikeOut) + { + } + + QVector glyphIndexes; + QVector glyphPositions; + QRawFont rawFont; + + uint overline : 1; + uint underline : 1; + uint strikeOut : 1; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QGLYPHS_P_H + +#endif // QT_NO_RAWFONT diff --git a/src/gui/text/qglyphs.cpp b/src/gui/text/qglyphs.cpp deleted file mode 100644 index cfea6ece93..0000000000 --- a/src/gui/text/qglyphs.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglobal.h" - -#if !defined(QT_NO_RAWFONT) - -#include "qglyphs.h" -#include "qglyphs_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QGlyphs - \brief The QGlyphs class provides direct access to the internal glyphs in a font. - \since 4.8 - - \ingroup text - \mainclass - - When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points - into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode - representation of the text and the QFont object will in this case serve as a convenient - abstraction that hides the details of what actually takes place when displaying the text - on-screen. For instance, by the time the text actually reaches the screen, it may be represented - by a set of fonts in addition to the one specified by the user, e.g. in case the originally - selected font did not support all the writing systems contained in the text. - - 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 - 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. - - \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 - 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. -*/ -QGlyphs::QGlyphs() : d(new QGlyphsPrivate) -{ -} - -/*! - Constructs a QGlyphs object which is a copy of \a other. -*/ -QGlyphs::QGlyphs(const QGlyphs &other) -{ - d = other.d; -} - -/*! - Destroys the QGlyphs. -*/ -QGlyphs::~QGlyphs() -{ - // Required for QExplicitlySharedDataPointer -} - -/*! - \internal -*/ -void QGlyphs::detach() -{ - if (d->ref != 1) - d.detach(); -} - -/*! - Assigns \a other to this QGlyphs object. -*/ -QGlyphs &QGlyphs::operator=(const QGlyphs &other) -{ - d = other.d; - return *this; -} - -/*! - Compares \a other to this QGlyphs 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 -{ - return ((d == other.d) - || (d->glyphIndexes == other.d->glyphIndexes - && d->glyphPositions == other.d->glyphPositions - && d->overline == other.d->overline - && d->underline == other.d->underline - && d->strikeOut == other.d->strikeOut - && d->font == other.d->font)); -} - -/*! - Compares \a other to this QGlyphs 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 -{ - return !(*this == other); -} - -/*! - \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. -*/ -QGlyphs QGlyphs::operator+(const QGlyphs &other) const -{ - QGlyphs ret(*this); - ret += other; - return ret; -} - -/*! - \internal - - Appends the glyph indexes and positions in \a other to this QGlyphs object and returns - a reference to the current object. -*/ -QGlyphs &QGlyphs::operator+=(const QGlyphs &other) -{ - detach(); - - d->glyphIndexes += other.d->glyphIndexes; - d->glyphPositions += other.d->glyphPositions; - - return *this; -} - -/*! - Returns the font selected for this QGlyphs object. - - \sa setFont() -*/ -QRawFont QGlyphs::font() const -{ - return d->font; -} - -/*! - Sets the font in which to look up the glyph indexes to \a font. - - \sa font(), setGlyphIndexes() -*/ -void QGlyphs::setFont(const QRawFont &font) -{ - detach(); - d->font = font; -} - -/*! - Returns the glyph indexes for this QGlyphs object. - - \sa setGlyphIndexes(), setPositions() -*/ -QVector QGlyphs::glyphIndexes() const -{ - return d->glyphIndexes; -} - -/*! - Set the glyph indexes for this QGlyphs object to \a glyphIndexes. The glyph indexes must - be valid for the selected font. -*/ -void QGlyphs::setGlyphIndexes(const QVector &glyphIndexes) -{ - detach(); - d->glyphIndexes = glyphIndexes; -} - -/*! - Returns the position of the edge of the baseline for each glyph in this set of glyph indexes. -*/ -QVector QGlyphs::positions() const -{ - return d->glyphPositions; -} - -/*! - 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 &positions) -{ - detach(); - d->glyphPositions = positions; -} - -/*! - Clears all data in the QGlyphs object. -*/ -void QGlyphs::clear() -{ - detach(); - d->glyphPositions = QVector(); - d->glyphIndexes = QVector(); - d->font = QRawFont(); - d->strikeOut = false; - d->overline = false; - d->underline = false; -} - -/*! - Returns true if this QGlyphs should be painted with an overline decoration. - - \sa setOverline() -*/ -bool QGlyphs::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. - - \sa overline() -*/ -void QGlyphs::setOverline(bool overline) -{ - detach(); - d->overline = overline; -} - -/*! - Returns true if this QGlyphs should be painted with an underline decoration. - - \sa setUnderline() -*/ -bool QGlyphs::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. - - \sa underline() -*/ -void QGlyphs::setUnderline(bool underline) -{ - detach(); - d->underline = underline; -} - -/*! - Returns true if this QGlyphs should be painted with a strike out decoration. - - \sa setStrikeOut() -*/ -bool QGlyphs::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. - - \sa strikeOut() -*/ -void QGlyphs::setStrikeOut(bool strikeOut) -{ - detach(); - d->strikeOut = strikeOut; -} - -QT_END_NAMESPACE - -#endif // QT_NO_RAWFONT diff --git a/src/gui/text/qglyphs.h b/src/gui/text/qglyphs.h deleted file mode 100644 index 4d7dcaf554..0000000000 --- a/src/gui/text/qglyphs.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLYPHS_H -#define QGLYPHS_H - -#include -#include -#include -#include - -#if !defined(QT_NO_RAWFONT) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QGlyphsPrivate; -class Q_GUI_EXPORT QGlyphs -{ -public: - QGlyphs(); - QGlyphs(const QGlyphs &other); - ~QGlyphs(); - - QRawFont font() const; - void setFont(const QRawFont &font); - - QVector glyphIndexes() const; - void setGlyphIndexes(const QVector &glyphIndexes); - - QVector positions() const; - void setPositions(const QVector &positions); - - void clear(); - - QGlyphs &operator=(const QGlyphs &other); - bool operator==(const QGlyphs &other) const; - bool operator!=(const QGlyphs &other) const; - - void setOverline(bool overline); - bool overline() const; - - void setUnderline(bool underline); - bool underline() const; - - void setStrikeOut(bool strikeOut); - bool strikeOut() const; - -private: - friend class QGlyphsPrivate; - friend class QTextLine; - - QGlyphs operator+(const QGlyphs &other) const; - QGlyphs &operator+=(const QGlyphs &other); - - void detach(); - QExplicitlySharedDataPointer d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QT_NO_RAWFONT - -#endif // QGLYPHS_H diff --git a/src/gui/text/qglyphs_p.h b/src/gui/text/qglyphs_p.h deleted file mode 100644 index 944f777d4a..0000000000 --- a/src/gui/text/qglyphs_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLYPHS_P_H -#define QGLYPHS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of internal files. This header file may change from version to version -// without notice, or even be removed. -// -// We mean it. -// - -#include "qglyphs.h" -#include "qrawfont.h" - -#include - -#if !defined(QT_NO_RAWFONT) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGlyphsPrivate: public QSharedData -{ -public: - QGlyphsPrivate() - : overline(false) - , underline(false) - , strikeOut(false) - { - } - - QGlyphsPrivate(const QGlyphsPrivate &other) - : QSharedData(other) - , glyphIndexes(other.glyphIndexes) - , glyphPositions(other.glyphPositions) - , font(other.font) - , overline(other.overline) - , underline(other.underline) - , strikeOut(other.strikeOut) - { - } - - QVector glyphIndexes; - QVector glyphPositions; - QRawFont font; - - uint overline : 1; - uint underline : 1; - uint strikeOut : 1; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGLYPHS_P_H - -#endif // QT_NO_RAWFONT diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 46c892c500..4f2a01e432 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -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 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 list = layout.glyphs(); + QList 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; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index cb5ba0e672..8499e0bc51 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -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 @@ -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 QTextLayout::glyphs() const +QList QTextLayout::glyphRuns() const { - QList glyphs; + QList glyphs; for (int i=0; ilines.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 QTextLine::glyphs(int from, int length) const +QList QTextLine::glyphs(int from, int length) const { const QScriptLine &line = eng->lines[i]; if (line.length == 0) - return QList(); + return QList(); QHash glyphLayoutHash; @@ -2168,7 +2168,7 @@ QList QTextLine::glyphs(int from, int length) const } } - QHash, QGlyphs> glyphsHash; + QHash, QGlyphRun> glyphsHash; QList keys = glyphLayoutHash.uniqueKeys(); for (int i=0; i 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 key(fontEngine, int(flags)); if (!glyphsHash.contains(key)) diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index 6aa81f9e7c..8fe488a95a 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include QT_BEGIN_HEADER @@ -174,7 +174,7 @@ public: qreal maximumWidth() const; #if !defined(QT_NO_RAWFONT) - QList glyphs() const; + QList glyphRuns() const; #endif QTextEngine *engine() const { return d; } @@ -249,7 +249,7 @@ private: void layout_helper(int numGlyphs); #if !defined(QT_NO_RAWFONT) - QList glyphs(int from, int length) const; + QList glyphs(int from, int length) const; #endif friend class QTextLayout; diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 5c1c8b9edc..8dabcc771b 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -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 QTextFragment::glyphs() const +QList QTextFragment::glyphRuns() const { if (!p || !n) - return QList(); + return QList(); int pos = position(); int len = length(); if (len == 0) - return QList(); + return QList(); int blockNode = p->blockMap().findNode(pos); const QTextBlockData *blockData = p->blockMap().fragment(blockNode); QTextLayout *layout = blockData->layout; - QList ret; + QList ret; for (int i=0; ilineCount(); ++i) { QTextLine textLine = layout->lineAt(i); ret += textLine.glyphs(pos, len); diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h index ad8e6579dc..1588349a3f 100644 --- a/src/gui/text/qtextobject.h +++ b/src/gui/text/qtextobject.h @@ -44,7 +44,7 @@ #include #include -#include +#include QT_BEGIN_HEADER @@ -317,7 +317,7 @@ public: QString text() const; #if !defined(QT_NO_RAWFONT) - QList glyphs() const; + QList glyphRuns() const; #endif private: diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index e5d57d069d..b6cdc52e10 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -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 += \ -- cgit v1.2.3