TextTag
Superclasses: Object
A tag that can be applied to text contained in a GtkTextBuffer
.
You may wish to begin by reading the text widget conceptual overview, which gives an overview of all the objects and data types related to the text widget and how they work together.
Tags should be in the TextTagTable
for a given
GtkTextBuffer
before using them with that buffer.
create_tag
is the best way to create tags.
See “gtk4-demo” for numerous examples.
For each property of GtkTextTag
, there is a “set” property, e.g.
“font-set” corresponds to “font”. These “set” properties reflect
whether a property has been set or not.
They are maintained by GTK and you should not set them independently.
Constructors
Methods
- class TextTag
- changed(size_changed: bool) None
Emits the
tag_changed
signal on theGtkTextTagTable
where the tag is included.The signal is already emitted when setting a
GtkTextTag
property. This function is useful for aGtkTextTag
subclass.- Parameters:
size_changed – whether the change affects the
GtkTextView
layout
- set_priority(priority: int) None
Sets the priority of a
GtkTextTag
.Valid priorities start at 0 and go to one less than
get_size
. Each tag in a table has a unique priority; setting the priority of one tag shifts the priorities of all the other tags in the table to maintain a unique priority for each tag.Higher priority tags “win” if two tags both set the same text attribute. When adding a tag to a tag table, it will be assigned the highest priority in the table by default; so normally the precedence of a set of tags is the order in which they were added to the table, or created with
create_tag
, which adds the tag to the buffer’s table automatically.- Parameters:
priority – the new priority
Properties
- class TextTag
- props.accumulative_margin: bool
Whether the margins accumulate or override each other.
When set to
True
the margins of this tag are added to the margins of any other non-accumulative margins present. When set toFalse
the margins override one another (the default).
- props.background_full_height: bool
Whether the background color fills the entire line height or only the height of the tagged characters.
- props.direction: TextDirection
Text direction, e.g. right-to-left or left-to-right.
- props.fallback: bool
Whether font fallback is enabled.
When set to
True
, other fonts will be substituted where the current font is missing glyphs.
- props.font: str
Font description as string, e.g. "Sans Italic 12".
Note that the initial value of this property depends on the internals of
PangoFontDescription
.
- props.font_desc: FontDescription
Font description as a
PangoFontDescription
.
- props.indent: int
Amount to indent the paragraph, in pixels.
A negative value of indent will produce a hanging indentation. That is, the first line will have the full width, and subsequent lines will be indented by the absolute value of indent.
- props.invisible: bool
Whether this text is hidden.
Note that there may still be problems with the support for invisible text, in particular when navigating programmatically inside a buffer containing invisible segments.
- props.justification: Justification
Left, right, or center justification.
- props.language: str
The language this text is in, as an ISO code.
Pango can use this as a hint when rendering the text. If not set, an appropriate default will be used.
Note that the initial value of this property depends on the current locale, see also
get_default_language
.
- props.overline_rgba: RGBA
This property modifies the color of overlines.
If not set, overlines will use the foreground color.
- props.rise: int
Offset of text above the baseline, in Pango units.
Negative values go below the baseline.
- props.scale: float
Font size as a scale factor relative to the default font size.
This properly adapts to theme changes, etc. so is recommended. Pango predefines some scales such as
%PANGO_SCALE_X_LARGE
.
- props.sentence: bool
Whether this tag represents a single sentence.
This affects cursor movement.
Added in version 4.6.
- props.strikethrough_rgba: RGBA
This property modifies the color of strikeouts.
If not set, strikeouts will use the foreground color.
- props.text_transform: TextTransform
How to transform the text for display.
Added in version 4.6.
- props.underline_rgba: RGBA
This property modifies the color of underlines.
If not set, underlines will use the foreground color.
If
underline
is set to%PANGO_UNDERLINE_ERROR
, an alternate color may be applied instead of the foreground. Setting this property will always override those defaults.
- props.word: bool
Whether this tag represents a single word.
This affects line breaks and cursor movement.
Added in version 4.6.