QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgstextdocumentmetrics.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextdocumentmetrics.h
3 -----------------
4 begin : September 2022
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 QGSTEXTDOCUMENTMETRICS_H
17#define QGSTEXTDOCUMENTMETRICS_H
18
19#include "qgis_sip.h"
20#include "qgis_core.h"
21#include "qgis.h"
22
23#include <QVector>
24#include <QSizeF>
25
26class QgsTextDocument;
28class QgsTextFormat;
29
40class CORE_EXPORT QgsTextDocumentMetrics
41{
42 public:
43
53 static QgsTextDocumentMetrics calculateMetrics( const QgsTextDocument &document, const QgsTextFormat &format, const QgsRenderContext &context, double scaleFactor = 1.0 );
54
58 QSizeF documentSize( Qgis::TextLayoutMode mode, Qgis::TextOrientation orientation ) const;
59
63 double blockWidth( int blockIndex ) const;
64
68 double blockHeight( int blockIndex ) const;
69
73 double baselineOffset( int blockIndex, Qgis::TextLayoutMode mode ) const;
74
78 double verticalOrientationXOffset( int blockIndex ) const;
79
83 double blockMaximumCharacterWidth( int blockIndex ) const;
84
88 double blockMaximumDescent( int blockIndex ) const;
89
93 QFont fragmentFont( int blockIndex, int fragmentIndex ) const;
94
98 double ascentOffset() const { return mFirstLineAscentOffset; }
99
100 private:
101
102 QSizeF mDocumentSizeLabelMode;
103 QSizeF mDocumentSizePointRectMode;
104 QSizeF mDocumentSizeVerticalOrientation;
105
106 QList < QList< QFont > > mFragmentFonts;
107 QList< double > mBlockWidths;
108 QList< double > mBlockHeights;
109 QList< double > mBaselineOffsetsLabelMode;
110 QList< double > mBaselineOffsetsPointMode;
111 QList< double > mBaselineOffsetsRectMode;
112 QList< double > mVerticalOrientationXOffsets;
113 QList< double > mBlockMaxDescent;
114 QList< double > mBlockMaxCharacterWidth;
115 double mFirstLineAscentOffset = 0;
116 double mLastLineAscentOffset = 0;
117
118};
119
120#endif // QGSTEXTDOCUMENTMETRICS_H
TextLayoutMode
Text layout modes.
Definition: qgis.h:1445
TextOrientation
Text orientations.
Definition: qgis.h:1430
Contains information about the context of a rendering operation.
Contains pre-calculated metrics of a QgsTextDocument.
double ascentOffset() const
Returns the ascent offset of the first block in the document.
Represents a document consisting of one or more QgsTextBlock objects.
Container for all settings relating to text rendering.
Definition: qgstextformat.h:41