15#include <private/qfixed_p.h>
17#include <QElapsedTimer>
18#include <QLoggingCategory>
27#ifndef QT_SVG_MAX_LAYOUT_SIZE
28#define QT_SVG_MAX_LAYOUT_SIZE (qint64(QFIXED_MAX / 2))
33 qWarning(
"<animation> not implemented");
51 return p->transform().mapRect(m_bounds);
57 path.addEllipse(m_bounds);
64 p->drawEllipse(m_bounds);
77 , m_filename(filename)
81 if (m_bounds.
width() == 0.0)
83 if (m_bounds.
height() == 0.0)
89 p->drawImage(m_bounds, m_image);
99 if (
p->pen().widthF() != 0) {
100 qreal oldOpacity =
p->opacity();
101 p->setOpacity(oldOpacity *
states.strokeOpacity);
103 p->setOpacity(oldOpacity);
133 return qFuzzyIsNull(sw) ?
p->transform().map(m_path).boundingRect()
151 return p->transform().map(m_poly).boundingRect();
154 path.addPolygon(m_poly);
161 p->drawPolygon(m_poly,
states.fillRule);
179 p->drawPolygon(m_poly,
states.fillRule);
181 p->drawPolyline(m_poly);
199 return p->transform().mapRect(m_rect);
206 return p->transform().mapRect(m_rect);
209 path.addRect(m_rect);
227QSvgTspan *
const QSvgText::LINEBREAK = 0;
240 for (
int i = 0;
i < m_tspans.
size(); ++
i) {
241 if (m_tspans[
i] != LINEBREAK)
258 for (
int i = 0;
i < m_tspans.
size(); ++
i) {
259 if (m_tspans.
at(
i) != LINEBREAK)
263 QRectF approxMaximumBrect(m_coord.
x(),
265 charCount * fm.averageCharWidth(),
266 -m_tspans.
size() * fm.height());
267 return p->transform().mapRect(approxMaximumBrect);
286 qreal originalFontSize =
p->font().pointSizeF();
287 qreal maxFontSize = originalFontSize;
289 if (
span == LINEBREAK)
292 numChars +=
span->text().size();
295 if (
style !=
nullptr &&
style->qfont().pointSizeF() > maxFontSize)
296 maxFontSize =
style->qfont().pointSizeF();
303 qCWarning(lcSvgDraw) <<
"Text element too high to lay out, ignoring";
308 qCWarning(lcSvgDraw) <<
"Text element too wide to lay out, ignoring";
319 qreal oldOpacity =
p->opacity();
320 p->setOpacity(oldOpacity *
states.fillOpacity);
339 px += scaledSize.
width() / 2;
341 px += scaledSize.
width();
348 bool appendSpace =
false;
349 QList<QString> paragraphs;
350 QList<QList<QTextLayout::FormatRange> > formatRanges(1);
351 paragraphs.push_back(
QString());
353 for (
int i = 0;
i < m_tspans.
size(); ++
i) {
354 if (m_tspans[
i] == LINEBREAK) {
356 if (paragraphs.back().isEmpty()) {
363 formatRanges.back().append(
range);
368 paragraphs.push_back(
QString());
369 formatRanges.resize(formatRanges.size() + 1);
382 bool prependSpace = !appendSpace && !m_tspans[
i]->isTspan() && (
mode ==
Default) && !paragraphs.
back().isEmpty() && newText.startsWith(
QLatin1Char(
' '));
383 if (appendSpace || prependSpace)
389 newText = newText.simplified();
390 if (newText.isEmpty())
391 appendSpaceNext =
false;
396 range.length = newText.size();
398 range.format.setTextOutline(
p->pen());
399 range.format.setForeground(
p->brush());
402 Q_ASSERT(!formatRanges.back().isEmpty());
403 ++formatRanges.back().back().length;
404 }
else if (prependSpace) {
408 formatRanges.back().append(
range);
410 appendSpace = appendSpaceNext;
411 paragraphs.back() += newText;
413 m_tspans[
i]->revertStyle(
p,
states);
420 for (
int i = 1;
i < paragraphs.size(); ++
i) {
427 for (
int i = 0;
i < paragraphs.size(); ++
i) {
431 tl.setTextOption(op);
432 tl.setFormats(formatRanges[
i]);
439 if (m_size.
width() != 0)
444 bool endOfBoundsReached =
false;
445 for (
int i = 0;
i < tl.lineCount(); ++
i) {
450 x -= 0.5 *
line.naturalTextWidth();
452 x -=
line.naturalTextWidth();
454 if (initial && m_type ==
Text)
459 brect |=
line.naturalTextRect();
462 if ((m_size.
width() != 0 &&
line.naturalTextWidth() > scaledSize.
width())
467 endOfBoundsReached =
true;
471 y += 1.1 *
line.height();
474 tl.draw(
p,
QPointF(px, py), QList<QTextLayout::FormatRange>(),
bounds);
476 if (endOfBoundsReached)
487 p->setWorldTransform(oldTransform,
false);
488 p->setOpacity(oldOpacity);
511 if (
states.nestedUseLevel > 3 &&
states.nestedUseCount > (256 +
states.nestedUseLevel * 2)) {
516 QScopedValueRollback<bool> inUseGuard(
states.inUse,
true);
519 p->translate(m_start);
521 if (
states.nestedUseLevel > 0)
524 QScopedValueRollback<int> useLevelGuard(
states.nestedUseLevel,
states.nestedUseLevel + 1);
525 QScopedValueRollback<bool> recursingGuard(m_recursing,
true);
528 if (
states.nestedUseLevel == 0)
529 states.nestedUseCount = 0;
532 p->translate(-m_start);
600 QScopedValueRollback<bool> guard(m_recursing,
true);
601 p->translate(m_start);
603 p->translate(-m_start);
617 return p->transform().map(m_poly).boundingRect();
620 path.addPolygon(m_poly);
627 return p->transform().mapRect(m_bounds);
\reentrant \inmodule QtGui
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
qreal pointSizeF() const
Returns the point size of the font.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
constexpr QPointF p1() const
Returns the line's start point.
constexpr QPointF p2() const
Returns the line's end point.
qsizetype size() const noexcept
bool endsWith(parameter_type t) const
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
The QPainterPathStroker class is used to generate fillable outlines for a given painter path.
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path.
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
QRectF controlPointRect() const
Returns the rectangle containing all the points and control points in this path.
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision.
The QPainter class performs low-level painting on widgets and other paint devices.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns fa...
The QPolygonF class provides a list of points using floating point precision.
QRectF Q_GUI_EXPORT boundingRect() const
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty.
\inmodule QtCore\reentrant
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr void setBottom(qreal pos) noexcept
Sets the bottom edge of the rectangle to the given finite y coordinate.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr void setWidth(qreal w) noexcept
Sets the width of the rectangle to the given finite width.
constexpr void translate(qreal dx, qreal dy) noexcept
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position.
constexpr void setHeight(qreal h) noexcept
Sets the height of the rectangle to the given finite height.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype size() const noexcept
Returns the number of characters in this string.
QString & append(QChar c)
Type type() const override
void drawCommand(QPainter *, QSvgExtraStates &) override
Type type() const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
bool separateFillStroke() const override
QSvgEllipse(QSvgNode *parent, const QRectF &rect)
void drawCommand(QPainter *p, QSvgExtraStates &states) override
Type type() const override
const QFont & qfont() const
Type type() const override
void drawCommand(QPainter *p, QSvgExtraStates &states) override
QSvgImage(QSvgNode *parent, const QImage &image, const QString &filename, const QRectF &bounds)
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
QSvgLine(QSvgNode *parent, const QLineF &line)
Type type() const override
void drawCommand(QPainter *p, QSvgExtraStates &states) override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
static void drawMarkersForNode(QSvgNode *node, QPainter *p, QSvgExtraStates &states)
static qreal strokeWidth(QPainter *p)
virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const
bool isDescendantOf(const QSvgNode *parent) const
void draw(QPainter *p, QSvgExtraStates &states)
const QSvgStyle & style() const
bool separateFillStroke() const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
void drawCommand(QPainter *p, QSvgExtraStates &states) override
Type type() const override
QSvgPath(QSvgNode *parent, const QPainterPath &qpath)
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
Type type() const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
bool separateFillStroke() const override
void drawCommand(QPainter *p, QSvgExtraStates &states) override
QSvgPolygon(QSvgNode *parent, const QPolygonF &poly)
QSvgPolyline(QSvgNode *parent, const QPolygonF &poly)
void drawCommand(QPainter *p, QSvgExtraStates &states) override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
bool separateFillStroke() const override
Type type() const override
Type type() const override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
bool separateFillStroke() const override
void drawCommand(QPainter *p, QSvgExtraStates &states) override
QSvgRect(QSvgNode *paren, const QRectF &rect, qreal rx=0, qreal ry=0)
QSvgRefCounter< QSvgFontStyle > font
bool shouldDrawNode(QPainter *p, QSvgExtraStates &states) const override
void addText(const QString &text)
void drawCommand(QPainter *p, QSvgExtraStates &states) override
QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
QSvgText(QSvgNode *parent, const QPointF &coord)
void setTextArea(const QSizeF &size)
Type type() const override
const QString & text() const
void setWhitespaceMode(QSvgText::WhitespaceMode mode)
void addText(const QString &text)
void drawCommand(QPainter *p, QSvgExtraStates &states) override
QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *link)
Type type() const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
Type type() const override
void setWrapMode(WrapMode wrap)
Sets the option's text wrap mode to the given mode.
@ WrapAtWordBoundaryOrAnywhere
Combined button and popup list for selecting options.
bool qFuzzyIsNull(qfloat16 f) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat GLfloat GLfloat maxY
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat GLfloat GLfloat maxX
GLsizei const GLchar *const * path
GLenum GLenum GLsizei void GLsizei void void * span
GLenum GLenum GLenum GLenum GLenum scale
static const QRectF boundingRect(const QPointF *points, int pointCount)
static QT_BEGIN_NAMESPACE const uint Default
#define qPrintable(string)
#define QT_SVG_MAX_LAYOUT_SIZE
static QRectF boundsOnStroke(QPainter *p, const QPainterPath &path, qreal width)
\inmodule QtCore \reentrant