text_tool_cmds.c 16.5 KB
Newer Older
Manish Singh's avatar
Manish Singh committed
1
/* The GIMP -- an image manipulation program
2
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
Manish Singh's avatar
Manish Singh committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * 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 2 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

/* NOTE: This file is autogenerated by pdbgen.pl. */

21
#include "config.h"
Manish Singh's avatar
Manish Singh committed
22

23

24
#include <glib-object.h>
25

26 27
#include "libgimpbase/gimpbase.h"

28
#include "pdb-types.h"
29 30
#include "procedural_db.h"

Michael Natterer's avatar
Michael Natterer committed
31
#include "core/gimpdrawable.h"
32 33
#include "core/gimpimage.h"
#include "core/gimplayer.h"
Sven Neumann's avatar
Sven Neumann committed
34
#include "text/gimptext-compat.h"
Manish Singh's avatar
Manish Singh committed
35 36 37 38 39 40 41

static ProcRecord text_fontname_proc;
static ProcRecord text_get_extents_fontname_proc;
static ProcRecord text_proc;
static ProcRecord text_get_extents_proc;

void
42
register_text_tool_procs (Gimp *gimp)
Manish Singh's avatar
Manish Singh committed
43
{
44 45 46 47
  procedural_db_register (gimp, &text_fontname_proc);
  procedural_db_register (gimp, &text_get_extents_fontname_proc);
  procedural_db_register (gimp, &text_proc);
  procedural_db_register (gimp, &text_get_extents_proc);
Manish Singh's avatar
Manish Singh committed
48 49 50
}

static Argument *
51 52 53 54
text_fontname_invoker (Gimp         *gimp,
                       GimpContext  *context,
                       GimpProgress *progress,
                       Argument     *args)
Manish Singh's avatar
Manish Singh committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
{
  gboolean success = TRUE;
  Argument *return_args;
  GimpImage *gimage;
  GimpDrawable *drawable;
  gdouble x;
  gdouble y;
  gchar *text;
  gint32 border;
  gboolean antialias;
  gdouble size;
  gint32 size_type;
  gchar *fontname;
  GimpLayer *text_layer = NULL;

70
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
71
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
72 73
    success = FALSE;

74
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int);
Manish Singh's avatar
Manish Singh committed
75 76 77 78 79 80

  x = args[2].value.pdb_float;

  y = args[3].value.pdb_float;

  text = (gchar *) args[4].value.pdb_pointer;
Michael Natterer's avatar
Michael Natterer committed
81
  if (text == NULL || !g_utf8_validate (text, -1, NULL))
Manish Singh's avatar
Manish Singh committed
82 83 84 85 86 87 88 89 90 91 92 93 94
    success = FALSE;

  border = args[5].value.pdb_int;
  if (border < -1)
    success = FALSE;

  antialias = args[6].value.pdb_int ? TRUE : FALSE;

  size = args[7].value.pdb_float;
  if (size <= 0.0)
    success = FALSE;

  size_type = args[8].value.pdb_int;
95
  if (size_type < GIMP_PIXELS || size_type > GIMP_POINTS)
Manish Singh's avatar
Manish Singh committed
96 97 98
    success = FALSE;

  fontname = (gchar *) args[9].value.pdb_pointer;
99
  if (fontname == NULL || !g_utf8_validate (fontname, -1, NULL))
Manish Singh's avatar
Manish Singh committed
100 101 102 103
    success = FALSE;

  if (success)
    {
104
      if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
Manish Singh's avatar
Manish Singh committed
105
        success = FALSE;
Manish Singh's avatar
Manish Singh committed
106

107
      if (success)
Manish Singh's avatar
Manish Singh committed
108 109
        {
          gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
Manish Singh's avatar
Manish Singh committed
110

111 112
          text_layer = text_render (gimage, drawable, context,
                                    x, y, real_fontname, text,
Manish Singh's avatar
Manish Singh committed
113
                                    border, antialias);
Manish Singh's avatar
Manish Singh committed
114

Manish Singh's avatar
Manish Singh committed
115 116
          g_free (real_fontname);
        }
Manish Singh's avatar
Manish Singh committed
117 118 119 120 121
    }

  return_args = procedural_db_return_args (&text_fontname_proc, success);

  if (success)
122
    return_args[1].value.pdb_int = text_layer ? gimp_item_get_ID (GIMP_ITEM (text_layer)) : -1;
Manish Singh's avatar
Manish Singh committed
123 124 125 126 127 128 129

  return return_args;
}

static ProcArg text_fontname_inargs[] =
{
  {
130
    GIMP_PDB_IMAGE,
Manish Singh's avatar
Manish Singh committed
131 132 133 134
    "image",
    "The image"
  },
  {
135
    GIMP_PDB_DRAWABLE,
Manish Singh's avatar
Manish Singh committed
136 137 138 139
    "drawable",
    "The affected drawable: (-1 for a new text layer)"
  },
  {
140
    GIMP_PDB_FLOAT,
Manish Singh's avatar
Manish Singh committed
141 142 143 144
    "x",
    "The x coordinate for the left of the text bounding box"
  },
  {
145
    GIMP_PDB_FLOAT,
Manish Singh's avatar
Manish Singh committed
146 147 148 149
    "y",
    "The y coordinate for the top of the text bounding box"
  },
  {
150
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
151 152 153 154
    "text",
    "The text to generate"
  },
  {
155
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
156 157 158 159
    "border",
    "The size of the border: -1 <= border"
  },
  {
160
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
161 162 163 164
    "antialias",
    "Antialiasing (TRUE or FALSE)"
  },
  {
165
    GIMP_PDB_FLOAT,
Manish Singh's avatar
Manish Singh committed
166 167 168 169
    "size",
    "The size of text in either pixels or points"
  },
  {
170
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
171
    "size_type",
172
    "The units of specified size: GIMP_PIXELS (0) or GIMP_POINTS (1)"
Manish Singh's avatar
Manish Singh committed
173 174
  },
  {
175
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
176
    "fontname",
177
    "The name of the font"
Manish Singh's avatar
Manish Singh committed
178 179 180 181 182 183
  }
};

static ProcArg text_fontname_outargs[] =
{
  {
184
    GIMP_PDB_LAYER,
Manish Singh's avatar
Manish Singh committed
185
    "text_layer",
186
    "The new text layer or -1 if no layer was created."
Manish Singh's avatar
Manish Singh committed
187 188 189 190 191 192 193
  }
};

static ProcRecord text_fontname_proc =
{
  "gimp_text_fontname",
  "Add text at the specified location as a floating selection or a new layer.",
Sven Neumann's avatar
Sven Neumann committed
194
  "This tool requires a fontname matching an installed PangoFT2 font. You can specify the fontsize in units of pixels or points, and the appropriate metric is specified using the size_type argument. The x and y parameters together control the placement of the new text by specifying the upper left corner of the text bounding box. If the specified drawable parameter is valid, the text will be created as a floating selection attached to the drawable. If the drawable parameter is not valid (-1), the text will appear as a new layer. Finally, a border can be specified around the final rendered text. The border is measured in pixels.",
Manish Singh's avatar
Manish Singh committed
195 196
  "Martin Edlman & Sven Neumann",
  "Spencer Kimball & Peter Mattis",
Sven Neumann's avatar
Sven Neumann committed
197
  "1998- 2001",
198
  NULL,
199
  GIMP_INTERNAL,
Manish Singh's avatar
Manish Singh committed
200 201 202 203 204 205 206 207
  10,
  text_fontname_inargs,
  1,
  text_fontname_outargs,
  { { text_fontname_invoker } }
};

static Argument *
208 209 210 211
text_get_extents_fontname_invoker (Gimp         *gimp,
                                   GimpContext  *context,
                                   GimpProgress *progress,
                                   Argument     *args)
Manish Singh's avatar
Manish Singh committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225
{
  gboolean success = TRUE;
  Argument *return_args;
  gchar *text;
  gdouble size;
  gint32 size_type;
  gchar *fontname;
  gint32 width;
  gint32 height;
  gint32 ascent;
  gint32 descent;
  gchar *real_fontname;

  text = (gchar *) args[0].value.pdb_pointer;
Michael Natterer's avatar
Michael Natterer committed
226
  if (text == NULL || !g_utf8_validate (text, -1, NULL))
Manish Singh's avatar
Manish Singh committed
227 228 229 230 231 232 233
    success = FALSE;

  size = args[1].value.pdb_float;
  if (size <= 0.0)
    success = FALSE;

  size_type = args[2].value.pdb_int;
234
  if (size_type < GIMP_PIXELS || size_type > GIMP_POINTS)
Manish Singh's avatar
Manish Singh committed
235 236 237
    success = FALSE;

  fontname = (gchar *) args[3].value.pdb_pointer;
238
  if (fontname == NULL || !g_utf8_validate (fontname, -1, NULL))
Manish Singh's avatar
Manish Singh committed
239 240 241 242
    success = FALSE;

  if (success)
    {
Sven Neumann's avatar
Sven Neumann committed
243
      real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
Manish Singh's avatar
Manish Singh committed
244

Manish Singh's avatar
Manish Singh committed
245
      success = text_get_extents (real_fontname, text,
Manish Singh's avatar
Manish Singh committed
246 247
                                  &width, &height,
                                  &ascent, &descent);
Manish Singh's avatar
Manish Singh committed
248

Manish Singh's avatar
Manish Singh committed
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
      g_free (real_fontname);
    }

  return_args = procedural_db_return_args (&text_get_extents_fontname_proc, success);

  if (success)
    {
      return_args[1].value.pdb_int = width;
      return_args[2].value.pdb_int = height;
      return_args[3].value.pdb_int = ascent;
      return_args[4].value.pdb_int = descent;
    }

  return return_args;
}

static ProcArg text_get_extents_fontname_inargs[] =
{
  {
268
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
269 270 271 272
    "text",
    "The text to generate"
  },
  {
273
    GIMP_PDB_FLOAT,
Manish Singh's avatar
Manish Singh committed
274 275 276 277
    "size",
    "The size of text in either pixels or points"
  },
  {
278
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
279
    "size_type",
280
    "The units of specified size: GIMP_PIXELS (0) or GIMP_POINTS (1)"
Manish Singh's avatar
Manish Singh committed
281 282
  },
  {
283
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
284
    "fontname",
285
    "The name of the font"
Manish Singh's avatar
Manish Singh committed
286 287 288 289 290 291
  }
};

static ProcArg text_get_extents_fontname_outargs[] =
{
  {
292
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
293 294 295 296
    "width",
    "The width of the specified font"
  },
  {
297
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
298 299 300 301
    "height",
    "The height of the specified font"
  },
  {
302
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
303 304 305 306
    "ascent",
    "The ascent of the specified font"
  },
  {
307
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
308 309 310 311 312 313 314 315 316 317 318 319
    "descent",
    "The descent of the specified font"
  }
};

static ProcRecord text_get_extents_fontname_proc =
{
  "gimp_text_get_extents_fontname",
  "Get extents of the bounding box for the specified text.",
  "This tool returns the width and height of a bounding box for the specified text string with the specified font information. Ascent and descent for the specified font are returned as well.",
  "Martin Edlman & Sven Neumann",
  "Spencer Kimball & Peter Mattis",
Sven Neumann's avatar
Sven Neumann committed
320
  "1998- 2001",
321
  NULL,
322
  GIMP_INTERNAL,
Manish Singh's avatar
Manish Singh committed
323 324 325 326 327 328 329 330
  4,
  text_get_extents_fontname_inargs,
  4,
  text_get_extents_fontname_outargs,
  { { text_get_extents_fontname_invoker } }
};

static Argument *
331 332 333 334
text_invoker (Gimp         *gimp,
              GimpContext  *context,
              GimpProgress *progress,
              Argument     *args)
Manish Singh's avatar
Manish Singh committed
335 336
{
  gboolean success = TRUE;
337 338 339 340 341 342 343 344 345 346
  Argument *return_args;
  GimpImage *gimage;
  GimpDrawable *drawable;
  gdouble x;
  gdouble y;
  gchar *text;
  gint32 border;
  gboolean antialias;
  gdouble size;
  gint32 size_type;
Manish Singh's avatar
Manish Singh committed
347 348 349 350 351 352 353 354
  gchar *foundry;
  gchar *family;
  gchar *weight;
  gchar *slant;
  gchar *set_width;
  gchar *spacing;
  gchar *registry;
  gchar *encoding;
355 356 357 358 359 360 361 362 363 364 365 366 367
  GimpLayer *text_layer = NULL;

  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
  if (! GIMP_IS_IMAGE (gimage))
    success = FALSE;

  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int);

  x = args[2].value.pdb_float;

  y = args[3].value.pdb_float;

  text = (gchar *) args[4].value.pdb_pointer;
Michael Natterer's avatar
Michael Natterer committed
368
  if (text == NULL || !g_utf8_validate (text, -1, NULL))
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
    success = FALSE;

  border = args[5].value.pdb_int;
  if (border < -1)
    success = FALSE;

  antialias = args[6].value.pdb_int ? TRUE : FALSE;

  size = args[7].value.pdb_float;
  if (size <= 0.0)
    success = FALSE;

  size_type = args[8].value.pdb_int;
  if (size_type < GIMP_PIXELS || size_type > GIMP_POINTS)
    success = FALSE;
Manish Singh's avatar
Manish Singh committed
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416

  foundry = (gchar *) args[9].value.pdb_pointer;
  if (foundry == NULL)
    success = FALSE;

  family = (gchar *) args[10].value.pdb_pointer;
  if (family == NULL)
    success = FALSE;

  weight = (gchar *) args[11].value.pdb_pointer;
  if (weight == NULL)
    success = FALSE;

  slant = (gchar *) args[12].value.pdb_pointer;
  if (slant == NULL)
    success = FALSE;

  set_width = (gchar *) args[13].value.pdb_pointer;
  if (set_width == NULL)
    success = FALSE;

  spacing = (gchar *) args[14].value.pdb_pointer;
  if (spacing == NULL)
    success = FALSE;

  registry = (gchar *) args[15].value.pdb_pointer;
  if (registry == NULL)
    success = FALSE;

  encoding = (gchar *) args[16].value.pdb_pointer;
  if (encoding == NULL)
    success = FALSE;

417 418
  if (success)
    {
419
      if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
Manish Singh's avatar
Manish Singh committed
420
        success = FALSE;
Manish Singh's avatar
Manish Singh committed
421

422
      if (success)
Manish Singh's avatar
Manish Singh committed
423 424
        {
          gchar *real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
Manish Singh's avatar
Manish Singh committed
425

426 427
          text_layer = text_render (gimage, drawable, context,
                                    x, y, real_fontname, text,
Manish Singh's avatar
Manish Singh committed
428
                                    border, antialias);
Manish Singh's avatar
Manish Singh committed
429

Manish Singh's avatar
Manish Singh committed
430 431
          g_free (real_fontname);
        }
432
    }
Manish Singh's avatar
Manish Singh committed
433

434
  return_args = procedural_db_return_args (&text_proc, success);
Manish Singh's avatar
Manish Singh committed
435

436
  if (success)
437
    return_args[1].value.pdb_int = text_layer ? gimp_item_get_ID (GIMP_ITEM (text_layer)) : -1;
Manish Singh's avatar
Manish Singh committed
438

439
  return return_args;
Manish Singh's avatar
Manish Singh committed
440 441 442 443 444
}

static ProcArg text_inargs[] =
{
  {
445
    GIMP_PDB_IMAGE,
Manish Singh's avatar
Manish Singh committed
446 447 448 449
    "image",
    "The image"
  },
  {
450
    GIMP_PDB_DRAWABLE,
Manish Singh's avatar
Manish Singh committed
451 452 453 454
    "drawable",
    "The affected drawable: (-1 for a new text layer)"
  },
  {
455
    GIMP_PDB_FLOAT,
Manish Singh's avatar
Manish Singh committed
456 457 458 459
    "x",
    "The x coordinate for the left of the text bounding box"
  },
  {
460
    GIMP_PDB_FLOAT,
Manish Singh's avatar
Manish Singh committed
461 462 463 464
    "y",
    "The y coordinate for the top of the text bounding box"
  },
  {
465
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
466 467 468 469
    "text",
    "The text to generate"
  },
  {
470
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
471 472 473 474
    "border",
    "The size of the border: -1 <= border"
  },
  {
475
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
476 477 478 479
    "antialias",
    "Antialiasing (TRUE or FALSE)"
  },
  {
480
    GIMP_PDB_FLOAT,
Manish Singh's avatar
Manish Singh committed
481 482 483 484
    "size",
    "The size of text in either pixels or points"
  },
  {
485
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
486
    "size_type",
487
    "The units of specified size: GIMP_PIXELS (0) or GIMP_POINTS (1)"
Manish Singh's avatar
Manish Singh committed
488 489
  },
  {
490
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
491
    "foundry",
492
    "The font foundry"
Manish Singh's avatar
Manish Singh committed
493 494
  },
  {
495
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
496
    "family",
497
    "The font family"
Manish Singh's avatar
Manish Singh committed
498 499
  },
  {
500
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
501
    "weight",
502
    "The font weight"
Manish Singh's avatar
Manish Singh committed
503 504
  },
  {
505
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
506
    "slant",
507
    "The font slant"
Manish Singh's avatar
Manish Singh committed
508 509
  },
  {
510
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
511
    "set_width",
512
    "The font set-width"
Manish Singh's avatar
Manish Singh committed
513 514
  },
  {
515
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
516
    "spacing",
517
    "The font spacing"
Manish Singh's avatar
Manish Singh committed
518 519
  },
  {
520
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
521
    "registry",
522
    "The font registry"
Manish Singh's avatar
Manish Singh committed
523 524
  },
  {
525
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
526
    "encoding",
527
    "The font encoding"
Manish Singh's avatar
Manish Singh committed
528 529 530 531 532 533
  }
};

static ProcArg text_outargs[] =
{
  {
534
    GIMP_PDB_LAYER,
Manish Singh's avatar
Manish Singh committed
535
    "text_layer",
536
    "The new text layer or -1 if no layer was created."
Manish Singh's avatar
Manish Singh committed
537 538 539 540 541 542
  }
};

static ProcRecord text_proc =
{
  "gimp_text",
543 544
  "This procedure is deprecated! Use 'gimp_text_fontname' instead.",
  "This procedure is deprecated! Use 'gimp_text_fontname' instead.",
545 546 547
  "",
  "",
  "",
548
  "gimp_text_fontname",
549
  GIMP_INTERNAL,
Manish Singh's avatar
Manish Singh committed
550 551 552 553 554 555 556 557
  17,
  text_inargs,
  1,
  text_outargs,
  { { text_invoker } }
};

static Argument *
558 559 560 561
text_get_extents_invoker (Gimp         *gimp,
                          GimpContext  *context,
                          GimpProgress *progress,
                          Argument     *args)
Manish Singh's avatar
Manish Singh committed
562 563
{
  gboolean success = TRUE;
564 565 566 567
  Argument *return_args;
  gchar *text;
  gdouble size;
  gint32 size_type;
Manish Singh's avatar
Manish Singh committed
568 569 570 571 572 573 574 575
  gchar *foundry;
  gchar *family;
  gchar *weight;
  gchar *slant;
  gchar *set_width;
  gchar *spacing;
  gchar *registry;
  gchar *encoding;
576 577 578 579 580 581 582
  gint32 width;
  gint32 height;
  gint32 ascent;
  gint32 descent;
  gchar *real_fontname;

  text = (gchar *) args[0].value.pdb_pointer;
Michael Natterer's avatar
Michael Natterer committed
583
  if (text == NULL || !g_utf8_validate (text, -1, NULL))
584 585 586 587 588 589 590 591 592
    success = FALSE;

  size = args[1].value.pdb_float;
  if (size <= 0.0)
    success = FALSE;

  size_type = args[2].value.pdb_int;
  if (size_type < GIMP_PIXELS || size_type > GIMP_POINTS)
    success = FALSE;
Manish Singh's avatar
Manish Singh committed
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625

  foundry = (gchar *) args[3].value.pdb_pointer;
  if (foundry == NULL)
    success = FALSE;

  family = (gchar *) args[4].value.pdb_pointer;
  if (family == NULL)
    success = FALSE;

  weight = (gchar *) args[5].value.pdb_pointer;
  if (weight == NULL)
    success = FALSE;

  slant = (gchar *) args[6].value.pdb_pointer;
  if (slant == NULL)
    success = FALSE;

  set_width = (gchar *) args[7].value.pdb_pointer;
  if (set_width == NULL)
    success = FALSE;

  spacing = (gchar *) args[8].value.pdb_pointer;
  if (spacing == NULL)
    success = FALSE;

  registry = (gchar *) args[9].value.pdb_pointer;
  if (registry == NULL)
    success = FALSE;

  encoding = (gchar *) args[10].value.pdb_pointer;
  if (encoding == NULL)
    success = FALSE;

626 627 628
  if (success)
    {
      real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
Manish Singh's avatar
Manish Singh committed
629

630
      success = text_get_extents (real_fontname, text,
Manish Singh's avatar
Manish Singh committed
631 632
                                  &width, &height,
                                  &ascent, &descent);
Manish Singh's avatar
Manish Singh committed
633

634 635
      g_free (real_fontname);
    }
Manish Singh's avatar
Manish Singh committed
636

637
  return_args = procedural_db_return_args (&text_get_extents_proc, success);
Manish Singh's avatar
Manish Singh committed
638

639 640 641 642 643 644 645
  if (success)
    {
      return_args[1].value.pdb_int = width;
      return_args[2].value.pdb_int = height;
      return_args[3].value.pdb_int = ascent;
      return_args[4].value.pdb_int = descent;
    }
Manish Singh's avatar
Manish Singh committed
646

647
  return return_args;
Manish Singh's avatar
Manish Singh committed
648 649 650 651 652
}

static ProcArg text_get_extents_inargs[] =
{
  {
653
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
654 655 656 657
    "text",
    "The text to generate"
  },
  {
658
    GIMP_PDB_FLOAT,
Manish Singh's avatar
Manish Singh committed
659 660 661 662
    "size",
    "The size of text in either pixels or points"
  },
  {
663
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
664
    "size_type",
665
    "The units of specified size: GIMP_PIXELS (0) or GIMP_POINTS (1)"
Manish Singh's avatar
Manish Singh committed
666 667
  },
  {
668
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
669
    "foundry",
670
    "The font foundry"
Manish Singh's avatar
Manish Singh committed
671 672
  },
  {
673
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
674
    "family",
675
    "The font family"
Manish Singh's avatar
Manish Singh committed
676 677
  },
  {
678
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
679
    "weight",
680
    "The font weight"
Manish Singh's avatar
Manish Singh committed
681 682
  },
  {
683
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
684
    "slant",
685
    "The font slant"
Manish Singh's avatar
Manish Singh committed
686 687
  },
  {
688
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
689
    "set_width",
690
    "The font set-width"
Manish Singh's avatar
Manish Singh committed
691 692
  },
  {
693
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
694
    "spacing",
695
    "The font spacing"
Manish Singh's avatar
Manish Singh committed
696 697
  },
  {
698
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
699
    "registry",
700
    "The font registry"
Manish Singh's avatar
Manish Singh committed
701 702
  },
  {
703
    GIMP_PDB_STRING,
Manish Singh's avatar
Manish Singh committed
704
    "encoding",
705
    "The font encoding"
Manish Singh's avatar
Manish Singh committed
706 707 708 709 710 711
  }
};

static ProcArg text_get_extents_outargs[] =
{
  {
712
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
713 714 715 716
    "width",
    "The width of the specified font"
  },
  {
717
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
718 719 720 721
    "height",
    "The height of the specified font"
  },
  {
722
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
723 724 725 726
    "ascent",
    "The ascent of the specified font"
  },
  {
727
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
728 729 730 731 732 733 734 735
    "descent",
    "The descent of the specified font"
  }
};

static ProcRecord text_get_extents_proc =
{
  "gimp_text_get_extents",
736 737
  "This procedure is deprecated! Use 'gimp_text_get_extents_fontname' instead.",
  "This procedure is deprecated! Use 'gimp_text_get_extents_fontname' instead.",
738 739 740
  "",
  "",
  "",
741
  "gimp_text_get_extents_fontname",
742
  GIMP_INTERNAL,
Manish Singh's avatar
Manish Singh committed
743 744 745 746 747 748
  11,
  text_get_extents_inargs,
  4,
  text_get_extents_outargs,
  { { text_get_extents_invoker } }
};