QGIS API Documentation 3.39.0-Master (3aed037ce22)
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
26class QTextCharFormat;
28
41class CORE_EXPORT QgsTextCharacterFormat
42{
43 public:
44
46
50 QgsTextCharacterFormat( const QTextCharFormat &format );
51
53 enum class BooleanValue
54 {
55 NotSet,
56 SetTrue,
57 SetFalse,
58 };
59
73 void overrideWith( const QgsTextCharacterFormat &other );
74
81 QColor textColor() const;
82
91 void setTextColor( const QColor &textColor );
92
100 double fontPointSize() const;
101
111 void setFontPointSize( double size );
112
120 QString family() const;
121
130 void setFamily( const QString &family );
131
139 int fontWeight() const;
140
150 void setFontWeight( int fontWeight );
151
158 BooleanValue italic() const;
159
166 void setItalic( BooleanValue enabled );
167
173 BooleanValue strikeOut() const;
174
180 void setStrikeOut( BooleanValue enabled );
181
187 BooleanValue underline() const;
188
194 void setUnderline( BooleanValue enabled );
195
201 BooleanValue overline() const;
202
208 void setOverline( BooleanValue enabled );
209
220 bool hasVerticalAlignmentSet() const { return mHasVerticalAlignSet; }
221
232 void setHasVerticalAlignmentSet( bool set ) { mHasVerticalAlignSet = set; }
233
245
256 void setVerticalAlignment( Qgis::TextCharacterVerticalAlignment alignment ) { mVerticalAlign = alignment; }
257
267 void updateFontForFormat( QFont &font, const QgsRenderContext &context, double scaleFactor = 1.0 ) const;
268
269 private:
270
271 QColor mTextColor;
272 int mFontWeight = -1;
273 QString mStyleName;
274 BooleanValue mItalic = BooleanValue::NotSet;
275 double mFontPointSize = -1;
276 QString mFontFamily;
277
278 bool mHasVerticalAlignSet = false;
280
281 BooleanValue mStrikethrough = BooleanValue::NotSet;
282 BooleanValue mUnderline = BooleanValue::NotSet;
283 BooleanValue mOverline = BooleanValue::NotSet;
284};
285
286#endif // QGSTEXTCHARACTERFORMAT_H
TextCharacterVerticalAlignment
Text vertical alignment for characters.
Definition qgis.h:2631
@ 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.