diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-05-17 02:56:03 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-05-17 02:56:03 (GMT) |
commit | 4109badc4321effeeb798dd101479be7dffdbe3d (patch) | |
tree | ab69ab72be3d717e681a27b20ea26b61782394b3 | |
parent | 219175903f9722bee12271321614cdaeb88eb914 (diff) | |
parent | 806d49e49be10ca7a478b1f0afc4fd0c98321480 (diff) | |
download | Qt-4109badc4321effeeb798dd101479be7dffdbe3d.zip Qt-4109badc4321effeeb798dd101479be7dffdbe3d.tar.gz Qt-4109badc4321effeeb798dd101479be7dffdbe3d.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging: (23 commits)
Fix QGLWidget::renderPixmap for raster engine on Mac
Check if OES_texture_npot is present on OpenGL ES 2.
Fix tst_QVariant::invalidColor
Move QTextCursor::MoveStyle to Qt namespace
Move the painting redirection to the unified toolbar surface.
Fix misspelled word in comment.
Build fix for tst_qrawfont
Add some QRawFont related low level functions to avoid extra copying
Compile on Mac
Rename QGlyphs -> QGlyphRun
Fix QRawFont::setPixelSize() on Mac
Remove warning from QColor::setNamedColor().
Add internal documentation for QUnifiedToolbarSurface.
Fix QPainter::drawGlyphs() with non-affine transformation
Remove misspelled comment in tst_qtextdocument.cpp
Only enable design metrics for scalable fonts
Add a way to retrieve CTFontRef from QFont
Include pixel size of font in exported HTML from QTextDocument
Fix the autotest condition.
Change the repaint() call to an update().
...
48 files changed, 524 insertions, 334 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 75ce68a..f086513 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -94,6 +94,7 @@ Qt { Q_ENUMS(GestureState) Q_ENUMS(GestureType) #endif + Q_ENUMS(CursorMoveStyle) #endif // (defined(Q_MOC_RUN) || defined(QT_JAMBI_RUN)) #if defined(Q_MOC_RUN) @@ -1784,6 +1785,11 @@ public: NavigationModeCursorAuto, NavigationModeCursorForceVisible }; + + enum CursorMoveStyle { + LogicalMoveStyle, + VisualMoveStyle + }; } #ifdef Q_MOC_RUN ; diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 72e2aa6..e107d88 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -54,6 +54,7 @@ #include <private/qpaintengine_mac_p.h> #include <private/qt_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> +#include <private/qapplication_p.h> #include <limits.h> #include <string.h> @@ -73,12 +74,18 @@ static int qt_pixmap_serial = 0; Q_GUI_EXPORT quint32 *qt_mac_pixmap_get_base(const QPixmap *pix) { - return static_cast<QMacPixmapData*>(pix->data.data())->pixels; + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) + return reinterpret_cast<quint32 *>(static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bits()); + else + return static_cast<QMacPixmapData*>(pix->data.data())->pixels; } Q_GUI_EXPORT int qt_mac_pixmap_get_bytes_per_line(const QPixmap *pix) { - return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow; + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) + return static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bytesPerLine(); + else + return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow; } void qt_mac_cgimage_data_free(void *info, const void *memoryToFree, size_t) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 80d7b85..4c1a6dd 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1389,16 +1389,6 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) QApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); extraPaintEngine = 0; - -#ifdef QT_MAC_USE_COCOA - // If we add a child to the unified toolbar, we have to redirect the painting. - if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) { - if (parentWidget->d_func()->unifiedSurface) { - QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor; - parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset); - } - } -#endif // QT_MAC_USE_COCOA } diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 354f05b..468de22 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2733,7 +2733,7 @@ QWidget::macCGHandle() const return handle(); } -void qt_mac_repaintParentUnderAlienWidget(QWidget *alienWidget) +void qt_mac_updateParentUnderAlienWidget(QWidget *alienWidget) { QWidget *nativeParent = alienWidget->nativeParentWidget(); if (!nativeParent) @@ -2741,7 +2741,7 @@ void qt_mac_repaintParentUnderAlienWidget(QWidget *alienWidget) QPoint globalPos = alienWidget->mapToGlobal(QPoint(0, 0)); QRect dirtyRect = QRect(nativeParent->mapFromGlobal(globalPos), alienWidget->size()); - nativeParent->repaint(dirtyRect); + nativeParent->update(dirtyRect); } void QWidget::destroy(bool destroyWindow, bool destroySubWindows) @@ -2752,7 +2752,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if (!isWindow() && parentWidget()) parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); if (!internalWinId()) - qt_mac_repaintParentUnderAlienWidget(this); + qt_mac_updateParentUnderAlienWidget(this); d->deactivateWidgetCleanup(); qt_mac_event_release(this); if(testAttribute(Qt::WA_WState_Created)) { @@ -3032,6 +3032,16 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) q->setAttribute(Qt::WA_WState_Hidden); q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); +#ifdef QT_MAC_USE_COCOA + // If we add a child to the unified toolbar, we have to redirect the painting. + if (parent && parent->d_func() && parent->d_func()->isInUnifiedToolbar) { + if (parent->d_func()->unifiedSurface) { + QWidget *toolbar = parent->d_func()->toolbar_ancestor; + parent->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset); + } + } +#endif // QT_MAC_USE_COCOA + if (wasCreated) { transferChildren(); #ifndef QT_MAC_USE_COCOA @@ -3526,8 +3536,8 @@ void QWidgetPrivate::show_sys() // INVARIANT: q is native. Just show the view: [view setHidden:NO]; } else { - // INVARIANT: q is alien. Repaint q instead: - q->repaint(); + // INVARIANT: q is alien. Update q instead: + q->update(); } #endif } @@ -3683,7 +3693,7 @@ void QWidgetPrivate::hide_sys() [view setHidden:YES]; } else { // INVARIANT: q is alien. Repaint where q is placed instead: - qt_mac_repaintParentUnderAlienWidget(q); + qt_mac_updateParentUnderAlienWidget(q); } #endif } diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index ff6c24e..cd87d21 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -532,8 +532,7 @@ QString QColor::name() const void QColor::setNamedColor(const QString &name) { - if (!setColorFromString(name)) - qWarning("QColor::setNamedColor: Unknown color name '%s'", name.toLatin1().constData()); + setColorFromString(name); } /*! diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp index 62a60d7..6212674 100644 --- a/src/gui/painting/qgraphicssystemfactory.cpp +++ b/src/gui/painting/qgraphicssystemfactory.cpp @@ -74,7 +74,7 @@ QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key) if (system.isEmpty()) { system = QLatin1String("runtime"); } -#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) +#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) || (defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) if (system.isEmpty()) { system = QLatin1String("raster"); } diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 51171c5..6f6cd6f 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -1768,12 +1768,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 3fd4c5b..a965c15 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 <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> @@ -5798,19 +5798,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); @@ -5819,6 +5819,13 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs) d->extended != 0 ? qt_paintengine_supports_transformations(d->extended->type()) : qt_paintengine_supports_transformations(d->engine->type()); + + // If the matrix is not affine, the paint engine will fall back to + // drawing the glyphs as paths, which in turn means we should not + // preprocess the glyph positions + if (!d->state->matrix.isAffine()) + paintEngineSupportsTransformations = true; + for (int i=0; i<count; ++i) { QPointF processedPosition = position + glyphPositions.at(i); if (!paintEngineSupportsTransformations) @@ -5826,8 +5833,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, @@ -5862,7 +5869,7 @@ void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, in QFixed width = rightMost - leftMost; - if (extended != 0) { + if (extended != 0 && state->matrix.isAffine()) { QStaticTextItem staticTextItem; staticTextItem.color = state->pen.color(); staticTextItem.font = state->font; diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 1a432e6..601c386 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/painting/qunifiedtoolbarsurface_mac_p.h b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h index 0a7ebf1..ce07f5c 100644 --- a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h +++ b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h @@ -65,6 +65,39 @@ QT_BEGIN_NAMESPACE class QNativeImage; +// +// This is the implementation of the unified toolbar on Mac OS X +// with the graphics system raster. +// +// General idea: +// ------------- +// We redirect the painting of widgets inside the unified toolbar +// to a special window surface, the QUnifiedToolbarSurface. +// We need a separate window surface because the unified toolbar +// is out of the content view. +// The input system is the same as for the unified toolbar with the +// native (CoreGraphics) engine. +// +// Execution flow: +// --------------- +// The unified toolbar is triggered by QMainWindow::setUnifiedTitleAndToolBarOnMac(). +// It calls QMainWindowLayout::insertIntoMacToolbar() which will +// set all the appropriate variables (offsets, redirection, ...). +// When Qt tells a widget to repaint, QWidgetPrivate::drawWidget() +// checks if the widget is inside the unified toolbar and exits without +// painting is that is the case. +// We trigger the rendering of the unified toolbar in QWidget::repaint() +// and QWidget::update(). +// We keep track of flush requests via "flushRequested" variable. That +// allow flush() to be a no-op if no repaint occurred for a widget. +// We rely on the needsDisplay: and drawRect: mecanism for drawing our +// content into the graphics context. +// +// Notes: +// ------ +// The painting of items inside the unified toolbar is expensive. +// Too many repaints will drastically slow down the whole application. +// class QUnifiedToolbarSurfacePrivate { diff --git a/src/gui/text/qfont_mac.cpp b/src/gui/text/qfont_mac.cpp index daf68c0..044fd84 100644 --- a/src/gui/text/qfont_mac.cpp +++ b/src/gui/text/qfont_mac.cpp @@ -43,6 +43,7 @@ #include "qfont_p.h" #include "qfontengine_p.h" #include "qfontengine_mac_p.h" +#include "qfontengine_coretext_p.h" #include "qfontinfo.h" #include "qfontmetrics.h" #include "qpaintdevice.h" @@ -119,10 +120,10 @@ quint32 QFont::macFontID() const // ### need 64-bit version // Returns an ATSUFonFamilyRef Qt::HANDLE QFont::handle() const { -#if 0 +#ifdef QT_MAC_USE_COCOA QFontEngine *fe = d->engineForScript(QUnicodeTables::Common); - if (fe && fe->type() == QFontEngine::Mac) - return (Qt::HANDLE)static_cast<QFontEngineMacMulti*>(fe)->fontFamilyRef(); + if (fe && fe->type() == QFontEngine::Multi) + return (Qt::HANDLE)static_cast<QCoreTextFontEngineMulti*>(fe)->macFontID(); #endif return 0; } diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index d4df218..cbf51e6 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -871,7 +871,7 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const newFontDef.pixelSize = pixelSize; newFontDef.pointSize = pixelSize * 72.0 / qt_defaultDpi(); - return new QCoreTextFontEngine(cgFont, fontDef); + return new QCoreTextFontEngine(cgFont, newFontDef); } QT_END_NAMESPACE diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h index bb80a9b..3775bc6 100644 --- a/src/gui/text/qfontengine_coretext_p.h +++ b/src/gui/text/qfontengine_coretext_p.h @@ -124,6 +124,8 @@ public: QScriptItem *si) const; virtual const char *name() const { return "CoreText"; } + inline CTFontRef macFontID() const { return ctfont; } + protected: virtual void loadEngine(int at); diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 237cde4..4dae2a3 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1597,7 +1597,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlag FT_Face face = 0; bool design = (default_hint_style == HintNone || default_hint_style == HintLight || - (flags & HB_ShaperFlag_UseDesignMetrics)); + (flags & HB_ShaperFlag_UseDesignMetrics)) && FT_IS_SCALABLE(freetype->face); for (int i = 0; i < glyphs->numGlyphs; i++) { Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]); if (g) { diff --git a/src/gui/text/qglyphs.cpp b/src/gui/text/qglyphrun.cpp index cfea6ec..ea52788 100644 --- a/src/gui/text/qglyphs.cpp +++ b/src/gui/text/qglyphrun.cpp @@ -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; diff --git a/src/gui/text/qglyphs.h b/src/gui/text/qglyphrun.h index 4d7dcaf..dcc166e 100644 --- a/src/gui/text/qglyphs.h +++ b/src/gui/text/qglyphrun.h @@ -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 diff --git a/src/gui/text/qglyphs_p.h b/src/gui/text/qglyphrun_p.h index 944f777..4aa01d6 100644 --- a/src/gui/text/qglyphs_p.h +++ b/src/gui/text/qglyphrun_p.h @@ -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; diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 46c892c..44ddfd2 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(), glyphIndexesForChars(), QGlyphRun, QTextLayout::glyphRuns(), QTextFragment::glyphRuns() */ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const { @@ -437,11 +437,9 @@ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const int nglyphs = text.size(); QVarLengthGlyphLayoutArray glyphs(nglyphs); - if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &nglyphs, - QTextEngine::GlyphIndicesOnly)) { + if (!glyphIndexesForChars(text.data(), text.size(), glyphs.glyphs, &nglyphs)) { glyphs.resize(nglyphs); - if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &nglyphs, - QTextEngine::GlyphIndicesOnly)) { + if (!glyphIndexesForChars(text.data(), text.size(), glyphs.glyphs, &nglyphs)) { Q_ASSERT_X(false, Q_FUNC_INFO, "stringToCMap shouldn't fail twice"); return QVector<quint32>(); } @@ -455,6 +453,26 @@ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const } /*! + Converts a string of unicode points to glyph indexes using the CMAP table in the + underlying font. The function works like glyphIndexesForString() except it take + an array (\a chars), the results will be returned though \a glyphIndexes array + and number of glyphs will be set in \a numGlyphs. The size of \a glyphIndexes array + must be at least \a numChars, if that's still not enough, this function will return + false, then you can resize \a glyphIndexes from the size returned in \a numGlyphs. + + \sa glyphIndexesForString(), advancesForGlyphIndexes(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs() +*/ +bool QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const +{ + if (!isValid()) + return false; + + QGlyphLayout glyphs; + glyphs.glyphs = glyphIndexes; + return d->fontEngine->stringToCMap(chars, numChars, &glyphs, numGlyphs, QTextEngine::GlyphIndicesOnly); +} + +/*! Returns the QRawFont's advances for each of the \a glyphIndexes in pixel units. The advances give the distance from the position of a given glyph to where the next glyph should be drawn to make it appear as if the two glyphs are unspaced. @@ -480,6 +498,36 @@ QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyph } /*! + Returns the QRawFont's advances for each of the \a glyphIndexes in pixel units. The advances + give the distance from the position of a given glyph to where the next glyph should be drawn + to make it appear as if the two glyphs are unspaced. The glyph indexes are given with the + array \a glyphIndexes while the results are returned through \a advances, both of them must + have \a numGlyphs elements. + + \sa QTextLine::horizontalAdvance(), QFontMetricsF::width() +*/ +bool QRawFont::advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const +{ + if (!isValid()) + return false; + + QGlyphLayout glyphs; + glyphs.glyphs = const_cast<HB_Glyph *>(glyphIndexes); + glyphs.numGlyphs = numGlyphs; + QVarLengthArray<QFixed> advances_x(numGlyphs); + QVarLengthArray<QFixed> advances_y(numGlyphs); + glyphs.advances_x = advances_x.data(); + glyphs.advances_y = advances_y.data(); + + d->fontEngine->recalcAdvances(&glyphs, 0); + + for (int i=0; i<numGlyphs; ++i) + advances[i] = QPointF(glyphs.advances_x[i].toReal(), glyphs.advances_y[i].toReal()); + + return true; +} + +/*! Returns the hinting preference used to construct this QRawFont. \sa QFont::hintingPreference() @@ -587,17 +635,17 @@ 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); - QRawFont rawfont = glyphs.font(); + QGlyphRun glyphs = list.at(i); + QRawFont rawfont = glyphs.rawFont(); if (rawfont.familyName() == font.family()) return rawfont; } - return list.at(0).font(); + return list.at(0).rawFont(); } return QRawFont(); #else diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index 900c07a..3875fec 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -90,6 +90,8 @@ public: QVector<quint32> glyphIndexesForString(const QString &text) const; QVector<QPointF> advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes) const; + bool glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const; + bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const; QImage alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialiasingType = SubPixelAntialiasing, diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 4f6857a..17bcc6c 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -362,7 +362,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor currentCharFormat = -1; bool adjustX = true; QTextBlock blockIt = block(); - bool visualMovement = priv->defaultCursorMoveStyle == QTextCursor::Visual; + bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle; if (!blockIt.isValid()) return false; @@ -2568,18 +2568,18 @@ QTextDocument *QTextCursor::document() const } /*! - \enum QTextCursor::MoveStyle + \enum Qt::CursorMoveStyle - This enum describes the movement style available to QTextCursor. The options + This enum describes the movement style available to text cursors. The options are: - \value Logical Within a left-to-right text block, increase cursor position - when pressing left arrow key, decrease cursor position when pressing the - right arrow key. If the text block is right-to-left, the opposite behavior + \value LogicalMoveStyle Within a left-to-right text block, decrease cursor + position when pressing left arrow key, increase cursor position when pressing + the right arrow key. If the text block is right-to-left, the opposite behavior applies. - \value Visual Pressing the left arrow key will always cause the cursor to move - left, regardless of the text's writing direction. The same behavior applies to - right arrow key. + \value VisualMoveStyle Pressing the left arrow key will always cause the cursor + to move left, regardless of the text's writing direction. Pressing the right + arrow key will always cause the cursor to move right. */ QT_END_NAMESPACE diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index 9e4c0b8..4eaeb41 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -86,10 +86,6 @@ public: MoveAnchor, KeepAnchor }; - enum MoveStyle { - Logical, - Visual - }; void setPosition(int pos, MoveMode mode = MoveAnchor); int position() const; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 36f3c6c..0d33912 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -589,9 +589,9 @@ void QTextDocument::setDefaultTextOption(const QTextOption &option) \since 4.8 The default cursor movement style is used by all QTextCursor objects - created from the document. The default is QTextCursor::Logical. + created from the document. The default is Qt::LogicalMoveStyle. */ -QTextCursor::MoveStyle QTextDocument::defaultCursorMoveStyle() const +Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const { Q_D(const QTextDocument); return d->defaultCursorMoveStyle; @@ -602,7 +602,7 @@ QTextCursor::MoveStyle QTextDocument::defaultCursorMoveStyle() const Set the default cursor movement style. */ -void QTextDocument::setDefaultCursorMoveStyle(QTextCursor::MoveStyle style) +void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style) { Q_D(QTextDocument); d->defaultCursorMoveStyle = style; @@ -2099,6 +2099,10 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode) html += QLatin1String(" font-size:"); html += QString::number(defaultCharFormat.fontPointSize()); html += QLatin1String("pt;"); + } else if (defaultCharFormat.hasProperty(QTextFormat::FontPixelSize)) { + html += QLatin1String(" font-size:"); + html += QString::number(defaultCharFormat.intProperty(QTextFormat::FontPixelSize)); + html += QLatin1String("px;"); } html += QLatin1String(" font-weight:"); @@ -2179,6 +2183,10 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) html += QLatin1Char(';'); attributesEmitted = true; } + } else if (format.hasProperty(QTextFormat::FontPixelSize)) { + html += QLatin1String(" font-size:"); + html += QString::number(format.intProperty(QTextFormat::FontPixelSize)); + html += QLatin1String("px;"); } if (format.hasProperty(QTextFormat::FontWeight) diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index e515b36..b826dc1 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -46,7 +46,6 @@ #include <QtCore/qsize.h> #include <QtCore/qrect.h> #include <QtGui/qfont.h> -#include <QtGui/qtextcursor.h> QT_BEGIN_HEADER @@ -70,6 +69,7 @@ class QUrl; class QVariant; class QRectF; class QTextOption; +class QTextCursor; template<typename T> class QVector; @@ -269,8 +269,8 @@ public: QTextOption defaultTextOption() const; void setDefaultTextOption(const QTextOption &option); - QTextCursor::MoveStyle defaultCursorMoveStyle() const; - void setDefaultCursorMoveStyle(QTextCursor::MoveStyle style); + Qt::CursorMoveStyle defaultCursorMoveStyle() const; + void setDefaultCursorMoveStyle(Qt::CursorMoveStyle style); Q_SIGNALS: void contentsChange(int from, int charsRemoves, int charsAdded); diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 779b1ff..640f7aa 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -209,7 +209,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() defaultTextOption.setTabStop(80); // same as in qtextengine.cpp defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); - defaultCursorMoveStyle = QTextCursor::Logical; + defaultCursorMoveStyle = Qt::LogicalMoveStyle; indentWidth = 40; documentMargin = 4; diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index 6563920..e72d676 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -342,7 +342,7 @@ private: public: QTextOption defaultTextOption; - QTextCursor::MoveStyle defaultCursorMoveStyle; + Qt::CursorMoveStyle defaultCursorMoveStyle; #ifndef QT_NO_CSSPARSER QCss::StyleSheet parsedDefaultStyleSheet; #endif diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index c476485..e06ca1c 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -598,7 +598,7 @@ public: inline bool visualCursorMovement() const { return (visualMovement || - (block.docHandle() ? block.docHandle()->defaultCursorMoveStyle == QTextCursor::Visual : false)); + (block.docHandle() ? block.docHandle()->defaultCursorMoveStyle == Qt::VisualMoveStyle : false)); } struct SpecialData { diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 01748b9..07aeb72 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 <limits.h> @@ -579,27 +579,27 @@ bool QTextLayout::cacheEnabled() const } /*! - Set the visual cursor movement style. If the QTextLayout is backed by + Set the cursor movement style. If the QTextLayout is backed by a document, you can ignore this and use the option in QTextDocument, this option is for widgets like QLineEdit or custom widgets without - a QTextDocument. Default value is QTextCursor::Logical. + a QTextDocument. Default value is Qt::LogicalMoveStyle. \sa setCursorMoveStyle() */ -void QTextLayout::setCursorMoveStyle(QTextCursor::MoveStyle style) +void QTextLayout::setCursorMoveStyle(Qt::CursorMoveStyle style) { - d->visualMovement = style == QTextCursor::Visual ? true : false; + d->visualMovement = style == Qt::VisualMoveStyle ? true : false; } /*! The cursor movement style of this QTextLayout. The default is - QTextCursor::Logical. + Qt::LogicalMoveStyle. \sa setCursorMoveStyle() */ -QTextCursor::MoveStyle QTextLayout::cursorMoveStyle() const +Qt::CursorMoveStyle QTextLayout::cursorMoveStyle() const { - return d->visualMovement ? QTextCursor::Visual : QTextCursor::Logical; + return d->visualMovement ? Qt::VisualMoveStyle : Qt::LogicalMoveStyle; } /*! @@ -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); @@ -2093,15 +2093,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; @@ -2166,7 +2166,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) { @@ -2223,14 +2223,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)) diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index 6aa81f9..89fbfb2 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -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 @@ -137,8 +137,8 @@ public: void setCacheEnabled(bool enable); bool cacheEnabled() const; - void setCursorMoveStyle(QTextCursor::MoveStyle style); - QTextCursor::MoveStyle cursorMoveStyle() const; + void setCursorMoveStyle(Qt::CursorMoveStyle style); + Qt::CursorMoveStyle cursorMoveStyle() const; void beginLayout(); void endLayout(); @@ -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; diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 5c1c8b9..8dabcc7 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<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); diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h index ad8e657..1588349 100644 --- a/src/gui/text/qtextobject.h +++ b/src/gui/text/qtextobject.h @@ -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: diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index e5d57d0..b6cdc52 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 += \ diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 4fb0f0c..2a15555 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -1593,7 +1593,7 @@ void QLineControl::processKeyEvent(QKeyEvent* event) } bool unknown = false; - bool visual = cursorMoveStyle() == QTextCursor::Visual; + bool visual = cursorMoveStyle() == Qt::VisualMoveStyle; if (false) { } diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 0655276..9764ba9 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -160,8 +160,8 @@ public: int cursorWidth() const { return m_cursorWidth; } void setCursorWidth(int value) { m_cursorWidth = value; } - QTextCursor::MoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); } - void setCursorMoveStyle(QTextCursor::MoveStyle style) { m_textLayout.setCursorMoveStyle(style); } + Qt::CursorMoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); } + void setCursorMoveStyle(Qt::CursorMoveStyle style) { m_textLayout.setCursorMoveStyle(style); } void moveCursor(int pos, bool mark = false); void cursorForward(bool mark, int steps) @@ -169,11 +169,11 @@ public: int c = m_cursor; if (steps > 0) { while (steps--) - c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.rightCursorPosition(c) + c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c) : m_textLayout.nextCursorPosition(c); } else if (steps < 0) { while (steps++) - c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.leftCursorPosition(c) + c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c) : m_textLayout.previousCursorPosition(c); } moveCursor(c, mark); diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 43c3f52..3c9874e 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1116,24 +1116,24 @@ void QLineEdit::setDragEnabled(bool b) \brief the movement style of cursor in this line edit \since 4.8 - When this property is set to QTextCursor::Visual, the line edit will use visual + When this property is set to Qt::VisualMoveStyle, the line edit will use visual movement style. Pressing the left arrow key will always cause the cursor to move left, regardless of the text's writing direction. The same behavior applies to right arrow key. - When the property is QTextCursor::Logical (the default), within a LTR text block, + When the property is Qt::LogicalMoveStyle (the default), within a LTR text block, increase cursor position when pressing left arrow key, decrease cursor position when pressing the right arrow key. If the text block is right to left, the opposite behavior applies. */ -QTextCursor::MoveStyle QLineEdit::cursorMoveStyle() const +Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const { Q_D(const QLineEdit); return d->control->cursorMoveStyle(); } -void QLineEdit::setCursorMoveStyle(QTextCursor::MoveStyle style) +void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style) { Q_D(QLineEdit); d->control->setCursorMoveStyle(style); diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index 73a736c..e88273f 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -85,6 +85,7 @@ class Q_GUI_EXPORT QLineEdit : public QWidget Q_PROPERTY(bool redoAvailable READ isRedoAvailable) Q_PROPERTY(bool acceptableInput READ hasAcceptableInput) Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText) + Q_PROPERTY(Qt::CursorMoveStyle cursorMoveStyle READ cursorMoveStyle WRITE setCursorMoveStyle) public: explicit QLineEdit(QWidget* parent=0); @@ -159,8 +160,8 @@ public: void setDragEnabled(bool b); bool dragEnabled() const; - void setCursorMoveStyle(QTextCursor::MoveStyle style); - QTextCursor::MoveStyle cursorMoveStyle() const; + void setCursorMoveStyle(Qt::CursorMoveStyle style); + Qt::CursorMoveStyle cursorMoveStyle() const; QString inputMask() const; void setInputMask(const QString &inputMask); diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp index be8219a..9137e0f 100644 --- a/src/opengl/qglfunctions.cpp +++ b/src/opengl/qglfunctions.cpp @@ -211,19 +211,24 @@ QGLFunctions::QGLFunctions(const QGLContext *context) static int qt_gl_resolve_features() { #if defined(QT_OPENGL_ES_2) - return QGLFunctions::Multitexture | - QGLFunctions::Shaders | - QGLFunctions::Buffers | - QGLFunctions::Framebuffers | - QGLFunctions::BlendColor | - QGLFunctions::BlendEquation | - QGLFunctions::BlendEquationSeparate | - QGLFunctions::BlendFuncSeparate | - QGLFunctions::BlendSubtract | - QGLFunctions::CompressedTextures | - QGLFunctions::Multisample | - QGLFunctions::StencilSeparate | - QGLFunctions::NPOTTextures; + int features = QGLFunctions::Multitexture | + QGLFunctions::Shaders | + QGLFunctions::Buffers | + QGLFunctions::Framebuffers | + QGLFunctions::BlendColor | + QGLFunctions::BlendEquation | + QGLFunctions::BlendEquationSeparate | + QGLFunctions::BlendFuncSeparate | + QGLFunctions::BlendSubtract | + QGLFunctions::CompressedTextures | + QGLFunctions::Multisample | + QGLFunctions::StencilSeparate; + QGLExtensionMatcher extensions; + if (extensions.match("GL_OES_texture_npot")) + features |= QGLFunctions::NPOTTextures; + if (extensions.match("GL_IMG_texture_npot")) + features |= QGLFunctions::NPOTTextures; + return features; #elif defined(QT_OPENGL_ES) int features = QGLFunctions::Multitexture | QGLFunctions::Buffers | @@ -240,6 +245,8 @@ static int qt_gl_resolve_features() features |= QGLFunctions::BlendSubtract; if (extensions.match("GL_OES_texture_npot")) features |= QGLFunctions::NPOTTextures; + if (extensions.match("GL_IMG_texture_npot")) + features |= QGLFunctions::NPOTTextures; return features; #else int features = 0; diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro index 0014b08..17f56f2 100644 --- a/tests/auto/gui.pro +++ b/tests/auto/gui.pro @@ -58,7 +58,7 @@ SUBDIRS=\ qfontdialog \ qfontmetrics \ qformlayout \ - qglyphs \ + qglyphrun \ qgraphicsanchorlayout \ qgraphicsanchorlayout1 \ qgraphicseffect \ diff --git a/tests/auto/qcolor/tst_qcolor.cpp b/tests/auto/qcolor/tst_qcolor.cpp index d42c26c..b02537e 100644 --- a/tests/auto/qcolor/tst_qcolor.cpp +++ b/tests/auto/qcolor/tst_qcolor.cpp @@ -1506,7 +1506,6 @@ void tst_QColor::setallowX11ColorNames() for (int i = 0; i < x11RgbTblSize; ++i) { QString colorName = QLatin1String(x11RgbTbl[i].name); QColor color; - QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1()); color.setNamedColor(colorName); QVERIFY(!color.isValid()); } @@ -1528,7 +1527,6 @@ void tst_QColor::setallowX11ColorNames() for (int i = 0; i < x11RgbTblSize; ++i) { QString colorName = QLatin1String(x11RgbTbl[i].name); QColor color; - QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1()); color.setNamedColor(colorName); QVERIFY(!color.isValid()); } diff --git a/tests/auto/qcomplextext/tst_qcomplextext.cpp b/tests/auto/qcomplextext/tst_qcomplextext.cpp index 58b31b4..ae63bac 100644 --- a/tests/auto/qcomplextext/tst_qcomplextext.cpp +++ b/tests/auto/qcomplextext/tst_qcomplextext.cpp @@ -214,7 +214,7 @@ void tst_QComplexText::bidiCursorMovement() QTextOption option = layout.textOption(); option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft); layout.setTextOption(option); - layout.setCursorMoveStyle(QTextCursor::Visual); + layout.setCursorMoveStyle(Qt::VisualMoveStyle); bool moved; int oldPos, newPos = 0; qreal x, newX; diff --git a/tests/auto/qglyphs/qglyphs.pro b/tests/auto/qglyphrun/qglyphrun.pro index 5084cf9..480ad5b 100644 --- a/tests/auto/qglyphs/qglyphs.pro +++ b/tests/auto/qglyphrun/qglyphrun.pro @@ -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/\\\" -}
\ No newline at end of file +} diff --git a/tests/auto/qglyphs/test.ttf b/tests/auto/qglyphrun/test.ttf Binary files differindex 9043a57..9043a57 100644 --- a/tests/auto/qglyphs/test.ttf +++ b/tests/auto/qglyphrun/test.ttf diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphrun/tst_qglyphrun.cpp index ffa0d00..aefc228 100644 --- a/tests/auto/qglyphs/tst_qglyphs.cpp +++ b/tests/auto/qglyphrun/tst_qglyphrun.cpp @@ -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" diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index f45481c..d5d9029 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -3815,7 +3815,7 @@ void tst_QLineEdit::bidiVisualMovement() QLineEdit le; le.setText(logical); - le.setCursorMoveStyle(QTextCursor::Visual); + le.setCursorMoveStyle(Qt::VisualMoveStyle); le.setCursorPosition(0); bool moved; @@ -3863,7 +3863,7 @@ void tst_QLineEdit::bidiLogicalMovement() QLineEdit le; le.setText(logical); - le.setCursorMoveStyle(QTextCursor::Logical); + le.setCursorMoveStyle(Qt::LogicalMoveStyle); le.setCursorPosition(0); bool moved; diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp index 4b42c74..8c58407 100644 --- a/tests/auto/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/qrawfont/tst_qrawfont.cpp @@ -91,6 +91,9 @@ private slots: void unsupportedWritingSystem_data(); void unsupportedWritingSystem(); + + void rawFontSetPixelSize_data(); + void rawFontSetPixelSize(); #endif // QT_NO_RAWFONT }; @@ -293,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); @@ -792,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); @@ -807,6 +810,39 @@ void tst_QRawFont::unsupportedWritingSystem() fontDatabase.removeApplicationFont(id); } +void tst_QRawFont::rawFontSetPixelSize_data() +{ + QTest::addColumn<QFont::HintingPreference>("hintingPreference"); + + QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting; + QTest::newRow("No hinting preference") << QFont::PreferNoHinting; + QTest::newRow("Vertical hinting preference") << QFont::PreferVerticalHinting; + QTest::newRow("Full hinting preference") << QFont::PreferFullHinting; +} + +void tst_QRawFont::rawFontSetPixelSize() +{ + QFETCH(QFont::HintingPreference, hintingPreference); + + QTextLayout layout("Foobar"); + + QFont font = layout.font(); + font.setHintingPreference(hintingPreference); + font.setPixelSize(12); + layout.setFont(font); + + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QGlyphRun glyphs = layout.glyphRuns().at(0); + QRawFont rawFont = glyphs.rawFont(); + QCOMPARE(rawFont.pixelSize(), 12.0); + + rawFont.setPixelSize(24); + QCOMPARE(rawFont.pixelSize(), 24.0); +} + #endif // QT_NO_RAWFONT QTEST_MAIN(tst_QRawFont) diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 6675c99..7aa6578 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -180,6 +180,8 @@ private slots: void escape_data(); void escape(); + void copiedFontSize(); + private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); @@ -2734,5 +2736,29 @@ void tst_QTextDocument::escape() QCOMPARE(Qt::escape(original), expected); } +void tst_QTextDocument::copiedFontSize() +{ + QTextDocument documentInput; + QTextDocument documentOutput; + + QFont fontInput; + fontInput.setPixelSize(24); + + QTextCursor cursorInput(&documentInput); + QTextCharFormat formatInput = cursorInput.charFormat(); + formatInput.setFont(fontInput); + cursorInput.insertText("Should be the same font", formatInput); + cursorInput.select(QTextCursor::Document); + + QTextDocumentFragment fragmentInput(cursorInput); + QString html = fragmentInput.toHtml(); + + QTextCursor cursorOutput(&documentOutput); + QTextDocumentFragment fragmentOutput = QTextDocumentFragment::fromHtml(html); + cursorOutput.insertFragment(fragmentOutput); + + QCOMPARE(cursorOutput.charFormat().font().pixelSize(), 24); +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index 5a64593..992d2f2 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -2292,7 +2292,7 @@ void tst_QTextEdit::bidiVisualMovement() option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft); ed->document()->setDefaultTextOption(option); - ed->document()->setDefaultCursorMoveStyle(QTextCursor::Visual); + ed->document()->setDefaultCursorMoveStyle(Qt::VisualMoveStyle); ed->moveCursor(QTextCursor::Start); ed->show(); @@ -2346,7 +2346,7 @@ void tst_QTextEdit::bidiLogicalMovement() option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft); ed->document()->setDefaultTextOption(option); - ed->document()->setDefaultCursorMoveStyle(QTextCursor::Logical); + ed->document()->setDefaultCursorMoveStyle(Qt::LogicalMoveStyle); ed->moveCursor(QTextCursor::Start); ed->show(); diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 6ebe84e..3e65d7e 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -2650,7 +2650,6 @@ void tst_QVariant::invalidAsByteArray() void tst_QVariant::invalidQColor() const { QVariant va("An invalid QColor::name() value."); - QTest::ignoreMessage(QtWarningMsg, "QColor::setNamedColor: Unknown color name 'An invalid QColor::name() value.'"); QVERIFY(va.canConvert(QVariant::Color)); QVERIFY(!va.convert(QVariant::Color)); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 35014c9..e266efb 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -4738,7 +4738,8 @@ void tst_QWidget::update() QCOMPARE(w.visibleRegion(), expectedVisible); QCOMPARE(w.paintedRegion, expectedVisible); #ifdef QT_MAC_USE_COCOA - QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue); + if (QApplicationPrivate::graphics_system_name != QLatin1String("raster")) + QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue); #endif QCOMPARE(child.numPaintEvents, 0); @@ -6336,11 +6337,15 @@ void tst_QWidget::compatibilityChildInsertedEvents() expected = EventRecorder::EventList() << qMakePair(&widget, QEvent::PolishRequest) - << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA) - << qMakePair(&widget, QEvent::UpdateRequest) -#endif - ; + << qMakePair(&widget, QEvent::Type(QEvent::User + 1)); + +#ifndef QT_MAC_USE_CARBON +#ifdef QT_MAC_USE_COCOA + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) +#endif // QT_MAC_USE_COCOA + expected << qMakePair(&widget, QEvent::UpdateRequest); +#endif // !QT_MAC_USE_CARBON + QCOMPARE(spy.eventList(), expected); } @@ -6432,11 +6437,15 @@ void tst_QWidget::compatibilityChildInsertedEvents() #endif << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) - << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA) - << qMakePair(&widget, QEvent::UpdateRequest) -#endif - ; + << qMakePair(&widget, QEvent::Type(QEvent::User + 2)); + +#ifndef QT_MAC_USE_CARBON +#ifdef QT_MAC_USE_COCOA + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) +#endif // QT_MAC_USE_COCOA + expected << qMakePair(&widget, QEvent::UpdateRequest); +#endif // !QT_MAC_USE_CARBON + QCOMPARE(spy.eventList(), expected); } @@ -6528,11 +6537,15 @@ void tst_QWidget::compatibilityChildInsertedEvents() #endif << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) - << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA) - << qMakePair(&widget, QEvent::UpdateRequest) -#endif - ; + << qMakePair(&widget, QEvent::Type(QEvent::User + 2)); + +#ifndef QT_MAC_USE_CARBON +#ifdef QT_MAC_USE_COCOA + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) +#endif // QT_MAC_USE_COCOA + expected << qMakePair(&widget, QEvent::UpdateRequest); +#endif // !QT_MAC_USE_CARBON + QCOMPARE(spy.eventList(), expected); } } |