summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qdistancefield.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qdistancefield.cpp')
-rw-r--r--src/gui/text/qdistancefield.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp
index 013f40fed6..5a449ebf90 100644
--- a/src/gui/text/qdistancefield.cpp
+++ b/src/gui/text/qdistancefield.cpp
@@ -11,7 +11,7 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
-Q_LOGGING_CATEGORY(lcDistanceField, "qt.distanceField");
+Q_STATIC_LOGGING_CATEGORY(lcDistanceField, "qt.distanceField");
namespace
{
@@ -530,14 +530,14 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path
|| (to.y() < offs << 8) || (to.y() >= (imgHeight - offs) << 8));
}
- isConvex.resize(normals.count());
- for (int next = 0, prev = normals.count() - 1; next < normals.count(); prev = next++) {
+ isConvex.resize(normals.size());
+ for (int next = 0, prev = normals.size() - 1; next < normals.size(); prev = next++) {
isConvex[prev] = normals.at(prev).x() * normals.at(next).y()
- normals.at(prev).y() * normals.at(next).x() < 0;
}
// Draw quads.
- for (int next = 0, prev = normals.count() - 1; next < normals.count(); prev = next++) {
+ for (int next = 0, prev = normals.size() - 1; next < normals.size(); prev = next++) {
QPoint n = normals.at(next);
QPoint intPrev = vertices.at(prev);
QPoint extPrev = vertices.at(prev);
@@ -839,14 +839,9 @@ QDistanceFieldData *QDistanceFieldData::create(const QSize &size)
return data;
}
-QDistanceFieldData *QDistanceFieldData::create(const QPainterPath &path, bool doubleResolution)
+QDistanceFieldData *QDistanceFieldData::create(QSize size, const QPainterPath &path, bool doubleResolution)
{
- int dfMargin = QT_DISTANCEFIELD_RADIUS(doubleResolution) / QT_DISTANCEFIELD_SCALE(doubleResolution);
- int glyphWidth = qCeil(path.boundingRect().width() / QT_DISTANCEFIELD_SCALE(doubleResolution)) + dfMargin * 2;
- int glyphHeight = qCeil(path.boundingRect().height() / QT_DISTANCEFIELD_SCALE(doubleResolution)) + dfMargin * 2;
-
- QDistanceFieldData *data = create(QSize(glyphWidth, glyphHeight));
-
+ QDistanceFieldData *data = create(size);
makeDistanceField(data,
path,
QT_DISTANCEFIELD_SCALE(doubleResolution),
@@ -855,6 +850,16 @@ QDistanceFieldData *QDistanceFieldData::create(const QPainterPath &path, bool do
}
+QDistanceFieldData *QDistanceFieldData::create(const QPainterPath &path, bool doubleResolution)
+{
+ int dfMargin = QT_DISTANCEFIELD_RADIUS(doubleResolution) / QT_DISTANCEFIELD_SCALE(doubleResolution);
+ int glyphWidth = qCeil(path.boundingRect().width() / QT_DISTANCEFIELD_SCALE(doubleResolution)) + dfMargin * 2;
+ int glyphHeight = qCeil(path.boundingRect().height() / QT_DISTANCEFIELD_SCALE(doubleResolution)) + dfMargin * 2;
+
+ return create(QSize(glyphWidth, glyphHeight), path, doubleResolution);
+}
+
+
QDistanceField::QDistanceField()
: d(new QDistanceFieldData)
{
@@ -875,6 +880,16 @@ QDistanceField::QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doub
setGlyph(fontEngine, glyph, doubleResolution);
}
+QDistanceField::QDistanceField(QSize size, const QPainterPath &path, glyph_t glyph, bool doubleResolution)
+{
+ QPainterPath dfPath = path;
+ dfPath.translate(-dfPath.boundingRect().topLeft());
+ dfPath.setFillRule(Qt::WindingFill);
+
+ d = QDistanceFieldData::create(size, dfPath, doubleResolution);
+ d->glyph = glyph;
+}
+
QDistanceField::QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution)
{
QPainterPath dfPath = path;
@@ -1058,7 +1073,7 @@ QImage QDistanceField::toImage(QImage::Format format) const
}
if (image.format() != format)
- image = image.convertToFormat(format);
+ image = std::move(image).convertToFormat(format);
}
return image;