summaryrefslogtreecommitdiffstats
path: root/src/svg/qsvgstyle_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/svg/qsvgstyle_p.h')
-rw-r--r--src/svg/qsvgstyle_p.h80
1 files changed, 64 insertions, 16 deletions
diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h
index 70ecf5b..bd28bb6 100644
--- a/src/svg/qsvgstyle_p.h
+++ b/src/svg/qsvgstyle_p.h
@@ -141,7 +141,11 @@ private:
struct QSvgExtraStates
{
QSvgExtraStates();
+
qreal fillOpacity;
+ QSvgFont *svgFont;
+ Qt::Alignment textAnchor;
+ int fontWeight;
};
class QSvgStyleProperty : public QSvgRefCounted
@@ -307,41 +311,85 @@ private:
class QSvgFontStyle : public QSvgStyleProperty
{
public:
+ static const int LIGHTER = -1;
+ static const int BOLDER = 1;
+
QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc);
- QSvgFontStyle(const QFont &font, QSvgTinyDocument *doc);
+ QSvgFontStyle();
virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- void setPointSize(qreal size);
- qreal pointSize() const;
+ void setSize(qreal size)
+ {
+ // Store the _pixel_ size in the font. Since QFont::setPixelSize() only takes an int, call
+ // QFont::SetPointSize() instead. Set proper font size just before rendering.
+ m_qfont.setPointSize(size);
+ m_sizeSet = 1;
+ }
- //### hack to avoid having a separate style element for text-anchor
- QString textAnchor() const;
- void setTextAnchor(const QString &anchor);
+ void setTextAnchor(Qt::Alignment anchor)
+ {
+ m_textAnchor = anchor;
+ m_textAnchorSet = 1;
+ }
- QSvgFont * svgFont() const
+ void setFamily(const QString &family)
{
- return m_font;
+ m_qfont.setFamily(family);
+ m_familySet = 1;
+ }
+
+ void setStyle(QFont::Style fontStyle) {
+ m_qfont.setStyle(fontStyle);
+ m_styleSet = 1;
}
- QSvgTinyDocument *doc() const
+
+ void setVariant(QFont::Capitalization fontVariant)
{
- return m_doc;
+ m_qfont.setCapitalization(fontVariant);
+ m_variantSet = 1;
}
- const QFont & qfont() const
+ static int SVGToQtWeight(int weight);
+
+ void setWeight(int weight)
+ {
+ m_weight = weight;
+ m_weightSet = 1;
+ }
+
+ QSvgFont * svgFont() const
+ {
+ return m_svgFont;
+ }
+
+ const QFont &qfont() const
{
return m_qfont;
}
+
+ QSvgTinyDocument *doc() const {return m_doc;}
+
private:
- QSvgFont *m_font;
- qreal m_pointSize;
+ QSvgFont *m_svgFont;
QSvgTinyDocument *m_doc;
+ QFont m_qfont;
- QString m_textAnchor;
+ int m_weight;
+ Qt::Alignment m_textAnchor;
- QFont m_qfont;
- QFont m_oldFont;
+ QSvgFont *m_oldSvgFont;
+ QFont m_oldQFont;
+ Qt::Alignment m_oldTextAnchor;
+ int m_oldWeight;
+
+ unsigned m_familySet : 1;
+ unsigned m_sizeSet : 1;
+ unsigned m_styleSet : 1;
+ unsigned m_variantSet : 1;
+ unsigned m_weightSet : 1;
+ unsigned m_textAnchorSet : 1;
};
class QSvgStrokeStyle : public QSvgStyleProperty