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_pdb
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: 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.
 *
Mukund Sivaraman's avatar
Mukund Sivaraman committed
178 179
 * Returns: 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
 * Returns: The font which is used in the specified text layer.
215
 *
216
 * Since: 2.6
217
 **/
218 219
gchar *
gimp_text_layer_get_font (gint32 layer_ID)
220
{
221 222
  GimpValueArray *args;
  GimpValueArray *return_vals;
223
  gchar *font = NULL;
224

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

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

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

238
  return font;
239 240 241
}

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

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

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

274
  gimp_value_array_unref (return_vals);
275 276 277 278 279

  return success;
}

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

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

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

316
  gimp_value_array_unref (return_vals);
317

318
  return font_size;
319 320 321
}

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

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

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

359
  gimp_value_array_unref (return_vals);
360 361 362 363 364

  return success;
}

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

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

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

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

398
  return antialias;
399 400 401
}

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

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

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

435
  gimp_value_array_unref (return_vals);
436 437 438 439 440

  return success;
}

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

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

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

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

474
  return style;
475 476 477
}

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

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

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

512
  gimp_value_array_unref (return_vals);
513 514 515 516 517

  return success;
}

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

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

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

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

550
  return kerning;
551 552 553
}

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

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

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

586
  gimp_value_array_unref (return_vals);
587 588 589 590 591

  return success;
}

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

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

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

622
  gimp_value_array_unref (return_vals);
623

624
  return language;
625 626 627
}

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

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

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

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

  gimp_value_array_unref (return_vals);
662

663
  return success;
664 665 666
}

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

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

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

697
  gimp_value_array_unref (return_vals);
698

699
  return direction;
700 701 702
}

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

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

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

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

  gimp_value_array_unref (return_vals);
737

738
  return success;
739 740 741
}

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

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

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

772
  gimp_value_array_unref (return_vals);
773

774
  return justify;
775 776 777
}

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

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

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

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

  gimp_value_array_unref (return_vals);
812

813
  return success;
814 815 816
}

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

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

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

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

850
  gimp_value_array_unref (return_vals);
851

852
  return success;
853 854 855
}

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

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

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

Michael Natterer's avatar