QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgstextcharacterformat.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextcharacterformat.h
3 -----------------
4 begin : May 2020
5 copyright : (C) Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSTEXTCHARACTERFORMAT_H
17#define QGSTEXTCHARACTERFORMAT_H
18
19#include "qgis_sip.h"
20#include "qgis_core.h"
21#include "qgis.h"
22
23#include <QFont>
24#include <QColor>
25#include <QSizeF>
26#include <QBrush>
27
28class QTextCharFormat;
30
43class CORE_EXPORT QgsTextCharacterFormat
44{
45 public:
46
48
52 QgsTextCharacterFormat( const QTextCharFormat &format );
53
55 enum class BooleanValue
56 {
57 NotSet,
58 SetTrue,
59 SetFalse,
60 };
61
75 void overrideWith( const QgsTextCharacterFormat &other );
76
83 QColor textColor() const;
84
93 void setTextColor( const QColor &textColor );
94
105 double fontPointSize() const;
106
119 void setFontPointSize( double size );
120
130 double fontPercentageSize() const;
131
143 void setFontPercentageSize( double size );
144
152 QString family() const;
153
162 void setFamily( const QString &family );
163
171 int fontWeight() const;
172
182 void setFontWeight( int fontWeight );
183
190 double wordSpacing() const;
191
198 void setWordSpacing( double spacing );
199
206 BooleanValue italic() const;
207
214 void setItalic( BooleanValue enabled );
215
221 BooleanValue strikeOut() const;
222
228 void setStrikeOut( BooleanValue enabled );
229
235 BooleanValue underline() const;
236
242 void setUnderline( BooleanValue enabled );
243
249 BooleanValue overline() const;
250
256 void setOverline( BooleanValue enabled );
257
267 QString imagePath() const;
268
278 void setImagePath( const QString &path );
279
291 QSizeF imageSize() const;
292
304 void setImageSize( const QSizeF &size );
305
316 bool hasVerticalAlignmentSet() const { return mHasVerticalAlignSet; }
317
328 void setHasVerticalAlignmentSet( bool set ) { mHasVerticalAlignSet = set; }
329
341
352 void setVerticalAlignment( Qgis::TextCharacterVerticalAlignment alignment ) { mVerticalAlign = alignment; }
353
360 bool hasBackground() const;
361
371 QBrush backgroundBrush() const;
372
381 void setBackgroundBrush( const QBrush &brush );
382
392 QString backgroundImagePath() const;
393
402 void setBackgroundImagePath( const QString &path );
403
413 void updateFontForFormat( QFont &font, const QgsRenderContext &context, double scaleFactor = 1.0 ) const;
414
415 private:
416
417 QColor mTextColor;
418 int mFontWeight = -1;
419 QString mStyleName;
420 BooleanValue mItalic = BooleanValue::NotSet;
421 double mFontPointSize = -1;
422 double mFontPercentageSize = -1;
423 QString mFontFamily;
424 double mWordSpacing = std::numeric_limits< double >::quiet_NaN();
425
426 bool mHasVerticalAlignSet = false;
428
429 QString mImagePath;
430 QSizeF mImageSize;
431
432 BooleanValue mStrikethrough = BooleanValue::NotSet;
433 BooleanValue mUnderline = BooleanValue::NotSet;
434 BooleanValue mOverline = BooleanValue::NotSet;
435
436 QBrush mBackgroundBrush;
437 QString mBackgroundPath;
438
439};
440
441#endif // QGSTEXTCHARACTERFORMAT_H
TextCharacterVerticalAlignment
Text vertical alignment for characters.
Definition qgis.h:2775
@ Normal
Adjacent characters are positioned in the standard way for text in the writing system in use.
Contains information about the context of a rendering operation.
Stores information relating to individual character formatting.
QgsTextCharacterFormat()=default
void setVerticalAlignment(Qgis::TextCharacterVerticalAlignment alignment)
Sets the format vertical alignment.
BooleanValue
Status values for boolean format properties.
Qgis::TextCharacterVerticalAlignment verticalAlignment() const
Returns the format vertical alignment.
bool hasVerticalAlignmentSet() const
Returns true if the format has an explicit vertical alignment set.
void setHasVerticalAlignmentSet(bool set)
Sets whether the format has an explicit vertical alignment set.