Qt 4.8
Public Functions | Static Public Functions | Static Public Variables | Properties | List of all members
QSvgFontStyle Class Reference

#include <qsvgstyle_p.h>

Inheritance diagram for QSvgFontStyle:
QSvgStyleProperty QSvgRefCounted

Public Functions

virtual void apply (QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
 
QSvgTinyDocumentdoc () const
 
const QFontqfont () const
 
 QSvgFontStyle (QSvgFont *font, QSvgTinyDocument *doc)
 
 QSvgFontStyle ()
 
virtual void revert (QPainter *p, QSvgExtraStates &states)
 
void setFamily (const QString &family)
 
void setSize (qreal size)
 
void setStyle (QFont::Style fontStyle)
 
void setTextAnchor (Qt::Alignment anchor)
 
void setVariant (QFont::Capitalization fontVariant)
 
void setWeight (int weight)
 
QSvgFontsvgFont () const
 
virtual Type type () const
 
- Public Functions inherited from QSvgStyleProperty
virtual ~QSvgStyleProperty ()
 
- Public Functions inherited from QSvgRefCounted
void deref ()
 
 QSvgRefCounted ()
 
void ref ()
 
virtual ~QSvgRefCounted ()
 

Static Public Functions

static int SVGToQtWeight (int weight)
 

Static Public Variables

static const int BOLDER = 1
 
static const int LIGHTER = -1
 

Properties

QSvgTinyDocumentm_doc
 
uint m_familySet: 1
 
QFont m_oldQFont
 
QSvgFontm_oldSvgFont
 
Qt::Alignment m_oldTextAnchor
 
int m_oldWeight
 
QFont m_qfont
 
uint m_sizeSet: 1
 
uint m_styleSet: 1
 
QSvgFontm_svgFont
 
Qt::Alignment m_textAnchor
 
uint m_textAnchorSet: 1
 
uint m_variantSet: 1
 
int m_weight
 
uint m_weightSet: 1
 

Additional Inherited Members

- Public Types inherited from QSvgStyleProperty
enum  Type {
  QUALITY, FILL, VIEWPORT_FILL, FONT,
  STROKE, SOLID_COLOR, GRADIENT, TRANSFORM,
  ANIMATE_TRANSFORM, ANIMATE_COLOR, OPACITY, COMP_OP
}
 

Detailed Description

Definition at line 325 of file qsvgstyle_p.h.

Constructors and Destructors

◆ QSvgFontStyle() [1/2]

QSvgFontStyle::QSvgFontStyle ( QSvgFont font,
QSvgTinyDocument doc 
)

Definition at line 183 of file qsvgstyle.cpp.

184  : m_svgFont(font)
185  , m_doc(doc)
186  , m_familySet(0)
187  , m_sizeSet(0)
188  , m_styleSet(0)
189  , m_variantSet(0)
190  , m_weightSet(0)
191  , m_textAnchorSet(0)
192 {
193 }
QSvgTinyDocument * m_doc
Definition: qsvgstyle_p.h:390
QSvgFont * m_svgFont
Definition: qsvgstyle_p.h:389
uint m_textAnchorSet
Definition: qsvgstyle_p.h:406

◆ QSvgFontStyle() [2/2]

QSvgFontStyle::QSvgFontStyle ( )

Definition at line 195 of file qsvgstyle.cpp.

196  : m_svgFont(0)
197  , m_doc(0)
198  , m_familySet(0)
199  , m_sizeSet(0)
200  , m_styleSet(0)
201  , m_variantSet(0)
202  , m_weightSet(0)
203  , m_textAnchorSet(0)
204 {
205 }
QSvgTinyDocument * m_doc
Definition: qsvgstyle_p.h:390
QSvgFont * m_svgFont
Definition: qsvgstyle_p.h:389
uint m_textAnchorSet
Definition: qsvgstyle_p.h:406

Functions

◆ apply()

void QSvgFontStyle::apply ( QPainter p,
const QSvgNode node,
QSvgExtraStates states 
)
virtual

Implements QSvgStyleProperty.

Definition at line 227 of file qsvgstyle.cpp.

228 {
229  m_oldQFont = p->font();
230  m_oldSvgFont = states.svgFont;
231  m_oldTextAnchor = states.textAnchor;
232  m_oldWeight = states.fontWeight;
233 
234  if (m_textAnchorSet)
235  states.textAnchor = m_textAnchor;
236 
237  QFont font = m_oldQFont;
238  if (m_familySet) {
239  states.svgFont = m_svgFont;
240  font.setFamily(m_qfont.family());
241  }
242 
243  if (m_sizeSet)
245 
246  if (m_styleSet)
247  font.setStyle(m_qfont.style());
248 
249  if (m_variantSet)
251 
252  if (m_weightSet) {
253  if (m_weight == BOLDER) {
254  states.fontWeight = qMin(states.fontWeight + 100, 900);
255  } else if (m_weight == LIGHTER) {
256  states.fontWeight = qMax(states.fontWeight - 100, 100);
257  } else {
258  states.fontWeight = m_weight;
259  }
260  font.setWeight(SVGToQtWeight(states.fontWeight));
261  }
262 
263  p->setFont(font);
264 }
void setCapitalization(Capitalization)
Sets the capitalization of the text in this font to caps.
Definition: qfont.cpp:1798
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
Style style() const
Returns the style of the font.
Definition: qfont.cpp:1223
Capitalization capitalization() const
Returns the current capitalization type of the font.
Definition: qfont.cpp:1819
Qt::Alignment m_textAnchor
Definition: qsvgstyle_p.h:394
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setFamily(const QString &)
Sets the family name of the font.
Definition: qfont.cpp:924
static int SVGToQtWeight(int weight)
Definition: qsvgstyle.cpp:207
Qt::Alignment m_oldTextAnchor
Definition: qsvgstyle_p.h:398
qreal pointSizeF() const
Returns the point size of the font.
Definition: qfont.cpp:1142
QSvgFont * m_oldSvgFont
Definition: qsvgstyle_p.h:396
QFont m_oldQFont
Definition: qsvgstyle_p.h:397
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
QSvgFont * svgFont
Definition: qsvgstyle_p.h:147
static const int BOLDER
Definition: qsvgstyle_p.h:329
QSvgFont * m_svgFont
Definition: qsvgstyle_p.h:389
static const int LIGHTER
Definition: qsvgstyle_p.h:328
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
void setWeight(int)
Sets the weight the font to weight, which should be a value from the QFont::Weight enumeration...
Definition: qfont.cpp:1278
Qt::Alignment textAnchor
Definition: qsvgstyle_p.h:148
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition: qfont.cpp:1121
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
uint m_textAnchorSet
Definition: qsvgstyle_p.h:406
void setStyle(Style style)
Sets the style of the font to style.
Definition: qfont.cpp:1234

◆ doc()

QSvgTinyDocument* QSvgFontStyle::doc ( ) const
inline

Definition at line 386 of file qsvgstyle_p.h.

Referenced by parseFontFaceNameNode(), and parseFontFaceNode().

386 {return m_doc;}
QSvgTinyDocument * m_doc
Definition: qsvgstyle_p.h:390

◆ qfont()

const QFont& QSvgFontStyle::qfont ( ) const
inline

Definition at line 381 of file qsvgstyle_p.h.

382  {
383  return m_qfont;
384  }

◆ revert()

void QSvgFontStyle::revert ( QPainter p,
QSvgExtraStates states 
)
virtual

Implements QSvgStyleProperty.

Definition at line 266 of file qsvgstyle.cpp.

267 {
268  p->setFont(m_oldQFont);
269  states.svgFont = m_oldSvgFont;
270  states.textAnchor = m_oldTextAnchor;
271  states.fontWeight = m_oldWeight;
272 }
Qt::Alignment m_oldTextAnchor
Definition: qsvgstyle_p.h:398
QSvgFont * m_oldSvgFont
Definition: qsvgstyle_p.h:396
QFont m_oldQFont
Definition: qsvgstyle_p.h:397
QSvgFont * svgFont
Definition: qsvgstyle_p.h:147
Qt::Alignment textAnchor
Definition: qsvgstyle_p.h:148
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288

◆ setFamily()

void QSvgFontStyle::setFamily ( const QString family)
inline

Definition at line 351 of file qsvgstyle_p.h.

Referenced by parseFont().

352  {
353  m_qfont.setFamily(family);
354  m_familySet = 1;
355  }
void setFamily(const QString &)
Sets the family name of the font.
Definition: qfont.cpp:924

◆ setSize()

void QSvgFontStyle::setSize ( qreal  size)
inline

Definition at line 337 of file qsvgstyle_p.h.

Referenced by parseFont().

338  {
339  // Store the _pixel_ size in the font. Since QFont::setPixelSize() only takes an int, call
340  // QFont::SetPointSize() instead. Set proper font size just before rendering.
341  m_qfont.setPointSizeF(size);
342  m_sizeSet = 1;
343  }
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition: qfont.cpp:1121

◆ setStyle()

void QSvgFontStyle::setStyle ( QFont::Style  fontStyle)
inline

Definition at line 357 of file qsvgstyle_p.h.

Referenced by parseFont().

357  {
358  m_qfont.setStyle(fontStyle);
359  m_styleSet = 1;
360  }
void setStyle(Style style)
Sets the style of the font to style.
Definition: qfont.cpp:1234

◆ setTextAnchor()

void QSvgFontStyle::setTextAnchor ( Qt::Alignment  anchor)
inline

Definition at line 345 of file qsvgstyle_p.h.

Referenced by parseFont().

346  {
347  m_textAnchor = anchor;
348  m_textAnchorSet = 1;
349  }
Qt::Alignment m_textAnchor
Definition: qsvgstyle_p.h:394
uint m_textAnchorSet
Definition: qsvgstyle_p.h:406

◆ setVariant()

void QSvgFontStyle::setVariant ( QFont::Capitalization  fontVariant)
inline

Definition at line 362 of file qsvgstyle_p.h.

Referenced by parseFont().

363  {
364  m_qfont.setCapitalization(fontVariant);
365  m_variantSet = 1;
366  }
void setCapitalization(Capitalization)
Sets the capitalization of the text in this font to caps.
Definition: qfont.cpp:1798

◆ setWeight()

void QSvgFontStyle::setWeight ( int  weight)
inline

Definition at line 370 of file qsvgstyle_p.h.

Referenced by parseFont().

371  {
372  m_weight = weight;
373  m_weightSet = 1;
374  }

◆ svgFont()

QSvgFont* QSvgFontStyle::svgFont ( ) const
inline

Definition at line 376 of file qsvgstyle_p.h.

Referenced by parseFontFaceNameNode(), parseFontFaceNode(), parseGlyphNode(), and parseMissingGlyphNode().

377  {
378  return m_svgFont;
379  }
QSvgFont * m_svgFont
Definition: qsvgstyle_p.h:389

◆ SVGToQtWeight()

int QSvgFontStyle::SVGToQtWeight ( int  weight)
static

Definition at line 207 of file qsvgstyle.cpp.

Referenced by apply().

207  {
208  switch (weight) {
209  case 100:
210  case 200:
211  return QFont::Light;
212  case 300:
213  case 400:
214  return QFont::Normal;
215  case 500:
216  case 600:
217  return QFont::DemiBold;
218  case 700:
219  case 800:
220  return QFont::Bold;
221  case 900:
222  return QFont::Black;
223  }
224  return QFont::Normal;
225 }

◆ type()

QSvgStyleProperty::Type QSvgFontStyle::type ( ) const
virtual

Implements QSvgStyleProperty.

Definition at line 472 of file qsvgstyle.cpp.

473 {
474  return FONT;
475 }

Properties

◆ BOLDER

const int QSvgFontStyle::BOLDER = 1
static

Definition at line 329 of file qsvgstyle_p.h.

Referenced by apply(), and parseFont().

◆ LIGHTER

const int QSvgFontStyle::LIGHTER = -1
static

Definition at line 328 of file qsvgstyle_p.h.

Referenced by apply(), and parseFont().

◆ m_doc

QSvgTinyDocument* QSvgFontStyle::m_doc
private

Definition at line 390 of file qsvgstyle_p.h.

◆ m_familySet

uint QSvgFontStyle::m_familySet
private

Definition at line 401 of file qsvgstyle_p.h.

Referenced by apply().

◆ m_oldQFont

QFont QSvgFontStyle::m_oldQFont
private

Definition at line 397 of file qsvgstyle_p.h.

Referenced by apply(), and revert().

◆ m_oldSvgFont

QSvgFont* QSvgFontStyle::m_oldSvgFont
private

Definition at line 396 of file qsvgstyle_p.h.

Referenced by apply(), and revert().

◆ m_oldTextAnchor

Qt::Alignment QSvgFontStyle::m_oldTextAnchor
private

Definition at line 398 of file qsvgstyle_p.h.

Referenced by apply(), and revert().

◆ m_oldWeight

int QSvgFontStyle::m_oldWeight
private

Definition at line 399 of file qsvgstyle_p.h.

Referenced by apply(), and revert().

◆ m_qfont

QFont QSvgFontStyle::m_qfont
private

Definition at line 391 of file qsvgstyle_p.h.

Referenced by apply().

◆ m_sizeSet

uint QSvgFontStyle::m_sizeSet
private

Definition at line 402 of file qsvgstyle_p.h.

Referenced by apply().

◆ m_styleSet

uint QSvgFontStyle::m_styleSet
private

Definition at line 403 of file qsvgstyle_p.h.

Referenced by apply().

◆ m_svgFont

QSvgFont* QSvgFontStyle::m_svgFont
private

Definition at line 389 of file qsvgstyle_p.h.

Referenced by apply().

◆ m_textAnchor

Qt::Alignment QSvgFontStyle::m_textAnchor
private

Definition at line 394 of file qsvgstyle_p.h.

Referenced by apply().

◆ m_textAnchorSet

uint QSvgFontStyle::m_textAnchorSet
private

Definition at line 406 of file qsvgstyle_p.h.

Referenced by apply().

◆ m_variantSet

uint QSvgFontStyle::m_variantSet
private

Definition at line 404 of file qsvgstyle_p.h.

Referenced by apply().

◆ m_weight

int QSvgFontStyle::m_weight
private

Definition at line 393 of file qsvgstyle_p.h.

Referenced by apply().

◆ m_weightSet

uint QSvgFontStyle::m_weightSet
private

Definition at line 405 of file qsvgstyle_p.h.

Referenced by apply().


The documentation for this class was generated from the following files: