Gimp.TextLayer

g GObject.Object GObject.Object Gimp.Item Gimp.Item GObject.Object->Gimp.Item Gimp.Drawable Gimp.Drawable Gimp.Layer Gimp.Layer Gimp.Drawable->Gimp.Layer Gimp.Item->Gimp.Drawable Gimp.TextLayer Gimp.TextLayer Gimp.Layer->Gimp.TextLayer

Subclasses:

None

Methods

Inherited:

Gimp.Layer (37), Gimp.Drawable (55), Gimp.Item (55), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

get_by_id (layer_id)

class

new (image, text, font, size, unit)

get_antialias ()

get_base_direction ()

get_color ()

get_font ()

get_font_size ()

get_hint_style ()

get_indent ()

get_justification ()

get_kerning ()

get_language ()

get_letter_spacing ()

get_line_spacing ()

get_markup ()

get_text ()

resize (width, height)

set_antialias (antialias)

set_base_direction (direction)

set_color (color)

set_font (font)

set_font_size (font_size, unit)

set_hint_style (style)

set_indent (indent)

set_justification (justify)

set_kerning (kerning)

set_language (language)

set_letter_spacing (letter_spacing)

set_line_spacing (line_spacing)

set_markup (markup)

set_text (text)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Inherited:

Gimp.Item (1)

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gimp.TextLayer(**kwargs)
Bases:

Gimp.Layer

Abstract:

No

Structure:

Gimp.TextLayerClass

Functions for querying and manipulating text layers.

classmethod get_by_id(layer_id)
Parameters:

layer_id (int) – The layer id.

Returns:

a Gimp.TextLayer for layer_id or None if layer_id does not represent a valid layer. The object belongs to libgimp and you must not modify or unref it.

Return type:

Gimp.TextLayer or None

Returns a Gimp.TextLayer representing layer_id. This function calls Gimp.Item.get_by_id() and returns the item if it is layer or None otherwise.

New in version 3.0.

classmethod new(image, text, font, size, unit)
Parameters:
  • image (Gimp.Image) – The image.

  • text (str) – The text to generate (in UTF-8 encoding).

  • font (Gimp.Font) – The font to write the text with.

  • size (float) – The size of text in either pixels or points.

  • unit (Gimp.Unit) – The units of specified size.

Returns:

The new text layer. The object belongs to libgimp and you should not free it.

Return type:

Gimp.TextLayer

Creates a new text layer.

This procedure creates a new text layer displaying the specified text. By default the width and height of the layer will be determined by the text contents, the font, size and unit.

The new layer still needs to be added to the image as this is not automatic. Add the new layer with the [method`Image`.insert_layer] method.

The arguments are kept as simple as necessary for the basic case. All text attributes, however, can be modified with the appropriate gimp_text_layer_set_*() procedures.

New in version 2.6.

get_antialias()
Returns:

A flag which is true if antialiasing is used for rendering the font in the text layer.

Return type:

bool

Check if antialiasing is used in the text layer.

This procedure checks if antialiasing is enabled in the specified text layer.

New in version 2.6.

get_base_direction()
Returns:

The based direction used for the text layer.

Return type:

Gimp.TextDirection

Get the base direction used for rendering the text layer.

This procedure returns the base direction used for rendering the text in the text layer

New in version 2.6.

get_color()
Returns:

The color of the text.

Return type:

Gegl.Color

Get the color of the text in a text layer.

This procedure returns the color of the text in a text layer.

New in version 2.6.

get_font()
Returns:

The font which is used in the specified text layer.

Return type:

Gimp.Font

Get the font from a text layer as string.

This procedure returns the font from a text layer.

New in version 2.6.

get_font_size()
Returns:

The font size.

unit:

The unit used for the font size.

Return type:

(float, unit: Gimp.Unit)

Get the font size from a text layer.

This procedure returns the size of the font which is used in a text layer. You will receive the size as a double ‘font-size’ in ‘unit’ units.

New in version 2.6.

get_hint_style()
Returns:

The hint style used for font outlines.

Return type:

Gimp.TextHintStyle

Get information about hinting in the specified text layer.

This procedure provides information about the hinting that is being used in a text layer. Hinting can be optimized for fidelity or contrast or it can be turned entirely off.

New in version 2.8.

get_indent()
Returns:

The indentation value of the first line.

Return type:

float

Get the line indentation of text layer.

This procedure returns the indentation of the first line in a text layer.

New in version 2.6.

get_justification()
Returns:

The justification used in the text layer.

Return type:

Gimp.TextJustification

Get the text justification information of the text layer.

This procedure returns the alignment of the lines in the text layer relative to each other.

New in version 2.6.

get_kerning()
Returns:

A flag which is true if kerning is used in the text layer.

Return type:

bool

Check if kerning is used in the text layer.

This procedure checks if kerning is enabled in the specified text layer.

New in version 2.6.

get_language()
Returns:

The language used in the text layer. The returned value must be freed with GLib.free().

Return type:

str

Get the language used in the text layer.

This procedure returns the language string which is set for the text in the text layer.

New in version 2.6.

get_letter_spacing()
Returns:

The letter-spacing value.

Return type:

float

Get the letter spacing used in a text layer.

This procedure returns the additional spacing between the single glyphs in a text layer.

New in version 2.6.

get_line_spacing()
Returns:

The line-spacing value.

Return type:

float

Get the spacing between lines of text.

This procedure returns the line-spacing between lines of text in a text layer.

New in version 2.6.

get_markup()
Returns:

The markup which represents the style of the specified text layer. The returned value must be freed with GLib.free().

Return type:

str

Get the markup from a text layer as string.

This procedure returns the markup of the styles from a text layer. The markup will be in the form of Pango’s markup - See https://www.pango.org/ for more information about Pango and its markup.

New in version 2.8.

get_text()
Returns:

The text from the specified text layer. The returned value must be freed with GLib.free().

Return type:

str

Get the text from a text layer as string.

This procedure returns the text from a text layer as a string.

New in version 2.6.

resize(width, height)
Parameters:
  • width (float) – The new box width in pixels.

  • height (float) – The new box height in pixels.

Returns:

True on success.

Return type:

bool

Resize the box of a text layer.

This procedure changes the width and height of a text layer while keeping it as a text layer and not converting it to a bitmap like Gimp.Layer.resize() would do.

New in version 2.8.

set_antialias(antialias)
Parameters:

antialias (bool) – Enable/disable antialiasing of the text.

Returns:

True on success.

Return type:

bool

Enable/disable anti-aliasing in a text layer.

This procedure enables or disables anti-aliasing of the text in a text layer.

New in version 2.6.

set_base_direction(direction)
Parameters:

direction (Gimp.TextDirection) – The base direction of the text.

Returns:

True on success.

Return type:

bool

Set the base direction in the text layer.

This procedure sets the base direction used in applying the Unicode bidirectional algorithm when rendering the text.

New in version 2.6.

set_color(color)
Parameters:

color (Gegl.Color) – The color to use for the text.

Returns:

True on success.

Return type:

bool

Set the color of the text in the text layer.

This procedure sets the text color in the text layer ‘layer’.

New in version 2.6.

set_font(font)
Parameters:

font (Gimp.Font) – The new font to use.

Returns:

True on success.

Return type:

bool

Set the font of a text layer.

This procedure modifies the font used in the specified text layer.

New in version 2.6.

set_font_size(font_size, unit)
Parameters:
  • font_size (float) – The font size.

  • unit (Gimp.Unit) – The unit to use for the font size.

Returns:

True on success.

Return type:

bool

Set the font size.

This procedure changes the font size of a text layer. The size of your font will be a double ‘font-size’ of ‘unit’ units.

New in version 2.6.

set_hint_style(style)
Parameters:

style (Gimp.TextHintStyle) – The new hint style.

Returns:

True on success.

Return type:

bool

Control how font outlines are hinted in a text layer.

This procedure sets the hint style for font outlines in a text layer. This controls whether to fit font outlines to the pixel grid, and if so, whether to optimize for fidelity or contrast.

New in version 2.8.

set_indent(indent)
Parameters:

indent (float) – The indentation for the first line.

Returns:

True on success.

Return type:

bool

Set the indentation of the first line in a text layer.

This procedure sets the indentation of the first line in the text layer.

New in version 2.6.

set_justification(justify)
Parameters:

justify (Gimp.TextJustification) – The justification for your text.

Returns:

True on success.

Return type:

bool

Set the justification of the text in a text layer.

This procedure sets the alignment of the lines in the text layer relative to each other.

New in version 2.6.

set_kerning(kerning)
Parameters:

kerning (bool) – Enable/disable kerning in the text.

Returns:

True on success.

Return type:

bool

Enable/disable kerning in a text layer.

This procedure enables or disables kerning in a text layer.

New in version 2.6.

set_language(language)
Parameters:

language (str) – The new language to use for the text layer.

Returns:

True on success.

Return type:

bool

Set the language of the text layer.

This procedure sets the language of the text in text layer. For some scripts the language has an influence of how the text is rendered.

New in version 2.6.

set_letter_spacing(letter_spacing)
Parameters:

letter_spacing (float) – The additional letter spacing to use.

Returns:

True on success.

Return type:

bool

Adjust the letter spacing in a text layer.

This procedure sets the additional spacing between the single glyphs in a text layer.

New in version 2.6.

set_line_spacing(line_spacing)
Parameters:

line_spacing (float) – The additional line spacing to use.

Returns:

True on success.

Return type:

bool

Adjust the line spacing in a text layer.

This procedure sets the additional spacing used between lines a text layer.

New in version 2.6.

set_markup(markup)
Parameters:

markup (str) – The new markup to set.

Returns:

True on success.

Return type:

bool

Set the markup for a text layer from a string.

This procedure sets the markup of the styles for a text layer. The markup should be in the form of Pango’s markup - See https://docs.gtk.org/Pango/pango_markup.html for a reference. Note that GIMP’s text tool does not support all of Pango markup. Any unsupported markup will still be applied to your text layer, yet would be dropped as soon as you edit text with the tool.

New in version 3.0.

set_text(text)
Parameters:

text (str) – The new text to set.

Returns:

True on success.

Return type:

bool

Set the text of a text layer.

This procedure changes the text of a text layer.

New in version 2.6.