QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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.h"
20#include "qgis_core.h"
21#include "qgis_sip.h"
23
24class QTextFragment;
25
41class CORE_EXPORT QgsTextFragment
42{
43 public:
47 explicit QgsTextFragment( const QString &text = QString(), const QgsTextCharacterFormat &format = QgsTextCharacterFormat() );
48
52 explicit QgsTextFragment( const QTextFragment &fragment );
53
59 QString text() const;
60
66 void setText( const QString &text );
67
73 bool isTab() const { return mText == '\t'; }
74
81 bool isWhitespace() const { return isTab() || mText.trimmed().isEmpty(); }
82
88 const QgsTextCharacterFormat &characterFormat() const { return mCharFormat; }
89
95 void setCharacterFormat( const QgsTextCharacterFormat &format );
96
102 bool isImage() const;
103
116 double horizontalAdvance( const QFont &font, const QgsRenderContext &context, bool fontHasBeenUpdatedForFragment = false, double scaleFactor = 1.0 ) const;
117
123 void applyCapitalization( Qgis::Capitalization capitalization );
124
125 private:
126 QString mText;
127 bool mIsImage = false;
128 QgsTextCharacterFormat mCharFormat;
129};
130
131#endif // QGSTEXTFRAGMENT_H
Capitalization
String capitalization options.
Definition qgis.h:3503
Contains information about the context of a rendering operation.
Stores information relating to individual character formatting.
void setText(const QString &text)
Sets the text content of the fragment.
QString text() const
Returns the text content of the fragment.
const QgsTextCharacterFormat & characterFormat() const
Returns the character formatting for the fragment.
QgsTextFragment(const QString &text=QString(), const QgsTextCharacterFormat &format=QgsTextCharacterFormat())
Constructor for QgsTextFragment, with the specified text and optional character format.
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...