QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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
69 QColor textColor() const;
70
79 void setTextColor( const QColor &textColor );
80
88 double fontPointSize() const;
89
99 void setFontPointSize( double size );
100
108 QString family() const;
109
118 void setFamily( const QString &family );
119
127 int fontWeight() const;
128
138 void setFontWeight( int fontWeight );
139
146 BooleanValue italic() const;
147
154 void setItalic( BooleanValue enabled );
155
161 BooleanValue strikeOut() const;
162
168 void setStrikeOut( BooleanValue enabled );
169
175 BooleanValue underline() const;
176
182 void setUnderline( BooleanValue enabled );
183
189 BooleanValue overline() const;
190
196 void setOverline( BooleanValue enabled );
197
208 bool hasVerticalAlignmentSet() const { return mHasVerticalAlignSet; }
209
220 void setHasVerticalAlignmentSet( bool set ) { mHasVerticalAlignSet = set; }
221
233
244 void setVerticalAlignment( Qgis::TextCharacterVerticalAlignment alignment ) { mVerticalAlign = alignment; }
245
255 void updateFontForFormat( QFont &font, const QgsRenderContext &context, double scaleFactor = 1.0 ) const;
256
257 private:
258
259 QColor mTextColor;
260 int mFontWeight = -1;
261 QString mStyleName;
262 BooleanValue mItalic = BooleanValue::NotSet;
263 double mFontPointSize = -1;
264 QString mFontFamily;
265
266 bool mHasVerticalAlignSet = false;
268
269 BooleanValue mStrikethrough = BooleanValue::NotSet;
270 BooleanValue mUnderline = BooleanValue::NotSet;
271 BooleanValue mOverline = BooleanValue::NotSet;
272};
273
274#endif // QGSTEXTCHARACTERFORMAT_H
TextCharacterVerticalAlignment
Text vertical alignment for characters.
Definition: qgis.h:1869
@ 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.