QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
26class QTextCharFormat;
28
41class CORE_EXPORT QgsTextCharacterFormat
42{
43 public:
44
49
53 QgsTextCharacterFormat( const QTextCharFormat &format );
54
56 enum class BooleanValue
57 {
58 NotSet,
59 SetTrue,
60 SetFalse,
61 };
62
76 void overrideWith( const QgsTextCharacterFormat &other );
77
84 QColor textColor() const;
85
94 void setTextColor( const QColor &textColor );
95
103 double fontPointSize() const;
104
114 void setFontPointSize( double size );
115
123 QString family() const;
124
133 void setFamily( const QString &family );
134
142 int fontWeight() const;
143
153 void setFontWeight( int fontWeight );
154
161 BooleanValue italic() const;
162
169 void setItalic( BooleanValue enabled );
170
176 BooleanValue strikeOut() const;
177
183 void setStrikeOut( BooleanValue enabled );
184
190 BooleanValue underline() const;
191
197 void setUnderline( BooleanValue enabled );
198
204 BooleanValue overline() const;
205
211 void setOverline( BooleanValue enabled );
212
223 bool hasVerticalAlignmentSet() const { return mHasVerticalAlignSet; }
224
235 void setHasVerticalAlignmentSet( bool set ) { mHasVerticalAlignSet = set; }
236
248
259 void setVerticalAlignment( Qgis::TextCharacterVerticalAlignment alignment ) { mVerticalAlign = alignment; }
260
270 void updateFontForFormat( QFont &font, const QgsRenderContext &context, double scaleFactor = 1.0 ) const;
271
272 private:
273
274 QColor mTextColor;
275 int mFontWeight = -1;
276 QString mStyleName;
277 BooleanValue mItalic = BooleanValue::NotSet;
278 double mFontPointSize = -1;
279 QString mFontFamily;
280
281 bool mHasVerticalAlignSet = false;
283
284 BooleanValue mStrikethrough = BooleanValue::NotSet;
285 BooleanValue mUnderline = BooleanValue::NotSet;
286 BooleanValue mOverline = BooleanValue::NotSet;
287};
288
289#endif // QGSTEXTCHARACTERFORMAT_H
TextCharacterVerticalAlignment
Text vertical alignment for characters.
Definition: qgis.h:2451
@ 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
Constructor for QgsTextCharacterFormat.
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.