QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
|
Stores a fragment of document along with formatting overrides to be used when rendering the fragment. More...
#include <qgstextfragment.h>
Public Member Functions | |
QgsTextFragment (const QString &text=QString(), const QgsTextCharacterFormat &format=QgsTextCharacterFormat()) | |
Constructor for QgsTextFragment, with the specified text and optional character format. | |
QgsTextFragment (const QTextFragment &fragment) | |
Constructor for QgsTextFragment, based on the specified QTextFragment fragment. | |
void | applyCapitalization (Qgis::Capitalization capitalization) |
Applies a capitalization style to the fragment's text. | |
const QgsTextCharacterFormat & | characterFormat () const |
Returns the character formatting for the fragment. | |
double | horizontalAdvance (const QFont &font, const QgsRenderContext &context, bool fontHasBeenUpdatedForFragment=false, double scaleFactor=1.0) const |
Returns the horizontal advance associated with this fragment, when rendered using the specified base font within the specified render context. | |
bool | isImage () const |
Returns true if the fragment represents an image. | |
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 to render. | |
void | setCharacterFormat (const QgsTextCharacterFormat &format) |
Sets the character format for the fragment. | |
void | setText (const QString &text) |
Sets the text content of the fragment. | |
QString | text () const |
Returns the text content of the fragment. | |
Stores a fragment of document along with formatting overrides to be used when rendering the fragment.
Text fragments consist of either a block of text or another atomic component of a document (such as an image).
Each fragment has an associated characterFormat(), which specifies the text formatting overrides to use when rendering the fragment. Additionally, the characterFormat() may contain properties for other fragment types, such as image paths and sizes for image fragments.
Definition at line 41 of file qgstextfragment.h.
|
explicit |
Constructor for QgsTextFragment, with the specified text and optional character format.
Definition at line 21 of file qgstextfragment.cpp.
|
explicit |
Constructor for QgsTextFragment, based on the specified QTextFragment fragment.
Definition at line 27 of file qgstextfragment.cpp.
void QgsTextFragment::applyCapitalization | ( | Qgis::Capitalization | capitalization | ) |
Applies a capitalization style to the fragment's text.
Definition at line 70 of file qgstextfragment.cpp.
|
inline |
Returns the character formatting for the fragment.
Definition at line 89 of file qgstextfragment.h.
double QgsTextFragment::horizontalAdvance | ( | const QFont & | font, |
const QgsRenderContext & | context, | ||
bool | fontHasBeenUpdatedForFragment = false , |
||
double | scaleFactor = 1.0 |
||
) | const |
Returns the horizontal advance associated with this fragment, when rendered using the specified base font within the specified render context.
Set fontHasBeenUpdatedForFragment to true
if font already represents the character format for this fragment.
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.
Definition at line 54 of file qgstextfragment.cpp.
bool QgsTextFragment::isImage | ( | ) | const |
Returns true
if the fragment represents an image.
Definition at line 49 of file qgstextfragment.cpp.
|
inline |
Returns true
if the fragment consists of just a tab character.
Definition at line 74 of file qgstextfragment.h.
|
inline |
Returns true
if the fragment consists of just whitespace characters, and does not contain any content to render.
Definition at line 82 of file qgstextfragment.h.
void QgsTextFragment::setCharacterFormat | ( | const QgsTextCharacterFormat & | format | ) |
Sets the character format for the fragment.
Definition at line 44 of file qgstextfragment.cpp.
void QgsTextFragment::setText | ( | const QString & | text | ) |
Sets the text content of the fragment.
Definition at line 39 of file qgstextfragment.cpp.
QString QgsTextFragment::text | ( | ) | const |
Returns the text content of the fragment.
Definition at line 34 of file qgstextfragment.cpp.