QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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
27class QTextCharFormat;
29
42class CORE_EXPORT QgsTextCharacterFormat
43{
44 public:
45
47
51 QgsTextCharacterFormat( const QTextCharFormat &format );
52
54 enum class BooleanValue
55 {
56 NotSet,
57 SetTrue,
58 SetFalse,
59 };
60
74 void overrideWith( const QgsTextCharacterFormat &other );
75
82 QColor textColor() const;
83
92 void setTextColor( const QColor &textColor );
93
104 double fontPointSize() const;
105
118 void setFontPointSize( double size );
119
129 double fontPercentageSize() const;
130
142 void setFontPercentageSize( double size );
143
151 QString family() const;
152
161 void setFamily( const QString &family );
162
170 int fontWeight() const;
171
181 void setFontWeight( int fontWeight );
182
189 double wordSpacing() const;
190
197 void setWordSpacing( double spacing );
198
205 BooleanValue italic() const;
206
213 void setItalic( BooleanValue enabled );
214
220 BooleanValue strikeOut() const;
221
227 void setStrikeOut( BooleanValue enabled );
228
234 BooleanValue underline() const;
235
241 void setUnderline( BooleanValue enabled );
242
248 BooleanValue overline() const;
249
255 void setOverline( BooleanValue enabled );
256
266 QString imagePath() const;
267
277 void setImagePath( const QString &path );
278
290 QSizeF imageSize() const;
291
303 void setImageSize( const QSizeF &size );
304
315 bool hasVerticalAlignmentSet() const { return mHasVerticalAlignSet; }
316
327 void setHasVerticalAlignmentSet( bool set ) { mHasVerticalAlignSet = set; }
328
340
351 void setVerticalAlignment( Qgis::TextCharacterVerticalAlignment alignment ) { mVerticalAlign = alignment; }
352
362 void updateFontForFormat( QFont &font, const QgsRenderContext &context, double scaleFactor = 1.0 ) const;
363
364 private:
365
366 QColor mTextColor;
367 int mFontWeight = -1;
368 QString mStyleName;
369 BooleanValue mItalic = BooleanValue::NotSet;
370 double mFontPointSize = -1;
371 double mFontPercentageSize = -1;
372 QString mFontFamily;
373 double mWordSpacing = std::numeric_limits< double >::quiet_NaN();
374
375 bool mHasVerticalAlignSet = false;
377
378 QString mImagePath;
379 QSizeF mImageSize;
380
381 BooleanValue mStrikethrough = BooleanValue::NotSet;
382 BooleanValue mUnderline = BooleanValue::NotSet;
383 BooleanValue mOverline = BooleanValue::NotSet;
384};
385
386#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.