QGIS API Documentation 3.39.0-Master (d85f3c2a281)
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
103 double fontPointSize() const;
104
117 void setFontPointSize( double size );
118
128 double fontPercentageSize() const;
129
141 void setFontPercentageSize( double size );
142
150 QString family() const;
151
160 void setFamily( const QString &family );
161
169 int fontWeight() const;
170
180 void setFontWeight( int fontWeight );
181
188 double wordSpacing() const;
189
196 void setWordSpacing( double spacing );
197
204 BooleanValue italic() const;
205
212 void setItalic( BooleanValue enabled );
213
219 BooleanValue strikeOut() const;
220
226 void setStrikeOut( BooleanValue enabled );
227
233 BooleanValue underline() const;
234
240 void setUnderline( BooleanValue enabled );
241
247 BooleanValue overline() const;
248
254 void setOverline( BooleanValue enabled );
255
266 bool hasVerticalAlignmentSet() const { return mHasVerticalAlignSet; }
267
278 void setHasVerticalAlignmentSet( bool set ) { mHasVerticalAlignSet = set; }
279
291
302 void setVerticalAlignment( Qgis::TextCharacterVerticalAlignment alignment ) { mVerticalAlign = alignment; }
303
313 void updateFontForFormat( QFont &font, const QgsRenderContext &context, double scaleFactor = 1.0 ) const;
314
315 private:
316
317 QColor mTextColor;
318 int mFontWeight = -1;
319 QString mStyleName;
320 BooleanValue mItalic = BooleanValue::NotSet;
321 double mFontPointSize = -1;
322 double mFontPercentageSize = -1;
323 QString mFontFamily;
324 double mWordSpacing = std::numeric_limits< double >::quiet_NaN();
325
326 bool mHasVerticalAlignSet = false;
328
329 BooleanValue mStrikethrough = BooleanValue::NotSet;
330 BooleanValue mUnderline = BooleanValue::NotSet;
331 BooleanValue mOverline = BooleanValue::NotSet;
332};
333
334#endif // QGSTEXTCHARACTERFORMAT_H
TextCharacterVerticalAlignment
Text vertical alignment for characters.
Definition qgis.h:2765
@ 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.