Class: QgsTextCharacterFormat¶
- class qgis.core.QgsTextCharacterFormat¶
Bases:
sip.wrapper
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.
QgsTextCharacterFormat() Constructor for QgsTextCharacterFormat.
QgsTextCharacterFormat(format: QTextCharFormat) Constructor for
QgsTextCharacterFormat
, based on the specified QTextCharFormatformat
.QgsTextCharacterFormat(
QgsTextCharacterFormat
)Enums
Bases:
enum.IntEnum
Methods
Returns the font family name, or an empty string if the family is not set and should be inherited.
Returns the font point size, or -1 if the font size is not set and should be inherited.
Returns the font weight, or -1 if the font weight is not set and should be inherited.
Returns
True
if the format has an explicit vertical alignment set.Returns whether the format has italic enabled.
Returns whether the format has overline enabled.
Override all the default/unset properties of the current character format with the settings from another format.
Sets the font
family
name.Sets the font point
size
.Sets the font
weight
.Sets whether the format has an explicit vertical alignment
set
.Sets whether the format has italic
enabled
.Sets whether the format has overline
enabled
.Sets whether the format has strikethrough
enabled
.Sets the character's text
color
.Sets whether the format has underline
enabled
.Sets the format vertical
alignment
.Returns whether the format has strikethrough enabled.
Returns the character's text color, or an invalid color if no color override is set and the default format color should be used.
Returns whether the format has underline enabled.
Updates the specified
font
in place, applying character formatting options which are applicable on a font level when rendered in the givencontext
.Returns the format vertical alignment.
- class BooleanValue(value)¶
Bases:
enum.IntEnum
Status values for boolean format properties
NotSet
: Property is not setSetTrue
: Property is set andTrue
SetFalse
: Property is set andFalse
- NotSet = 0¶
- SetFalse = 2¶
- SetTrue = 1¶
- family(self) str ¶
Returns the font family name, or an empty string if the family is not set and should be inherited.
See also
New in version 3.28.
- Return type:
str
- fontPointSize(self) float ¶
Returns the font point size, or -1 if the font size is not set and should be inherited.
See also
New in version 3.28.
- Return type:
float
- fontWeight(self) int ¶
Returns the font weight, or -1 if the font weight is not set and should be inherited.
See also
New in version 3.28.
- Return type:
int
- hasVerticalAlignmentSet(self) bool ¶
Returns
True
if the format has an explicit vertical alignment set.If
False
is returned then the vertical alignment will be inherited.See also
See also
New in version 3.30.
- Return type:
bool
- italic(self) QgsTextCharacterFormat.BooleanValue ¶
Returns whether the format has italic enabled.
See also
New in version 3.28.
- Return type:
- overline(self) QgsTextCharacterFormat.BooleanValue ¶
Returns whether the format has overline enabled.
See also
- Return type:
- overrideWith(self, other: QgsTextCharacterFormat)¶
Override all the default/unset properties of the current character format with the settings from another format.
This will replace any default/unset existing settings with the settings from
other
.Any settings which are default/unset in
other
will be left unchanged.- Parameters:
other (QgsTextCharacterFormat) – The format to override with.
New in version 3.36.
- setFamily(self, family: str)¶
Sets the font
family
name.Set to an empty string if the family should be inherited.
See also
New in version 3.28.
- Parameters:
family (str) –
- setFontPointSize(self, size: float)¶
Sets the font point
size
.Set
size
to -1 if the font size is not set and should be inherited.See also
New in version 3.28.
- Parameters:
size (float) –
- setFontWeight(self, fontWeight: int)¶
Sets the font
weight
.Set
weight
to -1 if the font weight is not set and should be inherited.See also
New in version 3.28.
- Parameters:
fontWeight (int) –
- setHasVerticalAlignmentSet(self, set: bool)¶
Sets whether the format has an explicit vertical alignment
set
.If
set
isFalse
then the vertical alignment will be inherited.See also
See also
New in version 3.30.
- Parameters:
set (bool) –
- setItalic(self, enabled: QgsTextCharacterFormat.BooleanValue)¶
Sets whether the format has italic
enabled
.See also
New in version 3.28.
- Parameters:
enabled (QgsTextCharacterFormat.BooleanValue) –
- setOverline(self, enabled: QgsTextCharacterFormat.BooleanValue)¶
Sets whether the format has overline
enabled
.See also
- Parameters:
enabled (QgsTextCharacterFormat.BooleanValue) –
- setStrikeOut(self, enabled: QgsTextCharacterFormat.BooleanValue)¶
Sets whether the format has strikethrough
enabled
.See also
- Parameters:
enabled (QgsTextCharacterFormat.BooleanValue) –
- setTextColor(self, textColor: 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
- Parameters:
textColor (Union[QColor) –
- setUnderline(self, enabled: QgsTextCharacterFormat.BooleanValue)¶
Sets whether the format has underline
enabled
.See also
- Parameters:
enabled (QgsTextCharacterFormat.BooleanValue) –
- setVerticalAlignment(self, alignment: Qgis.TextCharacterVerticalAlignment)¶
Sets the format vertical
alignment
.This property is only respected if
hasVerticalAlignmentSet()
isTrue
.See also
See also
New in version 3.30.
- Parameters:
alignment (Qgis.TextCharacterVerticalAlignment) –
- strikeOut(self) QgsTextCharacterFormat.BooleanValue ¶
Returns whether the format has strikethrough enabled.
See also
- Return type:
- 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
- Return type:
QColor
- underline(self) QgsTextCharacterFormat.BooleanValue ¶
Returns whether the format has underline enabled.
See also
- Return type:
- updateFontForFormat(self, font: QFont, context: QgsRenderContext, scaleFactor: float = 1)¶
Updates the specified
font
in place, applying character formatting options which are applicable on a font level when rendered in the givencontext
.The optional
scaleFactor
parameter can specify a font size scaling factor. It is recommended to set this toQgsTextRenderer
.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) –
context (QgsRenderContext) –
scaleFactor (float = 1) –
- verticalAlignment(self) Qgis.TextCharacterVerticalAlignment ¶
Returns the format vertical alignment.
This property is only respected if
hasVerticalAlignmentSet()
isTrue
.See also
See also
New in version 3.30.
- Return type: