249
129
g_free (real_fontname);
252
return_args = procedural_db_return_args (&text_get_extents_fontname_proc, success);
132
return_vals = gimp_procedure_get_return_values (procedure, success);
256
return_args[1].value.pdb_int = width;
257
return_args[2].value.pdb_int = height;
258
return_args[3].value.pdb_int = ascent;
259
return_args[4].value.pdb_int = descent;
136
g_value_set_int (&return_vals->values[1], width);
137
g_value_set_int (&return_vals->values[2], height);
138
g_value_set_int (&return_vals->values[3], ascent);
139
g_value_set_int (&return_vals->values[4], descent);
265
static ProcArg text_get_extents_fontname_inargs[] =
270
"The text to generate (in UTF-8 encoding)"
275
"The size of text in either pixels or points"
280
"The units of specified size: GIMP_PIXELS (0) or GIMP_POINTS (1)"
285
"The name of the font"
289
static ProcArg text_get_extents_fontname_outargs[] =
294
"The width of the specified font"
299
"The height of the specified font"
304
"The ascent of the specified font"
309
"The descent of the specified font"
313
static ProcRecord text_get_extents_fontname_proc =
315
"gimp_text_get_extents_fontname",
316
"Get extents of the bounding box for the specified text.",
317
"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.",
318
"Martin Edlman & Sven Neumann",
319
"Spencer Kimball & Peter Mattis",
324
text_get_extents_fontname_inargs,
326
text_get_extents_fontname_outargs,
327
{ { text_get_extents_fontname_invoker } }
331
text_invoker (Gimp *gimp,
332
GimpContext *context,
333
GimpProgress *progress,
146
text_invoker (GimpProcedure *procedure,
148
GimpContext *context,
149
GimpProgress *progress,
150
const GValueArray *args)
336
152
gboolean success = TRUE;
337
Argument *return_args;
153
GValueArray *return_vals;
339
155
GimpDrawable *drawable;
344
160
gboolean antialias;
346
162
gint32 size_type;
163
const gchar *foundry;
167
const gchar *set_width;
168
const gchar *spacing;
169
const gchar *registry;
170
const gchar *encoding;
355
171
GimpLayer *text_layer = NULL;
357
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
358
if (! GIMP_IS_IMAGE (gimage))
361
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int);
363
x = args[2].value.pdb_float;
365
y = args[3].value.pdb_float;
367
text = (gchar *) args[4].value.pdb_pointer;
368
if (text == NULL || !g_utf8_validate (text, -1, NULL))
371
border = args[5].value.pdb_int;
375
antialias = args[6].value.pdb_int ? TRUE : FALSE;
377
size = args[7].value.pdb_float;
381
size_type = args[8].value.pdb_int;
382
if (size_type < GIMP_PIXELS || size_type > GIMP_POINTS)
385
foundry = (gchar *) args[9].value.pdb_pointer;
389
family = (gchar *) args[10].value.pdb_pointer;
393
weight = (gchar *) args[11].value.pdb_pointer;
397
slant = (gchar *) args[12].value.pdb_pointer;
401
set_width = (gchar *) args[13].value.pdb_pointer;
402
if (set_width == NULL)
405
spacing = (gchar *) args[14].value.pdb_pointer;
409
registry = (gchar *) args[15].value.pdb_pointer;
410
if (registry == NULL)
413
encoding = (gchar *) args[16].value.pdb_pointer;
414
if (encoding == NULL)
173
image = gimp_value_get_image (&args->values[0], gimp);
174
drawable = gimp_value_get_drawable (&args->values[1], gimp);
175
x = g_value_get_double (&args->values[2]);
176
y = g_value_get_double (&args->values[3]);
177
text = g_value_get_string (&args->values[4]);
178
border = g_value_get_int (&args->values[5]);
179
antialias = g_value_get_boolean (&args->values[6]);
180
size = g_value_get_double (&args->values[7]);
181
size_type = g_value_get_enum (&args->values[8]);
182
foundry = g_value_get_string (&args->values[9]);
183
family = g_value_get_string (&args->values[10]);
184
weight = g_value_get_string (&args->values[11]);
185
slant = g_value_get_string (&args->values[12]);
186
set_width = g_value_get_string (&args->values[13]);
187
spacing = g_value_get_string (&args->values[14]);
188
registry = g_value_get_string (&args->values[15]);
189
encoding = g_value_get_string (&args->values[16]);
634
261
g_free (real_fontname);
637
return_args = procedural_db_return_args (&text_get_extents_proc, success);
264
return_vals = gimp_procedure_get_return_values (procedure, success);
641
return_args[1].value.pdb_int = width;
642
return_args[2].value.pdb_int = height;
643
return_args[3].value.pdb_int = ascent;
644
return_args[4].value.pdb_int = descent;
268
g_value_set_int (&return_vals->values[1], width);
269
g_value_set_int (&return_vals->values[2], height);
270
g_value_set_int (&return_vals->values[3], ascent);
271
g_value_set_int (&return_vals->values[4], descent);
650
static ProcArg text_get_extents_inargs[] =
655
"The text to generate (in UTF-8 encoding)"
660
"The size of text in either pixels or points"
665
"The units of specified size: GIMP_PIXELS (0) or GIMP_POINTS (1)"
709
static ProcArg text_get_extents_outargs[] =
714
"The width of the specified font"
719
"The height of the specified font"
724
"The ascent of the specified font"
729
"The descent of the specified font"
733
static ProcRecord text_get_extents_proc =
735
"gimp_text_get_extents",
736
"This procedure is deprecated! Use 'gimp_text_get_extents_fontname' instead.",
737
"This procedure is deprecated! Use 'gimp_text_get_extents_fontname' instead.",
741
"gimp_text_get_extents_fontname",
744
text_get_extents_inargs,
746
text_get_extents_outargs,
747
{ { text_get_extents_invoker } }
278
register_text_tool_procs (GimpPDB *pdb)
280
GimpProcedure *procedure;
285
procedure = gimp_procedure_new (text_fontname_invoker);
286
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-text-fontname");
287
gimp_procedure_set_static_strings (procedure,
288
"gimp-text-fontname",
289
"Add text at the specified location as a floating selection or a new layer.",
290
"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. Parameter size-type is not used and is currently ignored. If you need to display a font in points, divide the size in points by 72.0 and multiply it by the image's vertical resolution.",
291
"Martin Edlman & Sven Neumann",
292
"Spencer Kimball & Peter Mattis",
295
gimp_procedure_add_argument (procedure,
296
gimp_param_spec_image_id ("image",
300
GIMP_PARAM_READWRITE));
301
gimp_procedure_add_argument (procedure,
302
gimp_param_spec_drawable_id ("drawable",
304
"The affected drawable: (-1 for a new text layer)",
306
GIMP_PARAM_READWRITE));
307
gimp_procedure_add_argument (procedure,
308
g_param_spec_double ("x",
310
"The x coordinate for the left of the text bounding box",
311
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
312
GIMP_PARAM_READWRITE));
313
gimp_procedure_add_argument (procedure,
314
g_param_spec_double ("y",
316
"The y coordinate for the top of the text bounding box",
317
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
318
GIMP_PARAM_READWRITE));
319
gimp_procedure_add_argument (procedure,
320
gimp_param_spec_string ("text",
322
"The text to generate (in UTF-8 encoding)",
325
GIMP_PARAM_READWRITE));
326
gimp_procedure_add_argument (procedure,
327
gimp_param_spec_int32 ("border",
329
"The size of the border",
331
GIMP_PARAM_READWRITE));
332
gimp_procedure_add_argument (procedure,
333
g_param_spec_boolean ("antialias",
337
GIMP_PARAM_READWRITE));
338
gimp_procedure_add_argument (procedure,
339
g_param_spec_double ("size",
341
"The size of text in either pixels or points",
343
GIMP_PARAM_READWRITE));
344
gimp_procedure_add_argument (procedure,
345
g_param_spec_enum ("size-type",
347
"The units of specified size",
350
GIMP_PARAM_READWRITE));
351
gimp_procedure_add_argument (procedure,
352
gimp_param_spec_string ("fontname",
354
"The name of the font",
357
GIMP_PARAM_READWRITE));
358
gimp_procedure_add_return_value (procedure,
359
gimp_param_spec_layer_id ("text-layer",
361
"The new text layer or -1 if no layer was created.",
363
GIMP_PARAM_READWRITE));
364
gimp_pdb_register_procedure (pdb, procedure);
365
g_object_unref (procedure);
368
* gimp-text-get-extents-fontname
370
procedure = gimp_procedure_new (text_get_extents_fontname_invoker);
371
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-text-get-extents-fontname");
372
gimp_procedure_set_static_strings (procedure,
373
"gimp-text-get-extents-fontname",
374
"Get extents of the bounding box for the specified text.",
375
"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. Parameter size-type is not used and is currently ignored. If you need to display a font in points, divide the size in points by 72.0 and multiply it by the vertical resolution of the image you are taking into account.",
376
"Martin Edlman & Sven Neumann",
377
"Spencer Kimball & Peter Mattis",
380
gimp_procedure_add_argument (procedure,
381
gimp_param_spec_string ("text",
383
"The text to generate (in UTF-8 encoding)",
386
GIMP_PARAM_READWRITE));
387
gimp_procedure_add_argument (procedure,
388
g_param_spec_double ("size",
390
"The size of text in either pixels or points",
392
GIMP_PARAM_READWRITE));
393
gimp_procedure_add_argument (procedure,
394
g_param_spec_enum ("size-type",
396
"The units of specified size",
399
GIMP_PARAM_READWRITE));
400
gimp_procedure_add_argument (procedure,
401
gimp_param_spec_string ("fontname",
403
"The name of the font",
406
GIMP_PARAM_READWRITE));
407
gimp_procedure_add_return_value (procedure,
408
gimp_param_spec_int32 ("width",
410
"The width of the specified font",
411
G_MININT32, G_MAXINT32, 0,
412
GIMP_PARAM_READWRITE));
413
gimp_procedure_add_return_value (procedure,
414
gimp_param_spec_int32 ("height",
416
"The height of the specified font",
417
G_MININT32, G_MAXINT32, 0,
418
GIMP_PARAM_READWRITE));
419
gimp_procedure_add_return_value (procedure,
420
gimp_param_spec_int32 ("ascent",
422
"The ascent of the specified font",
423
G_MININT32, G_MAXINT32, 0,
424
GIMP_PARAM_READWRITE));
425
gimp_procedure_add_return_value (procedure,
426
gimp_param_spec_int32 ("descent",
428
"The descent of the specified font",
429
G_MININT32, G_MAXINT32, 0,
430
GIMP_PARAM_READWRITE));
431
gimp_pdb_register_procedure (pdb, procedure);
432
g_object_unref (procedure);
437
procedure = gimp_procedure_new (text_invoker);
438
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-text");
439
gimp_procedure_set_static_strings (procedure,
441
"This procedure is deprecated! Use 'gimp-text-fontname' instead.",
442
"This procedure is deprecated! Use 'gimp-text-fontname' instead.",
446
"gimp-text-fontname");
447
gimp_procedure_add_argument (procedure,
448
gimp_param_spec_image_id ("image",
452
GIMP_PARAM_READWRITE));
453
gimp_procedure_add_argument (procedure,
454
gimp_param_spec_drawable_id ("drawable",
456
"The affected drawable: (-1 for a new text layer)",
458
GIMP_PARAM_READWRITE));
459
gimp_procedure_add_argument (procedure,
460
g_param_spec_double ("x",
462
"The x coordinate for the left of the text bounding box",
463
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
464
GIMP_PARAM_READWRITE));
465
gimp_procedure_add_argument (procedure,
466
g_param_spec_double ("y",
468
"The y coordinate for the top of the text bounding box",
469
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
470
GIMP_PARAM_READWRITE));
471
gimp_procedure_add_argument (procedure,
472
gimp_param_spec_string ("text",
474
"The text to generate (in UTF-8 encoding)",
477
GIMP_PARAM_READWRITE));
478
gimp_procedure_add_argument (procedure,
479
gimp_param_spec_int32 ("border",
481
"The size of the border",
483
GIMP_PARAM_READWRITE));
484
gimp_procedure_add_argument (procedure,
485
g_param_spec_boolean ("antialias",
489
GIMP_PARAM_READWRITE));
490
gimp_procedure_add_argument (procedure,
491
g_param_spec_double ("size",
493
"The size of text in either pixels or points",
495
GIMP_PARAM_READWRITE));
496
gimp_procedure_add_argument (procedure,
497
g_param_spec_enum ("size-type",
499
"The units of specified size",
502
GIMP_PARAM_READWRITE));
503
gimp_procedure_add_argument (procedure,
504
gimp_param_spec_string ("foundry",
509
GIMP_PARAM_READWRITE));
510
gimp_procedure_add_argument (procedure,
511
gimp_param_spec_string ("family",
516
GIMP_PARAM_READWRITE));
517
gimp_procedure_add_argument (procedure,
518
gimp_param_spec_string ("weight",
523
GIMP_PARAM_READWRITE));
524
gimp_procedure_add_argument (procedure,
525
gimp_param_spec_string ("slant",
530
GIMP_PARAM_READWRITE));
531
gimp_procedure_add_argument (procedure,
532
gimp_param_spec_string ("set-width",
534
"The font set-width",
537
GIMP_PARAM_READWRITE));
538
gimp_procedure_add_argument (procedure,
539
gimp_param_spec_string ("spacing",
544
GIMP_PARAM_READWRITE));
545
gimp_procedure_add_argument (procedure,
546
gimp_param_spec_string ("registry",
551
GIMP_PARAM_READWRITE));
552
gimp_procedure_add_argument (procedure,
553
gimp_param_spec_string ("encoding",
558
GIMP_PARAM_READWRITE));
559
gimp_procedure_add_return_value (procedure,
560
gimp_param_spec_layer_id ("text-layer",
562
"The new text layer or -1 if no layer was created.",
564
GIMP_PARAM_READWRITE));
565
gimp_pdb_register_procedure (pdb, procedure);
566
g_object_unref (procedure);
569
* gimp-text-get-extents
571
procedure = gimp_procedure_new (text_get_extents_invoker);
572
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-text-get-extents");
573
gimp_procedure_set_static_strings (procedure,
574
"gimp-text-get-extents",
575
"This procedure is deprecated! Use 'gimp-text-get-extents-fontname' instead.",
576
"This procedure is deprecated! Use 'gimp-text-get-extents-fontname' instead.",
580
"gimp-text-get-extents-fontname");
581
gimp_procedure_add_argument (procedure,
582
gimp_param_spec_string ("text",
584
"The text to generate (in UTF-8 encoding)",
587
GIMP_PARAM_READWRITE));
588
gimp_procedure_add_argument (procedure,
589
g_param_spec_double ("size",
591
"The size of text in either pixels or points",
593
GIMP_PARAM_READWRITE));
594
gimp_procedure_add_argument (procedure,
595
g_param_spec_enum ("size-type",
597
"The units of specified size",
600
GIMP_PARAM_READWRITE));
601
gimp_procedure_add_argument (procedure,
602
gimp_param_spec_string ("foundry",
607
GIMP_PARAM_READWRITE));
608
gimp_procedure_add_argument (procedure,
609
gimp_param_spec_string ("family",
614
GIMP_PARAM_READWRITE));
615
gimp_procedure_add_argument (procedure,
616
gimp_param_spec_string ("weight",
621
GIMP_PARAM_READWRITE));
622
gimp_procedure_add_argument (procedure,
623
gimp_param_spec_string ("slant",
628
GIMP_PARAM_READWRITE));
629
gimp_procedure_add_argument (procedure,
630
gimp_param_spec_string ("set-width",
632
"The font set-width",
635
GIMP_PARAM_READWRITE));
636
gimp_procedure_add_argument (procedure,
637
gimp_param_spec_string ("spacing",
642
GIMP_PARAM_READWRITE));
643
gimp_procedure_add_argument (procedure,
644
gimp_param_spec_string ("registry",
649
GIMP_PARAM_READWRITE));
650
gimp_procedure_add_argument (procedure,
651
gimp_param_spec_string ("encoding",
656
GIMP_PARAM_READWRITE));
657
gimp_procedure_add_return_value (procedure,
658
gimp_param_spec_int32 ("width",
660
"The width of the specified font",
661
G_MININT32, G_MAXINT32, 0,
662
GIMP_PARAM_READWRITE));
663
gimp_procedure_add_return_value (procedure,
664
gimp_param_spec_int32 ("height",
666
"The height of the specified font",
667
G_MININT32, G_MAXINT32, 0,
668
GIMP_PARAM_READWRITE));
669
gimp_procedure_add_return_value (procedure,
670
gimp_param_spec_int32 ("ascent",
672
"The ascent of the specified font",
673
G_MININT32, G_MAXINT32, 0,
674
GIMP_PARAM_READWRITE));
675
gimp_procedure_add_return_value (procedure,
676
gimp_param_spec_int32 ("descent",
678
"The descent of the specified font",
679
G_MININT32, G_MAXINT32, 0,
680
GIMP_PARAM_READWRITE));
681
gimp_pdb_register_procedure (pdb, procedure);
682
g_object_unref (procedure);