QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
|
Contains pre-calculated metrics of a QgsTextDocument. More...
#include <qgstextdocumentmetrics.h>
Public Member Functions | |
double | ascentOffset () const |
Returns the ascent offset of the first block in the document. | |
double | baselineOffset (int blockIndex, Qgis::TextLayoutMode mode) const |
Returns the offset from the top of the document to the text baseline for the given block index. | |
double | blockHeight (int blockIndex) const |
Returns the height of the block at the specified index. | |
double | blockMaximumCharacterWidth (int blockIndex) const |
Returns the maximum character width for the specified block. | |
double | blockMaximumDescent (int blockIndex) const |
Returns the maximum descent encountered in the specified block. | |
double | blockWidth (int blockIndex) const |
Returns the width of the block at the specified index. | |
const QgsTextDocument & | document () const |
Returns the document associated with the calculated metrics. | |
QSizeF | documentSize (Qgis::TextLayoutMode mode, Qgis::TextOrientation orientation) const |
Returns the overall size of the document. | |
double | firstLineCapHeight () const |
Returns the cap height for the first line of text. | |
double | fragmentFixedHeight (int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode) const |
Returns the fixed height of the fragment at the specified block and fragment index, or -1 if the fragment does not have a fixed height. | |
QFont | fragmentFont (int blockIndex, int fragmentIndex) const |
Returns the calculated font for the fragment at the specified block and fragment indices. | |
double | fragmentHorizontalAdvance (int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode) const |
Returns the horizontal advance of the fragment at the specified block and fragment index. | |
double | fragmentVerticalOffset (int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode) const |
Returns the vertical offset from a text block's baseline which should be applied to the fragment at the specified index within that block. | |
bool | isNullFontSize () const |
Returns true if the metrics could not be calculated because the text format has a null font size. | |
QRectF | outerBounds (Qgis::TextLayoutMode mode, Qgis::TextOrientation orientation) const |
Returns the outer bounds of the document, which is the documentSize() adjusted to account for any text elements which fall outside of the usual document margins (such as super or sub script elements) | |
double | verticalOrientationXOffset (int blockIndex) const |
Returns the vertical orientation x offset for the specified block. | |
Static Public Member Functions | |
static QgsTextDocumentMetrics | calculateMetrics (const QgsTextDocument &document, const QgsTextFormat &format, const QgsRenderContext &context, double scaleFactor=1.0, const QgsTextDocumentRenderContext &documentContext=QgsTextDocumentRenderContext()) |
Returns precalculated text metrics for a text document, when rendered using the given base format and render context. | |
Contains pre-calculated metrics of a QgsTextDocument.
Definition at line 96 of file qgstextdocumentmetrics.h.
|
inline |
Returns the ascent offset of the first block in the document.
Definition at line 215 of file qgstextdocumentmetrics.h.
double QgsTextDocumentMetrics::baselineOffset | ( | int | blockIndex, |
Qgis::TextLayoutMode | mode | ||
) | const |
Returns the offset from the top of the document to the text baseline for the given block index.
Definition at line 665 of file qgstextdocumentmetrics.cpp.
double QgsTextDocumentMetrics::blockHeight | ( | int | blockIndex | ) | const |
Returns the height of the block at the specified index.
Definition at line 655 of file qgstextdocumentmetrics.cpp.
double QgsTextDocumentMetrics::blockMaximumCharacterWidth | ( | int | blockIndex | ) | const |
Returns the maximum character width for the specified block.
Definition at line 714 of file qgstextdocumentmetrics.cpp.
double QgsTextDocumentMetrics::blockMaximumDescent | ( | int | blockIndex | ) | const |
Returns the maximum descent encountered in the specified block.
Definition at line 719 of file qgstextdocumentmetrics.cpp.
double QgsTextDocumentMetrics::blockWidth | ( | int | blockIndex | ) | const |
Returns the width of the block at the specified index.
Definition at line 650 of file qgstextdocumentmetrics.cpp.
|
static |
Returns precalculated text metrics for a text document, when rendered using the given base format and render context.
The optional scaleFactor parameter can specify a font size scaling factor. It is recommended to set this to QgsTextRenderer::calculateScaleFactorForFormat() and then manually calculations based on the resultant font metrics. Failure to do so will result in poor quality text rendering at small font sizes.
Since QGIS 3.40 the optional documentContext argument can be used to pass text renderer context to change the logistics of the calculated metrics.
Definition at line 492 of file qgstextdocumentmetrics.cpp.
|
inline |
Returns the document associated with the calculated metrics.
Note that this may not exactly match the original document which was used in the call to calculateMetrics(), as certain settings (such as text wrapping) require restructuring the document.
Definition at line 130 of file qgstextdocumentmetrics.h.
QSizeF QgsTextDocumentMetrics::documentSize | ( | Qgis::TextLayoutMode | mode, |
Qgis::TextOrientation | orientation | ||
) | const |
Returns the overall size of the document.
Definition at line 593 of file qgstextdocumentmetrics.cpp.
double QgsTextDocumentMetrics::firstLineCapHeight | ( | ) | const |
Returns the cap height for the first line of text.
Definition at line 660 of file qgstextdocumentmetrics.cpp.
double QgsTextDocumentMetrics::fragmentFixedHeight | ( | int | blockIndex, |
int | fragmentIndex, | ||
Qgis::TextLayoutMode | mode | ||
) | const |
Returns the fixed height of the fragment at the specified block and fragment index, or -1 if the fragment does not have a fixed height.
Definition at line 704 of file qgstextdocumentmetrics.cpp.
QFont QgsTextDocumentMetrics::fragmentFont | ( | int | blockIndex, |
int | fragmentIndex | ||
) | const |
Returns the calculated font for the fragment at the specified block and fragment indices.
Definition at line 724 of file qgstextdocumentmetrics.cpp.
double QgsTextDocumentMetrics::fragmentHorizontalAdvance | ( | int | blockIndex, |
int | fragmentIndex, | ||
Qgis::TextLayoutMode | mode | ||
) | const |
Returns the horizontal advance of the fragment at the specified block and fragment index.
Definition at line 683 of file qgstextdocumentmetrics.cpp.
double QgsTextDocumentMetrics::fragmentVerticalOffset | ( | int | blockIndex, |
int | fragmentIndex, | ||
Qgis::TextLayoutMode | mode | ||
) | const |
Returns the vertical offset from a text block's baseline which should be applied to the fragment at the specified index within that block.
Definition at line 688 of file qgstextdocumentmetrics.cpp.
|
inline |
Returns true
if the metrics could not be calculated because the text format has a null font size.
Definition at line 120 of file qgstextdocumentmetrics.h.
QRectF QgsTextDocumentMetrics::outerBounds | ( | Qgis::TextLayoutMode | mode, |
Qgis::TextOrientation | orientation | ||
) | const |
Returns the outer bounds of the document, which is the documentSize() adjusted to account for any text elements which fall outside of the usual document margins (such as super or sub script elements)
Definition at line 624 of file qgstextdocumentmetrics.cpp.
double QgsTextDocumentMetrics::verticalOrientationXOffset | ( | int | blockIndex | ) | const |
Returns the vertical orientation x offset for the specified block.
Definition at line 709 of file qgstextdocumentmetrics.cpp.