gimptextlayer_pdb.c 33.8 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
 *
103
 * Since: 2.6
104
 **/
105 106
gchar *
gimp_text_layer_get_text (gint32 layer_ID)
107
{
108 109
  GimpValueArray *args;
  GimpValueArray *return_vals;
110
  gchar *text = NULL;
111

112 113 114 115 116 117 118
  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);
119

120 121
  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));
122

123
  gimp_value_array_unref (return_vals);
124

125
  return text;
126 127 128
}

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

149 150 151 152 153
  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);
154

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

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

  gimp_value_array_unref (return_vals);
162 163 164 165

  return success;
}

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

190 191 192 193 194 195 196
  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);
197

198 199
  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));
200

201
  gimp_value_array_unref (return_vals);
202 203 204 205

  return markup;
}

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

226 227 228
  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);
229

230 231 232
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-get-font",
                                               args);
  gimp_value_array_unref (args);
233

234 235 236 237
  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);
238

239
  return font;
240 241 242
}

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

263 264 265 266 267 268 269 270 271
  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);
272

273
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
274

275
  gimp_value_array_unref (return_vals);
276 277 278 279 280

  return success;
}

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

303 304 305
  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);
306

307 308 309 310 311
  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)
312
    {
313 314
      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));
315
    }
316

317
  gimp_value_array_unref (return_vals);
318

319
  return font_size;
320 321 322
}

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

346 347 348 349 350 351 352 353 354 355 356
  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);
357

358
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
359

360
  gimp_value_array_unref (return_vals);
361 362 363 364 365

  return success;
}

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

386 387 388
  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);
389

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

394 395 396 397
  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);
398

399
  return antialias;
400 401 402
}

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

424 425 426 427 428 429 430 431 432
  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);
433

434
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
435

436
  gimp_value_array_unref (return_vals);
437 438 439 440 441

  return success;
}

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

462 463 464
  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);
465

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

470 471 472 473
  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);
474

475
  return style;
476 477 478
}

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

501
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
502
                                          GIMP_TYPE_TEXT_HINT_STYLE,
503 504 505 506 507 508 509
                                          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);
510

511
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
512

513
  gimp_value_array_unref (return_vals);
514 515 516 517 518

  return success;
}

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

538 539 540
  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);
541

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

546 547 548 549
  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);
550

551
  return kerning;
552 553 554
}

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

575 576 577 578 579 580 581 582 583
  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);
584

585
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
586

587
  gimp_value_array_unref (return_vals);
588 589 590 591 592

  return success;
}

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

612 613 614 615 616 617 618
  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);
619

620 621
  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));
622

623
  gimp_value_array_unref (return_vals);
624

625
  return language;
626 627 628
}

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

650 651 652 653 654
  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);
655

656 657 658
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-language",
                                               args);
  gimp_value_array_unref (args);
659

660 661 662
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
663

664
  return success;
665 666 667
}

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

687 688 689 690 691 692 693
  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);
694

695 696
  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));
697

698
  gimp_value_array_unref (return_vals);
699

700
  return direction;
701 702 703
}

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

725
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
726
                                          GIMP_TYPE_TEXT_DIRECTION,
727 728 729
                                          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);
730

731 732 733
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-base-direction",
                                               args);
  gimp_value_array_unref (args);
734

735 736 737
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
738

739
  return success;
740 741 742
}

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

762 763 764 765 766 767 768
  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);
769

770 771
  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));
772

773
  gimp_value_array_unref (return_vals);
774

775
  return justify;
776 777 778
}

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

800
  args = gimp_value_array_new_from_types (GIMP_TYPE_LAYER_ID,
801
                                          GIMP_TYPE_TEXT_JUSTIFICATION,
802 803 804
                                          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);
805

806 807 808
  return_vals = gimp_run_procedure_with_array ("gimp-text-layer-set-justification",
                                               args);
  gimp_value_array_unref (args);
809

810 811 812
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
813

814
  return success;
815 816 817
}

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

838 839 840 841 842 843 844
  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);
845

846
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
847 848

  if (success)
849
    gimp_value_get_rgb (gimp_value_array_index (return_vals, 1), &*color);
850

851
  gimp_value_array_unref (return_vals);
852

853
  return success;
854 855 856
}

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

877 878 879 880 881 882 883 884 885
  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);
886

887
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
888