Class: QgsTextFragment¶
-
class
qgis.core.
QgsTextFragment
(text: str = '', format: QgsTextCharacterFormat = QgsTextCharacterFormat())¶ Bases:
sip.wrapper
Constructor for
QgsTextFragment
, with the specifiedtext
and optional characterformat
.QgsTextFragment(fragment: QTextFragment) Constructor for
QgsTextFragment
, based on the specified QTextFragmentfragment
.QgsTextFragment(
QgsTextFragment
)Stores a fragment of text along with formatting overrides to be used when rendering the fragment.
Warning
This API is not considered stable and may change in future QGIS versions.
New in version 3.14.
- Parameters
text (str = '') –
format –
-
characterFormat
(self) → QgsTextCharacterFormat¶ Returns the character formatting for the fragment.
See also
- Return type
-
horizontalAdvance
(self, font: QFont, fontHasBeenUpdatedForFragment: bool = False) → float¶ Returns the horizontal advance associated with this fragment, when rendered using the specified base
font
.Set
fontHasBeenUpdatedForFragment
toTrue
iffont
already represents the character format for this fragment.- Parameters
font (QFont) –
fontHasBeenUpdatedForFragment (bool = False) –
- Return type
float
-
setCharacterFormat
(self, format: QgsTextCharacterFormat)¶ Sets the character
format
for the fragment.See also
- Parameters
format (QgsTextCharacterFormat) –
-
setText
(self, text: str)¶ Sets the
text
content of the fragment.See also
- Parameters
text (str) –