QGIS API Documentation 3.37.0-Master (684a802617f)
Loading...
Searching...
No Matches
qgstextfragment.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextfragment.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 QGSTEXTFRAGMENT_H
17#define QGSTEXTFRAGMENT_H
18
19#include "qgis_sip.h"
20#include "qgis_core.h"
22#include "qgis.h"
23
24class QTextFragment;
25
35class CORE_EXPORT QgsTextFragment
36{
37 public:
38
42 explicit QgsTextFragment( const QString &text = QString(), const QgsTextCharacterFormat &format = QgsTextCharacterFormat() );
43
47 explicit QgsTextFragment( const QTextFragment &fragment );
48
54 QString text() const;
55
61 void setText( const QString &text );
62
68 bool isTab() const { return mText == '\t'; }
69
76 bool isWhitespace() const { return isTab() || mText.trimmed().isEmpty(); }
77
83 const QgsTextCharacterFormat &characterFormat() const { return mCharFormat; }
84
90 void setCharacterFormat( const QgsTextCharacterFormat &format );
91
104 double horizontalAdvance( const QFont &font, const QgsRenderContext &context, bool fontHasBeenUpdatedForFragment = false, double scaleFactor = 1.0 ) const;
105
111 void applyCapitalization( Qgis::Capitalization capitalization );
112
113 private:
114
115 QString mText;
116 QgsTextCharacterFormat mCharFormat;
117};
118
119#endif // QGSTEXTFRAGMENT_H
Capitalization
String capitalization options.
Definition qgis.h:2884
Contains information about the context of a rendering operation.
Stores information relating to individual character formatting.
Stores a fragment of text along with formatting overrides to be used when rendering the fragment.
const QgsTextCharacterFormat & characterFormat() const
Returns the character formatting for the fragment.
bool isTab() const
Returns true if the fragment consists of just a tab character.
bool isWhitespace() const
Returns true if the fragment consists of just whitespace characters, and does not contain any content...