QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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"
21 #include "qgstextcharacterformat.h"
22 #include "qgsstringutils.h"
23 
24 class QTextFragment;
25 
35 class 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  const QgsTextCharacterFormat &characterFormat() const { return mCharFormat; }
69 
75  void setCharacterFormat( const QgsTextCharacterFormat &format );
76 
89  double horizontalAdvance( const QFont &font, bool fontHasBeenUpdatedForFragment = false, double scaleFactor = 1.0 ) const;
90 
96  void applyCapitalization( QgsStringUtils::Capitalization capitalization );
97 
98  private:
99 
100  QString mText;
101  QgsTextCharacterFormat mCharFormat;
102 };
103 
104 #endif // QGSTEXTFRAGMENT_H
Capitalization
Capitalization options.
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.