QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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
41class CORE_EXPORT QgsTextFragment
42{
43 public:
44
48 explicit QgsTextFragment( const QString &text = QString(), const QgsTextCharacterFormat &format = QgsTextCharacterFormat() );
49
53 explicit QgsTextFragment( const QTextFragment &fragment );
54
60 QString text() const;
61
67 void setText( const QString &text );
68
74 bool isTab() const { return mText == '\t'; }
75
82 bool isWhitespace() const { return isTab() || mText.trimmed().isEmpty(); }
83
89 const QgsTextCharacterFormat &characterFormat() const { return mCharFormat; }
90
96 void setCharacterFormat( const QgsTextCharacterFormat &format );
97
103 bool isImage() const;
104
117 double horizontalAdvance( const QFont &font, const QgsRenderContext &context, bool fontHasBeenUpdatedForFragment = false, double scaleFactor = 1.0 ) const;
118
124 void applyCapitalization( Qgis::Capitalization capitalization );
125
126 private:
127
128 QString mText;
129 bool mIsImage = false;
130 QgsTextCharacterFormat mCharFormat;
131};
132
133#endif // QGSTEXTFRAGMENT_H
Capitalization
String capitalization options.
Definition qgis.h:3132
Contains information about the context of a rendering operation.
Stores information relating to individual character formatting.
Stores a fragment of document 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...