/* PIKA - Photo and Image Kooker Application
 * a rebranding of The GNU Image Manipulation Program (created with heckimp)
 * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
 *
 * Original copyright, applying to most contents (license remains unchanged): 
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

/* NOTE: This file is auto-generated by pdbgen.pl. */

#include "config.h"

#include "stamp-pdbgen.h"

#include <cairo.h>
#include <pango/pango.h>

#include <gegl.h>

#include <gdk-pixbuf/gdk-pixbuf.h>

#include "libpikabase/pikabase.h"
#include "libpikacolor/pikacolor.h"

#include "libpikabase/pikabase.h"

#include "pdb-types.h"

#include "core/pikacontext.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"
#include "text/pikafont.h"
#include "text/pikatext.h"
#include "text/pikatextlayer.h"

#include "pikapdb.h"
#include "pikapdberror.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"

#include "pika-intl.h"


static PikaValueArray *
text_layer_new_invoker (PikaProcedure         *procedure,
                        Pika                  *pika,
                        PikaContext           *context,
                        PikaProgress          *progress,
                        const PikaValueArray  *args,
                        GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  const gchar *text;
  PikaFont *font;
  gdouble size;
  PikaUnit unit;
  PikaTextLayer *layer = NULL;

  image = g_value_get_object (pika_value_array_index (args, 0));
  text = g_value_get_string (pika_value_array_index (args, 1));
  font = g_value_get_object (pika_value_array_index (args, 2));
  size = g_value_get_double (pika_value_array_index (args, 3));
  unit = g_value_get_int (pika_value_array_index (args, 4));

  if (success)
    {
      PikaText *pika_text;
      PikaRGB   color;

      pika_context_get_foreground (context, &color);

      pika_text = g_object_new (PIKA_TYPE_TEXT,
                                "text",           text,
                                "font",           font,
                                "font-size",      size,
                                "font-size-unit", unit,
                                "color",          &color,
                                NULL);

      layer = PIKA_TEXT_LAYER (pika_text_layer_new (image, pika_text));
      g_object_unref (pika_text);

      if (! layer)
        {
          g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
                       _("Failed to create text layer"));

          success = FALSE;
        }
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_object (pika_value_array_index (return_vals, 1), layer);

  return return_vals;
}

static PikaValueArray *
text_layer_get_text_invoker (PikaProcedure         *procedure,
                             Pika                  *pika,
                             PikaContext           *context,
                             PikaProgress          *progress,
                             const PikaValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gchar *text = NULL;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "text", &text,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (pika_value_array_index (return_vals, 1), text);

  return return_vals;
}

static PikaValueArray *
text_layer_set_text_invoker (PikaProcedure         *procedure,
                             Pika                  *pika,
                             PikaContext           *context,
                             PikaProgress          *progress,
                             const PikaValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  const gchar *text;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  text = g_value_get_string (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "text", text,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_markup_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gchar *markup = NULL;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "markup", &markup,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (pika_value_array_index (return_vals, 1), markup);

  return return_vals;
}

static PikaValueArray *
text_layer_set_markup_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  const gchar *markup;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  markup = g_value_get_string (pika_value_array_index (args, 1));

  if (success)
    {
      gchar *markup_cat = NULL;
      const gchar *markup_ptr = markup;

      if (strstr(markup, "<markup>") == NULL || strstr(markup, "</markup>") == NULL)
        {
          markup_cat = g_strconcat("<markup>", markup, "</markup>", NULL);
          markup_ptr = markup_cat;
        }

      if (pango_parse_markup (markup_ptr, -1, 0, NULL, NULL, NULL, error))
        {
          pika_text_layer_set (layer,
                               _("Set text layer markup"),
                               "markup", markup_ptr,
                               NULL);
        }
      else
        {
          success = FALSE;
        }

      g_free(markup_cat);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_font_invoker (PikaProcedure         *procedure,
                             Pika                  *pika,
                             PikaContext           *context,
                             PikaProgress          *progress,
                             const PikaValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  PikaFont *font = NULL;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "font", &font,
                    NULL);
      /* The PikaText keeps a reference. Therefore unref before returning the
       * pointer so that we don't leak a reference.
       */
      g_object_unref (font);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_object (pika_value_array_index (return_vals, 1), font);

  return return_vals;
}

static PikaValueArray *
text_layer_set_font_invoker (PikaProcedure         *procedure,
                             Pika                  *pika,
                             PikaContext           *context,
                             PikaProgress          *progress,
                             const PikaValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  PikaFont *font;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  font = g_value_get_object (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "font", font,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_font_size_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gdouble font_size = 0.0;
  PikaUnit unit = PIKA_UNIT_PIXEL;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
       g_object_get (pika_text_layer_get_text (layer),
                     "font-size",      &font_size,
                     "font-size-unit", &unit,
                     NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_double (pika_value_array_index (return_vals, 1), font_size);
      g_value_set_int (pika_value_array_index (return_vals, 2), unit);
    }

  return return_vals;
}

static PikaValueArray *
text_layer_set_font_size_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gdouble font_size;
  PikaUnit unit;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  font_size = g_value_get_double (pika_value_array_index (args, 1));
  unit = g_value_get_int (pika_value_array_index (args, 2));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "font-size-unit", unit,
                           "font-size",      font_size,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_antialias_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gboolean antialias = FALSE;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "antialias", &antialias,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), antialias);

  return return_vals;
}

static PikaValueArray *
text_layer_set_antialias_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gboolean antialias;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  antialias = g_value_get_boolean (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "antialias", antialias,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_hint_style_invoker (PikaProcedure         *procedure,
                                   Pika                  *pika,
                                   PikaContext           *context,
                                   PikaProgress          *progress,
                                   const PikaValueArray  *args,
                                   GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gint style = 0;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "hint-style", &style,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_enum (pika_value_array_index (return_vals, 1), style);

  return return_vals;
}

static PikaValueArray *
text_layer_set_hint_style_invoker (PikaProcedure         *procedure,
                                   Pika                  *pika,
                                   PikaContext           *context,
                                   PikaProgress          *progress,
                                   const PikaValueArray  *args,
                                   GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gint style;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  style = g_value_get_enum (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "hint-style", style,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_kerning_invoker (PikaProcedure         *procedure,
                                Pika                  *pika,
                                PikaContext           *context,
                                PikaProgress          *progress,
                                const PikaValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gboolean kerning = FALSE;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "kerning", &kerning,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), kerning);

  return return_vals;
}

static PikaValueArray *
text_layer_set_kerning_invoker (PikaProcedure         *procedure,
                                Pika                  *pika,
                                PikaContext           *context,
                                PikaProgress          *progress,
                                const PikaValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gboolean kerning;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  kerning = g_value_get_boolean (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "kerning", kerning,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_language_invoker (PikaProcedure         *procedure,
                                 Pika                  *pika,
                                 PikaContext           *context,
                                 PikaProgress          *progress,
                                 const PikaValueArray  *args,
                                 GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gchar *language = NULL;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "language", &language,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (pika_value_array_index (return_vals, 1), language);

  return return_vals;
}

static PikaValueArray *
text_layer_set_language_invoker (PikaProcedure         *procedure,
                                 Pika                  *pika,
                                 PikaContext           *context,
                                 PikaProgress          *progress,
                                 const PikaValueArray  *args,
                                 GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  const gchar *language;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  language = g_value_get_string (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "language", language,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_base_direction_invoker (PikaProcedure         *procedure,
                                       Pika                  *pika,
                                       PikaContext           *context,
                                       PikaProgress          *progress,
                                       const PikaValueArray  *args,
                                       GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gint direction = 0;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "base-direction", &direction,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_enum (pika_value_array_index (return_vals, 1), direction);

  return return_vals;
}

static PikaValueArray *
text_layer_set_base_direction_invoker (PikaProcedure         *procedure,
                                       Pika                  *pika,
                                       PikaContext           *context,
                                       PikaProgress          *progress,
                                       const PikaValueArray  *args,
                                       GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gint direction;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  direction = g_value_get_enum (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "base-direction", direction,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_justification_invoker (PikaProcedure         *procedure,
                                      Pika                  *pika,
                                      PikaContext           *context,
                                      PikaProgress          *progress,
                                      const PikaValueArray  *args,
                                      GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gint justify = 0;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "justify", &justify,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_enum (pika_value_array_index (return_vals, 1), justify);

  return return_vals;
}

static PikaValueArray *
text_layer_set_justification_invoker (PikaProcedure         *procedure,
                                      Pika                  *pika,
                                      PikaContext           *context,
                                      PikaProgress          *progress,
                                      const PikaValueArray  *args,
                                      GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gint justify;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  justify = g_value_get_enum (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "justify", justify,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_color_invoker (PikaProcedure         *procedure,
                              Pika                  *pika,
                              PikaContext           *context,
                              PikaProgress          *progress,
                              const PikaValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  PikaRGB color = { 0.0, 0.0, 0.0, 1.0 };

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      color = pika_text_layer_get_text (layer)->color;
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    pika_value_set_rgb (pika_value_array_index (return_vals, 1), &color);

  return return_vals;
}

static PikaValueArray *
text_layer_set_color_invoker (PikaProcedure         *procedure,
                              Pika                  *pika,
                              PikaContext           *context,
                              PikaProgress          *progress,
                              const PikaValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  PikaRGB color;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  pika_value_get_rgb (pika_value_array_index (args, 1), &color);

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "color", &color,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_indent_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gdouble indent = 0.0;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "indent", &indent,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_double (pika_value_array_index (return_vals, 1), indent);

  return return_vals;
}

static PikaValueArray *
text_layer_set_indent_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gdouble indent;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  indent = g_value_get_double (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "indent", indent,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_line_spacing_invoker (PikaProcedure         *procedure,
                                     Pika                  *pika,
                                     PikaContext           *context,
                                     PikaProgress          *progress,
                                     const PikaValueArray  *args,
                                     GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gdouble line_spacing = 0.0;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "line-spacing", &line_spacing,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_double (pika_value_array_index (return_vals, 1), line_spacing);

  return return_vals;
}

static PikaValueArray *
text_layer_set_line_spacing_invoker (PikaProcedure         *procedure,
                                     Pika                  *pika,
                                     PikaContext           *context,
                                     PikaProgress          *progress,
                                     const PikaValueArray  *args,
                                     GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gdouble line_spacing;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  line_spacing = g_value_get_double (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "line-spacing", line_spacing,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_get_letter_spacing_invoker (PikaProcedure         *procedure,
                                       Pika                  *pika,
                                       PikaContext           *context,
                                       PikaProgress          *progress,
                                       const PikaValueArray  *args,
                                       GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaTextLayer *layer;
  gdouble letter_spacing = 0.0;

  layer = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      g_object_get (pika_text_layer_get_text (layer),
                    "letter-spacing", &letter_spacing,
                    NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_double (pika_value_array_index (return_vals, 1), letter_spacing);

  return return_vals;
}

static PikaValueArray *
text_layer_set_letter_spacing_invoker (PikaProcedure         *procedure,
                                       Pika                  *pika,
                                       PikaContext           *context,
                                       PikaProgress          *progress,
                                       const PikaValueArray  *args,
                                       GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gdouble letter_spacing;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  letter_spacing = g_value_get_double (pika_value_array_index (args, 1));

  if (success)
    {
      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "letter-spacing", letter_spacing,
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
text_layer_resize_invoker (PikaProcedure         *procedure,
                           Pika                  *pika,
                           PikaContext           *context,
                           PikaProgress          *progress,
                           const PikaValueArray  *args,
                           GError               **error)
{
  gboolean success = TRUE;
  PikaTextLayer *layer;
  gdouble width;
  gdouble height;

  layer = g_value_get_object (pika_value_array_index (args, 0));
  width = g_value_get_double (pika_value_array_index (args, 1));
  height = g_value_get_double (pika_value_array_index (args, 2));

  if (success)
    {
      PikaText *text = pika_text_layer_get_text (layer);
      gdouble   xres, yres;

      pika_image_get_resolution (pika_item_get_image (PIKA_ITEM (layer)),
                                 &xres, &yres);

      pika_text_layer_set (layer,
                           _("Set text layer attribute"),
                           "box-mode",   PIKA_TEXT_BOX_FIXED,
                           "box-width",  pika_pixels_to_units (width,
                                                               text->box_unit,
                                                               xres),
                           "box-height", pika_pixels_to_units (height,
                                                               text->box_unit,
                                                               yres),
                           NULL);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

void
register_text_layer_procs (PikaPDB *pdb)
{
  PikaProcedure *procedure;

  /*
   * pika-text-layer-new
   */
  procedure = pika_procedure_new (text_layer_new_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-new");
  pika_procedure_set_static_help (procedure,
                                  "Creates a new text layer.",
                                  "This procedure creates a new text layer. The arguments are kept as simple as necessary for the normal case. All text attributes, however, can be modified with the appropriate pika_text_layer_set_*() procedures. The new layer still needs to be added to the image, as this is not automatic. Add the new layer using 'pika-image-insert-layer'.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("text",
                                                       "text",
                                                       "The text to generate (in UTF-8 encoding)",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_font ("font",
                                                     "font",
                                                     "The font to write the text with",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("size",
                                                    "size",
                                                    "The size of text in either pixels or points",
                                                    0.0, 8192.0, 0.0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_unit ("unit",
                                                     "unit",
                                                     "The units of specified size",
                                                     TRUE,
                                                     FALSE,
                                                     PIKA_UNIT_PIXEL,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_text_layer ("layer",
                                                               "layer",
                                                               "The new text layer.",
                                                               FALSE,
                                                               PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-text
   */
  procedure = pika_procedure_new (text_layer_get_text_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-text");
  pika_procedure_set_static_help (procedure,
                                  "Get the text from a text layer as string.",
                                  "This procedure returns the text from a text layer as a string.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_string ("text",
                                                           "text",
                                                           "The text from the specified text layer.",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-text
   */
  procedure = pika_procedure_new (text_layer_set_text_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-text");
  pika_procedure_set_static_help (procedure,
                                  "Set the text of a text layer.",
                                  "This procedure changes the text of a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("text",
                                                       "text",
                                                       "The new text to set",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-markup
   */
  procedure = pika_procedure_new (text_layer_get_markup_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-markup");
  pika_procedure_set_static_help (procedure,
                                  "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.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Barak Itkin <lightningismyname@gmail.com>",
                                         "Barak Itkin",
                                         "2010");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_string ("markup",
                                                           "markup",
                                                           "The markup which represents the style of the specified text layer.",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-markup
   */
  procedure = pika_procedure_new (text_layer_set_markup_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-markup");
  pika_procedure_set_static_help (procedure,
                                  "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.\n"
                                  "Note that PIKA'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.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Ian Munsie <darkstarsword@gmail.com>",
                                         "Ian Munsie",
                                         "2014");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("markup",
                                                       "markup",
                                                       "The new markup to set",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-font
   */
  procedure = pika_procedure_new (text_layer_get_font_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-font");
  pika_procedure_set_static_help (procedure,
                                  "Get the font from a text layer as string.",
                                  "This procedure returns the font from a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_font ("font",
                                                         "font",
                                                         "The font which is used in the specified text layer.",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-font
   */
  procedure = pika_procedure_new (text_layer_set_font_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-font");
  pika_procedure_set_static_help (procedure,
                                  "Set the font of a text layer.",
                                  "This procedure modifies the font used in the specified text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_font ("font",
                                                     "font",
                                                     "The new font to use",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-font-size
   */
  procedure = pika_procedure_new (text_layer_get_font_size_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-font-size");
  pika_procedure_set_static_help (procedure,
                                  "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 float 'font-size' in 'unit' units.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("font-size",
                                                        "font size",
                                                        "The font size",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_unit ("unit",
                                                         "unit",
                                                         "The unit used for the font size",
                                                         TRUE,
                                                         FALSE,
                                                         PIKA_UNIT_PIXEL,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-font-size
   */
  procedure = pika_procedure_new (text_layer_set_font_size_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-font-size");
  pika_procedure_set_static_help (procedure,
                                  "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.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("font-size",
                                                    "font size",
                                                    "The font size",
                                                    0.0, 8192.0, 0.0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_unit ("unit",
                                                     "unit",
                                                     "The unit to use for the font size",
                                                     TRUE,
                                                     FALSE,
                                                     PIKA_UNIT_PIXEL,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-antialias
   */
  procedure = pika_procedure_new (text_layer_get_antialias_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-antialias");
  pika_procedure_set_static_help (procedure,
                                  "Check if antialiasing is used in the text layer.",
                                  "This procedure checks if antialiasing is enabled in the specified text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("antialias",
                                                         "antialias",
                                                         "A flag which is true if antialiasing is used for rendering the font in the text layer.",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-antialias
   */
  procedure = pika_procedure_new (text_layer_set_antialias_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-antialias");
  pika_procedure_set_static_help (procedure,
                                  "Enable/disable anti-aliasing in a text layer.",
                                  "This procedure enables or disables anti-aliasing of the text in a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("antialias",
                                                     "antialias",
                                                     "Enable/disable antialiasing of the text",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-hint-style
   */
  procedure = pika_procedure_new (text_layer_get_hint_style_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-hint-style");
  pika_procedure_set_static_help (procedure,
                                  "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.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_enum ("style",
                                                      "style",
                                                      "The hint style used for font outlines",
                                                      PIKA_TYPE_TEXT_HINT_STYLE,
                                                      PIKA_TEXT_HINT_STYLE_NONE,
                                                      PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-hint-style
   */
  procedure = pika_procedure_new (text_layer_set_hint_style_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-hint-style");
  pika_procedure_set_static_help (procedure,
                                  "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.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sven Neumann <sven@gimp.org>",
                                         "Sven Neumann",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_enum ("style",
                                                  "style",
                                                  "The new hint style",
                                                  PIKA_TYPE_TEXT_HINT_STYLE,
                                                  PIKA_TEXT_HINT_STYLE_NONE,
                                                  PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-kerning
   */
  procedure = pika_procedure_new (text_layer_get_kerning_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-kerning");
  pika_procedure_set_static_help (procedure,
                                  "Check if kerning is used in the text layer.",
                                  "This procedure checks if kerning is enabled in the specified text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("kerning",
                                                         "kerning",
                                                         "A flag which is true if kerning is used in the text layer.",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-kerning
   */
  procedure = pika_procedure_new (text_layer_set_kerning_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-kerning");
  pika_procedure_set_static_help (procedure,
                                  "Enable/disable kerning in a text layer.",
                                  "This procedure enables or disables kerning in a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("kerning",
                                                     "kerning",
                                                     "Enable/disable kerning in the text",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-language
   */
  procedure = pika_procedure_new (text_layer_get_language_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-language");
  pika_procedure_set_static_help (procedure,
                                  "Get the language used in the text layer.",
                                  "This procedure returns the language string which is set for the text in the text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer.",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_string ("language",
                                                           "language",
                                                           "The language used in the text layer.",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-language
   */
  procedure = pika_procedure_new (text_layer_set_language_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-language");
  pika_procedure_set_static_help (procedure,
                                  "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.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("language",
                                                       "language",
                                                       "The new language to use for the text layer",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-base-direction
   */
  procedure = pika_procedure_new (text_layer_get_base_direction_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-base-direction");
  pika_procedure_set_static_help (procedure,
                                  "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",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer.",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_enum ("direction",
                                                      "direction",
                                                      "The based direction used for the text layer.",
                                                      PIKA_TYPE_TEXT_DIRECTION,
                                                      PIKA_TEXT_DIRECTION_LTR,
                                                      PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-base-direction
   */
  procedure = pika_procedure_new (text_layer_set_base_direction_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-base-direction");
  pika_procedure_set_static_help (procedure,
                                  "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.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_enum ("direction",
                                                  "direction",
                                                  "The base direction of the text.",
                                                  PIKA_TYPE_TEXT_DIRECTION,
                                                  PIKA_TEXT_DIRECTION_LTR,
                                                  PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-justification
   */
  procedure = pika_procedure_new (text_layer_get_justification_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-justification");
  pika_procedure_set_static_help (procedure,
                                  "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.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer.",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_enum ("justify",
                                                      "justify",
                                                      "The justification used in the text layer.",
                                                      PIKA_TYPE_TEXT_JUSTIFICATION,
                                                      PIKA_TEXT_JUSTIFY_LEFT,
                                                      PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-justification
   */
  procedure = pika_procedure_new (text_layer_set_justification_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-justification");
  pika_procedure_set_static_help (procedure,
                                  "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.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_enum ("justify",
                                                  "justify",
                                                  "The justification for your text.",
                                                  PIKA_TYPE_TEXT_JUSTIFICATION,
                                                  PIKA_TEXT_JUSTIFY_LEFT,
                                                  PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-color
   */
  procedure = pika_procedure_new (text_layer_get_color_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-color");
  pika_procedure_set_static_help (procedure,
                                  "Get the color of the text in a text layer.",
                                  "This procedure returns the color of the text in a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer.",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_rgb ("color",
                                                        "color",
                                                        "The color of the text.",
                                                        FALSE,
                                                        NULL,
                                                        PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-color
   */
  procedure = pika_procedure_new (text_layer_set_color_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-color");
  pika_procedure_set_static_help (procedure,
                                  "Set the color of the text in the text layer.",
                                  "This procedure sets the text color in the text layer 'layer'.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_rgb ("color",
                                                    "color",
                                                    "The color to use for the text",
                                                    FALSE,
                                                    NULL,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-indent
   */
  procedure = pika_procedure_new (text_layer_get_indent_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-indent");
  pika_procedure_set_static_help (procedure,
                                  "Get the line indentation of text layer.",
                                  "This procedure returns the indentation of the first line in a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer.",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("indent",
                                                        "indent",
                                                        "The indentation value of the first line.",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-indent
   */
  procedure = pika_procedure_new (text_layer_set_indent_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-indent");
  pika_procedure_set_static_help (procedure,
                                  "Set the indentation of the first line in a text layer.",
                                  "This procedure sets the indentation of the first line in the text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("indent",
                                                    "indent",
                                                    "The indentation for the first line.",
                                                    -8192.0, 8192.0, -8192.0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-line-spacing
   */
  procedure = pika_procedure_new (text_layer_get_line_spacing_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-line-spacing");
  pika_procedure_set_static_help (procedure,
                                  "Get the spacing between lines of text.",
                                  "This procedure returns the line-spacing between lines of text in a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer.",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("line-spacing",
                                                        "line spacing",
                                                        "The line-spacing value.",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-line-spacing
   */
  procedure = pika_procedure_new (text_layer_set_line_spacing_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-line-spacing");
  pika_procedure_set_static_help (procedure,
                                  "Adjust the line spacing in a text layer.",
                                  "This procedure sets the additional spacing used between lines a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("line-spacing",
                                                    "line spacing",
                                                    "The additional line spacing to use.",
                                                    -8192.0, 8192.0, -8192.0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-get-letter-spacing
   */
  procedure = pika_procedure_new (text_layer_get_letter_spacing_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-get-letter-spacing");
  pika_procedure_set_static_help (procedure,
                                  "Get the letter spacing used in a text layer.",
                                  "This procedure returns the additional spacing between the single glyphs in a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer.",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("letter-spacing",
                                                        "letter spacing",
                                                        "The letter-spacing value.",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-set-letter-spacing
   */
  procedure = pika_procedure_new (text_layer_set_letter_spacing_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-set-letter-spacing");
  pika_procedure_set_static_help (procedure,
                                  "Adjust the letter spacing in a text layer.",
                                  "This procedure sets the additional spacing between the single glyphs in a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("letter-spacing",
                                                    "letter spacing",
                                                    "The additional letter spacing to use.",
                                                    -8192.0, 8192.0, -8192.0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-text-layer-resize
   */
  procedure = pika_procedure_new (text_layer_resize_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-text-layer-resize");
  pika_procedure_set_static_help (procedure,
                                  "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 'pika-layer-resize' would do.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Barak Itkin <lightningismyname@gmail.com>",
                                         "Barak Itkin",
                                         "2009");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_text_layer ("layer",
                                                           "layer",
                                                           "The text layer",
                                                           FALSE,
                                                           PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("width",
                                                    "width",
                                                    "The new box width in pixels",
                                                    0.0, PIKA_MAX_IMAGE_SIZE, 0.0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("height",
                                                    "height",
                                                    "The new box height in pixels",
                                                    0.0, PIKA_MAX_IMAGE_SIZE, 0.0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);
}
