gimptextlayer_pdb.c 34.1 KB
Newer Older
1 2 3 4 5
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
 *
 * gimptextlayer_pdb.c
 *
6
 * This library is free software: you can redistribute it and/or
7 8
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
9
 * version 3 of the License, or (at your option) any later version.
10 11 12 13 14 15 16
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library.  If not, see
18
 * <https://www.gnu.org/licenses/>.
19 20 21 22 23 24 25 26
 */

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

#include "config.h"

#include "gimp.h"

27 28

/**
29
 * SECTION: gimptextlayer
30 31 32 33 34 35 36
 * @title: gimptextlayer
 * @short_description: Functions for querying and manipulating text layers.
 *
 * Functions for querying and manipulating text layers.
 **/


37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
/**
 * gimp_text_layer_new:
 * @image_ID: The image.
 * @text: The text to generate (in UTF-8 encoding).
 * @fontname: The name of the font.
 * @size: The size of text in either pixels or points.
 * @unit: The units of specified size.
 *
 * 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
 * gimp_text_layer_set_*() procedures. The new layer still needs to be
 * added to the image, as this is not automatic. Add the new layer
52
 * using gimp_image_insert_layer().
53 54 55
 *
 * Returns: The new text layer.
 *
56
 * Since: 2.6
57
 **/
58 59 60 61 62 63 64
gint32
gimp_text_layer_new (gint32       image_ID,
                     const gchar *text,
                     const gchar *fontname,
                     gdouble      size,
                     GimpUnit     unit)
{
65 66
  GimpValueArray *args;
  GimpValueArray *return_vals;
67 68
  gint32 layer_ID = -1;

69 70 71 72 73 74 75 76 77 78 79
  args = gimp_value_array_new_from_types (GIMP_TYPE_IMAGE_ID,
                                          G_TYPE_STRING,
                                          G_TYPE_STRING,
                                          G_TYPE_DOUBLE,
                                          GIMP_TYPE_UNIT,
                                          G_TYPE_NONE);
  gimp_value_set_image_id (gimp_value_array_index (args, 0), image_ID);
  g_value_set_string (gimp_value_array_index (args, 1), text);
  g_value_set_string (gimp_value_array_index (args, 2), fontname);
  g_value_set_double (gimp_value_array_index (args, 3), size);
  g_value_set_int (gimp_value_array_index (args, 4), unit);
80

81 82 83
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-new",
                                               args);
  gimp_value_array_unref (args);
84

85 86 87 88
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    layer_ID = gimp_value_get_layer_id (gimp_value_array_index (return_vals, 1));

  gimp_value_array_unref (return_vals);
89 90 91 92 93

  return layer_ID;
}

/**
94
 * gimp_text_layer_get_text:
95 96
 * @layer_ID: The text layer.
 *
97
 * Get the text from a text layer as string.
98
 *
99
 * This procedure returns the text from a text layer as a string.
100
 *
101
 * Returns: (transfer full): The text from the specified text layer.
102
 *          The returned value must be freed with g_free().
103
 *
104
 * Since: 2.6
105
 **/
106 107
gchar *
gimp_text_layer_get_text (gint32 layer_ID)
108
{
109 110
  GimpValueArray *args;
  GimpValueArray *return_vals;
111
  gchar *text = NULL;
112

113 114 115 116 117 118 119
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-text",
                                               args);
  gimp_value_array_unref (args);
120

121 122
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    text = g_value_dup_string (gimp_value_array_index (return_vals, 1));
123

124
  gimp_value_array_unref (return_vals);
125

126
  return text;
127 128 129
}

/**
130
 * gimp_text_layer_set_text:
131
 * @layer_ID: The text layer.
132
 * @text: The new text to set.
133
 *
134
 * Set the text of a text layer.
135
 *
136
 * This procedure changes the text of a text layer.
137 138 139
 *
 * Returns: TRUE on success.
 *
140
 * Since: 2.6
141
 **/
142
gboolean
143 144
gimp_text_layer_set_text (gint32       layer_ID,
                          const gchar *text)
145
{
146 147
  GimpValueArray *args;
  GimpValueArray *return_vals;
148 149
  gboolean success = TRUE;

150 151 152 153 154
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_STRING,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  g_value_set_string (gimp_value_array_index (args, 1), text);
155

156 157 158
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-text",
                                               args);
  gimp_value_array_unref (args);
159

160 161 162
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
163 164 165 166

  return success;
}

167 168 169 170 171 172 173 174
/**
 * gimp_text_layer_get_markup:
 * @layer_ID: The text layer.
 *
 * 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
175
 * https://www.pango.org/ for more information about Pango and its
176 177 178
 * markup. Note: Setting the markup of a text layer using Pango's
 * markup is not supported for now.
 *
179 180 181
 * Returns: (transfer full):
 *          The markup which represents the style of the specified text layer.
 *          The returned value must be freed with g_free().
182
 *
183
 * Since: 2.8
184
 **/
185 186 187
gchar *
gimp_text_layer_get_markup (gint32 layer_ID)
{
188 189
  GimpValueArray *args;
  GimpValueArray *return_vals;
190 191
  gchar *markup = NULL;

192 193 194 195 196 197 198
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-markup",
                                               args);
  gimp_value_array_unref (args);
199

200 201
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    markup = g_value_dup_string (gimp_value_array_index (return_vals, 1));
202

203
  gimp_value_array_unref (return_vals);
204 205 206 207

  return markup;
}

208
/**
209
 * gimp_text_layer_get_font:
210 211
 * @layer_ID: The text layer.
 *
212
 * Get the font from a text layer as string.
213
 *
214
 * This procedure returns the name of the font from a text layer.
215
 *
216 217 218
 * Returns: (transfer full):
 *          The font which is used in the specified text layer.
 *          The returned value must be freed with g_free().
219
 *
220
 * Since: 2.6
221
 **/
222 223
gchar *
gimp_text_layer_get_font (gint32 layer_ID)
224
{
225 226
  GimpValueArray *args;
  GimpValueArray *return_vals;
227
  gchar *font = NULL;
228

229 230 231
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
232

233 234 235
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-font",
                                               args);
  gimp_value_array_unref (args);
236

237 238 239 240
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    font = g_value_dup_string (gimp_value_array_index (return_vals, 1));

  gimp_value_array_unref (return_vals);
241

242
  return font;
243 244 245
}

/**
246
 * gimp_text_layer_set_font:
247
 * @layer_ID: The text layer.
248
 * @font: The new font to use.
249
 *
250
 * Set the font of a text layer.
251
 *
252
 * This procedure modifies the font used in the specified text layer.
253 254 255
 *
 * Returns: TRUE on success.
 *
256
 * Since: 2.6
257
 **/
258
gboolean
259 260
gimp_text_layer_set_font (gint32       layer_ID,
                          const gchar *font)
261
{
262 263
  GimpValueArray *args;
  GimpValueArray *return_vals;
264 265
  gboolean success = TRUE;

266 267 268 269 270 271 272 273 274
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_STRING,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  g_value_set_string (gimp_value_array_index (args, 1), font);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-font",
                                               args);
  gimp_value_array_unref (args);
275

276
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
277

278
  gimp_value_array_unref (return_vals);
279 280 281 282 283

  return success;
}

/**
284
 * gimp_text_layer_get_font_size:
285
 * @layer_ID: The text layer.
286
 * @unit: (out): The unit used for the font size.
287
 *
288
 * Get the font size from a text layer.
289
 *
290 291 292
 * 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.
293
 *
294
 * Returns: The font size.
295
 *
296
 * Since: 2.6
297
 **/
298 299 300
gdouble
gimp_text_layer_get_font_size (gint32    layer_ID,
                               GimpUnit *unit)
301
{
302 303
  GimpValueArray *args;
  GimpValueArray *return_vals;
304
  gdouble font_size = 0.0;
305

306 307 308
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
309

310 311 312 313 314
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-font-size",
                                               args);
  gimp_value_array_unref (args);

  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
315
    {
316 317
      font_size = g_value_get_double (gimp_value_array_index (return_vals, 1));
      *unit = g_value_get_int (gimp_value_array_index (return_vals, 2));
318
    }
319

320
  gimp_value_array_unref (return_vals);
321

322
  return font_size;
323 324 325
}

/**
326
 * gimp_text_layer_set_font_size:
327
 * @layer_ID: The text layer.
328 329
 * @font_size: The font size.
 * @unit: The unit to use for the font size.
330
 *
331
 * Set the font size.
332
 *
333 334
 * This procedure changes the font size of a text layer. The size of
 * your font will be a double 'font-size' of 'unit' units.
335 336 337
 *
 * Returns: TRUE on success.
 *
338
 * Since: 2.6
339
 **/
340
gboolean
341 342 343
gimp_text_layer_set_font_size (gint32   layer_ID,
                               gdouble  font_size,
                               GimpUnit unit)
344
{
345 346
  GimpValueArray *args;
  GimpValueArray *return_vals;
347 348
  gboolean success = TRUE;

349 350 351 352 353 354 355 356 357 358 359
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_DOUBLE,
                                          GIMP_TYPE_UNIT,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  g_value_set_double (gimp_value_array_index (args, 1), font_size);
  g_value_set_int (gimp_value_array_index (args, 2), unit);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-font-size",
                                               args);
  gimp_value_array_unref (args);
360

361
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
362

363
  gimp_value_array_unref (return_vals);
364 365 366 367 368

  return success;
}

/**
369
 * gimp_text_layer_get_antialias:
370 371
 * @layer_ID: The text layer.
 *
372
 * Check if antialiasing is used in the text layer.
373
 *
374 375
 * This procedure checks if antialiasing is enabled in the specified
 * text layer.
376
 *
377
 * Returns: A flag which is true if antialiasing is used for rendering the font in the text layer.
378
 *
379
 * Since: 2.6
380
 **/
381
gboolean
382
gimp_text_layer_get_antialias (gint32 layer_ID)
383
{
384 385
  GimpValueArray *args;
  GimpValueArray *return_vals;
386
  gboolean antialias = FALSE;
387

388 389 390
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
391

392 393 394
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-antialias",
                                               args);
  gimp_value_array_unref (args);
395

396 397 398 399
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    antialias = g_value_get_boolean (gimp_value_array_index (return_vals, 1));

  gimp_value_array_unref (return_vals);
400

401
  return antialias;
402 403 404
}

/**
405
 * gimp_text_layer_set_antialias:
406
 * @layer_ID: The text layer.
407
 * @antialias: Enable/disable antialiasing of the text.
408
 *
409
 * Enable/disable anti-aliasing in a text layer.
410
 *
411 412
 * This procedure enables or disables anti-aliasing of the text in a
 * text layer.
413 414 415
 *
 * Returns: TRUE on success.
 *
416
 * Since: 2.6
417
 **/
418
gboolean
419 420
gimp_text_layer_set_antialias (gint32   layer_ID,
                               gboolean antialias)
421
{
422 423
  GimpValueArray *args;
  GimpValueArray *return_vals;
424 425
  gboolean success = TRUE;

426 427 428 429 430 431 432 433 434
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_BOOLEAN,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  g_value_set_boolean (gimp_value_array_index (args, 1), antialias);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-antialias",
                                               args);
  gimp_value_array_unref (args);
435

436
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
437

438
  gimp_value_array_unref (return_vals);
439 440 441 442 443

  return success;
}

/**
444
 * gimp_text_layer_get_hint_style:
445 446
 * @layer_ID: The text layer.
 *
447
 * Get information about hinting in the specified text layer.
448
 *
449 450 451
 * 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.
452
 *
453
 * Returns: The hint style used for font outlines.
454
 *
455
 * Since: 2.8
456
 **/
457 458
GimpTextHintStyle
gimp_text_layer_get_hint_style (gint32 layer_ID)
459
{
460 461
  GimpValueArray *args;
  GimpValueArray *return_vals;
462
  GimpTextHintStyle style = 0;
463

464 465 466
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
467

468 469 470
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-hint-style",
                                               args);
  gimp_value_array_unref (args);
471

472 473 474 475
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    style = g_value_get_enum (gimp_value_array_index (return_vals, 1));

  gimp_value_array_unref (return_vals);
476

477
  return style;
478 479 480
}

/**
481
 * gimp_text_layer_set_hint_style:
482
 * @layer_ID: The text layer.
483
 * @style: The new hint style.
484
 *
485
 * Control how font outlines are hinted in a text layer.
486
 *
487 488 489
 * 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.
490 491 492
 *
 * Returns: TRUE on success.
 *
493
 * Since: 2.8
494
 **/
495
gboolean
496 497
gimp_text_layer_set_hint_style (gint32            layer_ID,
                                GimpTextHintStyle style)
498
{
499 500
  GimpValueArray *args;
  GimpValueArray *return_vals;
501 502
  gboolean success = TRUE;

503
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
504
                                          GIMP_TYPE_TEXT_HINT_STYLE,
505 506 507 508 509 510 511
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), style);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-hint-style",
                                               args);
  gimp_value_array_unref (args);
512

513
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
514

515
  gimp_value_array_unref (return_vals);
516 517 518 519 520

  return success;
}

/**
521
 * gimp_text_layer_get_kerning:
522 523
 * @layer_ID: The text layer.
 *
524
 * Check if kerning is used in the text layer.
525
 *
526
 * This procedure checks if kerning is enabled in the specified text
527 528
 * layer.
 *
529
 * Returns: A flag which is true if kerning is used in the text layer.
530
 *
531
 * Since: 2.6
532
 **/
533
gboolean
534
gimp_text_layer_get_kerning (gint32 layer_ID)
535
{
536 537
  GimpValueArray *args;
  GimpValueArray *return_vals;
538
  gboolean kerning = FALSE;
539

540 541 542
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
543

544 545 546
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-kerning",
                                               args);
  gimp_value_array_unref (args);
547

548 549 550 551
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    kerning = g_value_get_boolean (gimp_value_array_index (return_vals, 1));

  gimp_value_array_unref (return_vals);
552

553
  return kerning;
554 555 556
}

/**
557
 * gimp_text_layer_set_kerning:
558
 * @layer_ID: The text layer.
559
 * @kerning: Enable/disable kerning in the text.
560
 *
561
 * Enable/disable kerning in a text layer.
562
 *
563
 * This procedure enables or disables kerning in a text layer.
564 565 566
 *
 * Returns: TRUE on success.
 *
567
 * Since: 2.6
568
 **/
569
gboolean
570 571
gimp_text_layer_set_kerning (gint32   layer_ID,
                             gboolean kerning)
572
{
573 574
  GimpValueArray *args;
  GimpValueArray *return_vals;
575 576
  gboolean success = TRUE;

577 578 579 580 581 582 583 584 585
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_BOOLEAN,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  g_value_set_boolean (gimp_value_array_index (args, 1), kerning);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-kerning",
                                               args);
  gimp_value_array_unref (args);
586

587
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
588

589
  gimp_value_array_unref (return_vals);
590 591 592 593 594

  return success;
}

/**
595
 * gimp_text_layer_get_language:
596 597
 * @layer_ID: The text layer.
 *
598
 * Get the language used in the text layer.
599
 *
600 601
 * This procedure returns the language string which is set for the text
 * in the text layer.
602
 *
603
 * Returns: (transfer full): The language used in the text layer.
604
 *          The returned value must be freed with g_free().
605
 *
606
 * Since: 2.6
607
 **/
608 609
gchar *
gimp_text_layer_get_language (gint32 layer_ID)
610
{
611 612
  GimpValueArray *args;
  GimpValueArray *return_vals;
613
  gchar *language = NULL;
614

615 616 617 618 619 620 621
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-language",
                                               args);
  gimp_value_array_unref (args);
622

623 624
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    language = g_value_dup_string (gimp_value_array_index (return_vals, 1));
625

626
  gimp_value_array_unref (return_vals);
627

628
  return language;
629 630 631
}

/**
632
 * gimp_text_layer_set_language:
633
 * @layer_ID: The text layer.
634
 * @language: The new language to use for the text layer.
635
 *
636
 * Set the language of the text layer.
637
 *
638 639
 * 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.
640
 *
641
 * Returns: TRUE on success.
642
 *
643
 * Since: 2.6
644
 **/
645 646 647
gboolean
gimp_text_layer_set_language (gint32       layer_ID,
                              const gchar *language)
648
{
649 650
  GimpValueArray *args;
  GimpValueArray *return_vals;
651
  gboolean success = TRUE;
652

653 654 655 656 657
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_STRING,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  g_value_set_string (gimp_value_array_index (args, 1), language);
658

659 660 661
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-language",
                                               args);
  gimp_value_array_unref (args);
662

663 664 665
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
666

667
  return success;
668 669 670
}

/**
671
 * gimp_text_layer_get_base_direction:
672 673
 * @layer_ID: The text layer.
 *
674
 * Get the base direction used for rendering the text layer.
675
 *
676 677
 * This procedure returns the base direction used for rendering the
 * text in the text layer
678
 *
679
 * Returns: The based direction used for the text layer.
680
 *
681
 * Since: 2.6
682
 **/
683 684
GimpTextDirection
gimp_text_layer_get_base_direction (gint32 layer_ID)
685
{
686 687
  GimpValueArray *args;
  GimpValueArray *return_vals;
688
  GimpTextDirection direction = 0;
689

690 691 692 693 694 695 696
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-base-direction",
                                               args);
  gimp_value_array_unref (args);
697

698 699
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    direction = g_value_get_enum (gimp_value_array_index (return_vals, 1));
700

701
  gimp_value_array_unref (return_vals);
702

703
  return direction;
704 705 706
}

/**
707
 * gimp_text_layer_set_base_direction:
708
 * @layer_ID: The text layer.
709
 * @direction: The base direction of the text.
710
 *
711
 * Set the base direction in the text layer.
712
 *
713 714
 * This procedure sets the base direction used in applying the Unicode
 * bidirectional algorithm when rendering the text.
715
 *
716
 * Returns: TRUE on success.
717
 *
718
 * Since: 2.6
719
 **/
720 721 722
gboolean
gimp_text_layer_set_base_direction (gint32            layer_ID,
                                    GimpTextDirection direction)
723
{
724 725
  GimpValueArray *args;
  GimpValueArray *return_vals;
726
  gboolean success = TRUE;
727

728
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
729
                                          GIMP_TYPE_TEXT_DIRECTION,
730 731 732
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), direction);
733

734 735 736
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-base-direction",
                                               args);
  gimp_value_array_unref (args);
737

738 739 740
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
741

742
  return success;
743 744 745
}

/**
746
 * gimp_text_layer_get_justification:
747 748
 * @layer_ID: The text layer.
 *
749
 * Get the text justification information of the text layer.
750
 *
751 752
 * This procedure returns the alignment of the lines in the text layer
 * relative to each other.
753
 *
754
 * Returns: The justification used in the text layer.
755
 *
756
 * Since: 2.6
757
 **/
758 759
GimpTextJustification
gimp_text_layer_get_justification (gint32 layer_ID)
760
{
761 762
  GimpValueArray *args;
  GimpValueArray *return_vals;
763
  GimpTextJustification justify = 0;
764

765 766 767 768 769 770 771
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-justification",
                                               args);
  gimp_value_array_unref (args);
772

773 774
  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
    justify = g_value_get_enum (gimp_value_array_index (return_vals, 1));
775

776
  gimp_value_array_unref (return_vals);
777

778
  return justify;
779 780 781
}

/**
782
 * gimp_text_layer_set_justification:
783
 * @layer_ID: The text layer.
784
 * @justify: The justification for your text.
785
 *
786
 * Set the justification of the text in a text layer.
787
 *
788 789
 * This procedure sets the alignment of the lines in the text layer
 * relative to each other.
790
 *
791
 * Returns: TRUE on success.
792
 *
793
 * Since: 2.6
794
 **/
795
gboolean
796 797
gimp_text_layer_set_justification (gint32                layer_ID,
                                   GimpTextJustification justify)
798
{
799 800
  GimpValueArray *args;
  GimpValueArray *return_vals;
801
  gboolean success = TRUE;
802

803
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
804
                                          GIMP_TYPE_TEXT_JUSTIFICATION,
805 806 807
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), justify);
808

809 810 811
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-justification",
                                               args);
  gimp_value_array_unref (args);
812

813 814 815
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
816

817
  return success;
818 819 820
}

/**
821
 * gimp_text_layer_get_color:
822
 * @layer_ID: The text layer.
823
 * @color: (out caller-allocates): The color of the text.
824
 *
825
 * Get the color of the text in a text layer.
826
 *
827
 * This procedure returns the color of the text in a text layer.
828
 *
829
 * Returns: TRUE on success.
830
 *
831
 * Since: 2.6
832
 **/
833
gboolean
834 835
gimp_text_layer_get_color (gint32   layer_ID,
                           GimpRGB *color)
836
{
837 838
  GimpValueArray *args;
  GimpValueArray *return_vals;
839
  gboolean success = TRUE;
840

841 842 843 844 845 846 847
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-color",
                                               args);
  gimp_value_array_unref (args);
848

849
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
850 851

  if (success)
852
    gimp_value_get_rgb (gimp_value_array_index (return_vals, 1), &*color);
853

854
  gimp_value_array_unref (return_vals);
855

856
  return success;
857 858 859
}

/**
860
 * gimp_text_layer_set_color:
861
 * @layer_ID: The text layer.
862
 * @color: The color to use for the text.
863
 *
864
 * Set the color of the text in the text layer.
865
 *
866
 * This procedure sets the text color in the text layer 'layer'.
867
 *
868
 * Returns: TRUE on success.
869
 *
870
 * Since: 2.6
871
 **/
872 873 874
gboolean
gimp_text_layer_set_color (gint32         layer_ID,
                           const GimpRGB *color)
875
{
876 877
  GimpValueArray *args;
  GimpValueArray *return_vals;
878
  gboolean success = TRUE;
879

880 881 882 883 884 885 886 887 888
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
                                          GIMP_TYPE_RGB,
                                          G_TYPE_NONE);
  gimp_value_set_layer_id (gimp_value_array_index (args, 0), layer_ID);
  gimp_value_set_rgb (gimp_value_array_index (args, 1), color);

  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-color",
                                               args);
  gimp_value_array_unref (args);