summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-10-24 12:48:39 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-10-24 12:48:42 +0200
commit840f6a40e6218992b5b9d451ee3c0886a4846c89 (patch)
tree2b808decc7adf5218b810d2de6b45c5a8b4cfc42 /src/gui/text
parent109bf980b37fed405c6c1eb14cb9c83ff897e389 (diff)
parent2e3870fe37d36ccf4bd84eb90e1d5e08ad00c1bc (diff)
Merge remote-tracking branch 'origin/stable' into dev
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontdatabase.h2
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp6
-rw-r--r--src/gui/text/qfontengine.cpp10
-rw-r--r--src/gui/text/qfontengine_p.h1
-rw-r--r--src/gui/text/qtextdocument.cpp23
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp13
-rw-r--r--src/gui/text/qtextengine.cpp3
-rw-r--r--src/gui/text/qtexthtmlparser.cpp4
-rw-r--r--src/gui/text/qtextlayout.cpp23
9 files changed, 61 insertions, 24 deletions
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index 4e8f718962..708b8cbd58 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -151,7 +151,7 @@ public:
static bool removeAllApplicationFonts();
#if QT_DEPRECATED_SINCE(5, 2)
- QT_DEPRECATED static inline bool supportsThreadedFontRendering() { return true; }
+ QT_DEPRECATED static bool supportsThreadedFontRendering();
#endif
static QFont systemFont(SystemFont type);
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index 7f5281131e..6c0be950dc 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -267,6 +267,12 @@ bool QFontDatabase::removeAllApplicationFonts()
return true;
}
+// QT_DEPRECATED_SINCE(5, 2)
+bool QFontDatabase::supportsThreadedFontRendering()
+{
+ return true;
+}
+
/*!
\internal
*/
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index b3889a02a4..303c85ce75 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -891,6 +891,16 @@ QByteArray QFontEngine::getSfntTable(uint tag) const
return table;
}
+void QFontEngine::clearGlyphCache(const void *key)
+{
+ for (QLinkedList<GlyphCacheEntry>::iterator it = m_glyphCaches.begin(), end = m_glyphCaches.end(); it != end; ) {
+ if (it->context == key)
+ it = m_glyphCaches.erase(it);
+ else
+ ++it;
+ }
+}
+
void QFontEngine::setGlyphCache(const void *key, QFontEngineGlyphCache *data)
{
Q_ASSERT(data);
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index d3faef93bb..c181d61d73 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -256,6 +256,7 @@ public:
virtual int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints);
+ void clearGlyphCache(const void *key);
void setGlyphCache(const void *key, QFontEngineGlyphCache *data);
QFontEngineGlyphCache *glyphCache(const void *key, QFontEngineGlyphCache::Type type, const QTransform &transform) const;
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 03602712cc..30e0f32547 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -2531,6 +2531,29 @@ void QTextHtmlExporter::emitBlockAttributes(const QTextBlock &block)
html += QLatin1Char(';');
}
+ if (format.lineHeightType() != QTextBlockFormat::SingleHeight) {
+ switch (format.lineHeightType()) {
+ case QTextBlockFormat::ProportionalHeight:
+ case QTextBlockFormat::FixedHeight:
+ html += QLatin1String(" line-height:");
+ break;
+ case QTextBlockFormat::MinimumHeight:
+ html += QLatin1String(" min-height:");
+ break;
+ case QTextBlockFormat::LineDistanceHeight:
+ html += QLatin1String(" line-spacing:");
+ break;
+ case QTextBlockFormat::SingleHeight:
+ default:
+ break; // Should never reach here
+ }
+ html += QString::number(format.lineHeight());
+ if (format.lineHeightType() == QTextBlockFormat::ProportionalHeight)
+ html += QLatin1String("%;");
+ else
+ html += QLatin1String("px;");
+ }
+
emitPageBreakPolicy(format.pageBreakPolicy());
QTextCharFormat diff;
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 6156f56ae1..313700429c 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1427,19 +1427,6 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
xoff = -xoff - size.width();
r.translate( xoff, (fontMetrics.height() / 2) - (size.height() / 2));
- // Prevent clipping the left side of the list decorator (on left to
- // right layouts) and clipping the right side of the list
- // decorator (on right to left layouts).
- if ((r.left() < 0) && (dir == Qt::LeftToRight)) {
- int horizontalOffset = -r.left();
- r.translate(horizontalOffset, 0);
- layout->setPosition(layout->position() + QPointF(horizontalOffset, 0));
- } else if ((r.right() > document->pageSize().width()) && (dir == Qt::RightToLeft)) {
- int horizontalOffset = r.right() - document->pageSize().width();
- r.translate(-horizontalOffset, 0);
- layout->setPosition(layout->position() - QPointF(horizontalOffset, 0));
- }
-
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index c0e2c5b803..2b0f9ffeb6 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1883,11 +1883,12 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
scaledEngine = feCache.prevScaledFontEngine;
} else {
QFontEngine *scEngine = rawFont.d->fontEngine->cloneWithSize(smallCapsFraction * rawFont.pixelSize());
+ scEngine->ref.ref();
scaledEngine = QFontEngineMultiQPA::createMultiFontEngine(scEngine, script);
scaledEngine->ref.ref();
feCache.prevScaledFontEngine = scaledEngine;
// If scEngine is not ref'ed by scaledEngine, make sure it is deallocated and not leaked.
- if (!scEngine->ref.load())
+ if (!scEngine->ref.deref())
delete scEngine;
}
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 5292ba20a2..a131503b85 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -46,7 +46,7 @@
#include <qstack.h>
#include <qdebug.h>
#include <qthread.h>
-#include <qcoreapplication.h>
+#include <qguiapplication.h>
#include "qtextdocument.h"
#include "qtextformat_p.h"
@@ -1066,7 +1066,7 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
&& !attributes.at(i + 1).isEmpty()) {
hasHref = true;
charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
- charFormat.setForeground(Qt::blue);
+ charFormat.setForeground(QGuiApplication::palette().link());
}
}
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index dc8ae06868..66341e186a 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -44,6 +44,7 @@
#include <qthread.h>
#include <qfont.h>
+#include <qmath.h>
#include <qpainter.h>
#include <qvarlengtharray.h>
#include <qtextformat.h>
@@ -207,7 +208,7 @@ void QTextInlineObject::setAscent(qreal a)
}
/*!
- Sets the inline object's decent to \a d.
+ Sets the inline object's descent to \a d.
\sa descent(), setAscent(), width(), rect()
*/
@@ -946,15 +947,23 @@ static void addSelectedRegionsToPath(QTextEngine *eng, int lineNumber, const QPo
continue;
}
- if (lastSelectionWidth > 0)
- region->addRect(boundingRect & QRectF(lastSelectionX.toReal(), selectionY, lastSelectionWidth.toReal(), lineHeight));
+ if (lastSelectionWidth > 0) {
+ QRectF rect = boundingRect & QRectF(lastSelectionX.toReal(), selectionY, lastSelectionWidth.toReal(), lineHeight);
+ rect.moveLeft(qFloor(rect.left()));
+ rect.moveTop(qFloor(rect.top()));
+ region->addRect(rect);
+ }
lastSelectionX = selectionX;
lastSelectionWidth = selectionWidth;
}
}
- if (lastSelectionWidth > 0)
- region->addRect(boundingRect & QRectF(lastSelectionX.toReal(), selectionY, lastSelectionWidth.toReal(), lineHeight));
+ if (lastSelectionWidth > 0) {
+ QRectF rect = boundingRect & QRectF(lastSelectionX.toReal(), selectionY, lastSelectionWidth.toReal(), lineHeight);
+ rect.moveLeft(qFloor(rect.left()));
+ rect.moveTop(qFloor(rect.top()));
+ region->addRect(rect);
+ }
}
static inline QRectF clipIfValid(const QRectF &rect, const QRectF &clip)
@@ -1288,7 +1297,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
After being created, the line can be filled using the setLineWidth()
or setNumColumns() functions. A line has a number of attributes including the
rectangle it occupies, rect(), its coordinates, x() and y(), its
- textLength(), width() and naturalTextWidth(), and its ascent() and decent()
+ textLength(), width() and naturalTextWidth(), and its ascent() and descent()
relative to the text. The position of the cursor in terms of the
line is available from cursorToX() and its inverse from
xToCursor(). A line can be moved with setPosition().
@@ -2077,7 +2086,7 @@ static void setPenAndDrawBackground(QPainter *p, const QPen &defaultPen, const Q
QBrush bg = chf.background();
if (bg.style() != Qt::NoBrush && !chf.property(SuppressBackground).toBool())
- p->fillRect(r, bg);
+ p->fillRect(QRectF(qFloor(r.x()), qFloor(r.y()), r.width(), r.height()), bg);
if (c.style() != Qt::NoBrush) {
p->setPen(QPen(c, 0));
}