Class: QgsTextCharacterFormat

class qgis.core.QgsTextCharacterFormat

Bases: sip.wrapper

Constructor for QgsTextCharacterFormat.

QgsTextCharacterFormat(format: QTextCharFormat) Constructor for QgsTextCharacterFormat, based on the specified QTextCharFormat format.

QgsTextCharacterFormat(QgsTextCharacterFormat)

Stores information relating to individual character formatting.

These options encapsulate formatting options which override the default settings from a QgsTextFormat for individual characters (or sets of characters).

Warning

This API is not considered stable and may change in future QGIS versions.

New in version 3.14: Enums

BooleanValue

Bases: enum.IntEnum

Methods

overline

Returns whether the format has overline enabled.

setOverline

Sets whether the format has overline enabled.

setStrikeOut

Sets whether the format has strikethrough enabled.

setTextColor

Sets the character’s text color.

setUnderline

Sets whether the format has underline enabled.

strikeOut

Returns whether the format has strikethrough enabled.

textColor

Returns the character’s text color, or an invalid color if no color override is set and the default format color should be used.

underline

Returns whether the format has underline enabled.

updateFontForFormat

Updates the specified font in place, applying character formatting options which are applicable on a font level.

class BooleanValue(value)

Bases: enum.IntEnum

Status values for boolean format properties

  • NotSet: Property is not set

  • SetTrue: Property is set and True

  • SetFalse: Property is set and False

NotSet = 0
SetFalse = 2
SetTrue = 1
overline(self)QgsTextCharacterFormat.BooleanValue

Returns whether the format has overline enabled.

See also

setUnderline()

Return type

QgsTextCharacterFormat.BooleanValue

setOverline(self, enabled: QgsTextCharacterFormat.BooleanValue)

Sets whether the format has overline enabled.

See also

overline()

Parameters

enabled (QgsTextCharacterFormat.BooleanValue) –

setStrikeOut(self, enabled: QgsTextCharacterFormat.BooleanValue)

Sets whether the format has strikethrough enabled.

See also

strikeOut()

Parameters

enabled (QgsTextCharacterFormat.BooleanValue) –

setTextColor(self, textColor: Union[QColor, Qt.GlobalColor])

Sets the character’s text color.

Set color to an invalid color if no color override is desired and the default format color should be used.

See also

textColor()

Parameters

textColor (Union[QColor) –

setUnderline(self, enabled: QgsTextCharacterFormat.BooleanValue)

Sets whether the format has underline enabled.

See also

underline()

Parameters

enabled (QgsTextCharacterFormat.BooleanValue) –

strikeOut(self)QgsTextCharacterFormat.BooleanValue

Returns whether the format has strikethrough enabled.

See also

setStrikeOut()

Return type

QgsTextCharacterFormat.BooleanValue

textColor(self)QColor

Returns the character’s text color, or an invalid color if no color override is set and the default format color should be used.

See also

setTextColor()

Return type

QColor

underline(self)QgsTextCharacterFormat.BooleanValue

Returns whether the format has underline enabled.

See also

setUnderline()

Return type

QgsTextCharacterFormat.BooleanValue

updateFontForFormat(self, font: QFont, scaleFactor: float = 1)

Updates the specified font in place, applying character formatting options which are applicable on a font level.

The optional scaleFactor parameter can specify a font size scaling factor. It is recommended to set this to QgsTextRenderer.FONT_WORKAROUND_SCALE 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.

Parameters
  • font (QFont) –

  • scaleFactor (float = 1) –