Gimp/tools/pdbgen/pdb/text_tool.pdb
Michael Natterer 66a66b3218 added "gboolean none_ok" members to GimpParamSpecImageID,
2006-05-06  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpparamspecs.[ch]: added "gboolean none_ok" members
	to GimpParamSpecImageID, GimpParamSpecItemID and
	GimpParamSpecDisplayID.  If none_ok is set, allow '0' and '-1' as
	valid IDs. Added "none_ok" parameter to all ID param spec
	constructors.

	* app/pdb/gimp-pdb-compat.c: set none_ok to TRUE in all compat
	param specs, so only IDs that are really random garbage don't pass
	validation. Fixes validation errors with 0 and -1 IDs.

	* tools/pdbgen/app.pl: set none_ok to FALSE by default. Added
	support for $arg->{none_ok} to control it.

	* tools/pdbgen/pdb/image.pdb
	* tools/pdbgen/pdb/progress.pdb
	* tools/pdbgen/pdb/text_tool.pdb: use none_ok instead of
	no_success (which disables validation entirely).

	* app/pdb/[many]_cmds.c: regenerated.
2006-05-06 18:57:51 +00:00

272 lines
8.8 KiB
Text

# The GIMP -- an image manipulation program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
# 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.
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
sub text_fontname {
$blurb = <<'BLURB';
Add text at the specified location as a floating selection or a new layer.
BLURB
$help = <<'HELP';
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.
HELP
&std_pdb_misc;
$author = 'Martin Edlman & Sven Neumann';
$date = '1998- 2001';
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'drawable', type => 'drawable',
desc => 'The affected drawable: (-1 for a new text layer)',
none_ok => 1 },
{ name => 'x', type => 'float',
desc => 'The x coordinate for the left of the text bounding box' },
{ name => 'y', type => 'float',
desc => 'The y coordinate for the top of the text bounding box' },
{ name => 'text', type => 'string',
desc => 'The text to generate (in UTF-8 encoding)' },
{ name => 'border', type => '-1 <= int32',
desc => 'The size of the border %%desc%%' },
{ name => 'antialias', type => 'boolean',
desc => 'Antialiasing %%desc%%' },
{ name => 'size', type => '0 < float',
desc => 'The size of text in either pixels or points' },
{ name => 'size_type', type => 'enum GimpSizeType',
desc => 'The units of specified size: %%desc%%' },
{ name => 'fontname', type => 'string',
desc => 'The name of the font' }
);
@outargs = (
{ name => 'text_layer', type => 'layer',
desc => 'The new text layer or -1 if no layer was created.' }
);
%invoke = (
code => <<'CODE'
{
if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
success = FALSE;
if (success)
{
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
text_layer = text_render (image, drawable, context,
x, y, real_fontname, text,
border, antialias);
g_free (real_fontname);
}
}
CODE
);
}
sub text_get_extents_fontname {
$blurb = 'Get extents of the bounding box for the specified text.';
$help = <<'HELP';
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.
HELP
&std_pdb_misc;
$author = 'Martin Edlman & Sven Neumann';
$date = '1998- 2001';
@inargs = (
{ name => 'text', type => 'string',
desc => 'The text to generate (in UTF-8 encoding)' },
{ name => 'size', type => '0 < float',
desc => 'The size of text in either pixels or points' },
{ name => 'size_type', type => 'enum GimpSizeType',
desc => 'The units of specified size: %%desc%%' },
{ name => 'fontname', type => 'string',
desc => 'The name of the font' }
);
@outargs = (
{ name => 'width', type => 'int32', void_ret => 1,
desc => 'The width of the specified font' },
{ name => 'height', type => 'int32',
desc => 'The height of the specified font' },
{ name => 'ascent', type => 'int32',
desc => 'The ascent of the specified font' },
{ name => 'descent', type => 'int32',
desc => 'The descent of the specified font' }
);
%invoke = (
code => <<'CODE'
{
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
success = text_get_extents (real_fontname, text,
&width, &height,
&ascent, &descent);
g_free (real_fontname);
}
CODE
);
}
sub text {
&std_pdb_deprecated ('gimp-text-fontname');
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'drawable', type => 'drawable',
desc => 'The affected drawable: (-1 for a new text layer)',
none_ok => 1 },
{ name => 'x', type => 'float',
desc => 'The x coordinate for the left of the text bounding box' },
{ name => 'y', type => 'float',
desc => 'The y coordinate for the top of the text bounding box' },
{ name => 'text', type => 'string',
desc => 'The text to generate (in UTF-8 encoding)' },
{ name => 'border', type => '-1 <= int32',
desc => 'The size of the border %%desc%%' },
{ name => 'antialias', type => 'boolean',
desc => 'Antialiasing %%desc%%' },
{ name => 'size', type => '0 < float',
desc => 'The size of text in either pixels or points' },
{ name => 'size_type', type => 'enum GimpSizeType',
desc => 'The units of specified size: %%desc%%' },
{ name => 'foundry', type => 'string', no_validate => 1,
desc => 'The font foundry' },
{ name => 'family', type => 'string', no_validate => 1,
desc => 'The font family' },
{ name => 'weight', type => 'string', no_validate => 1,
desc => 'The font weight' },
{ name => 'slant', type => 'string', no_validate => 1,
desc => 'The font slant' },
{ name => 'set_width', type => 'string', no_validate => 1,
desc => 'The font set-width' },
{ name => 'spacing', type => 'string', no_validate => 1,
desc => 'The font spacing' },
{ name => 'registry', type => 'string', no_validate => 1,
desc => 'The font registry' },
{ name => 'encoding', type => 'string', no_validate => 1,
desc => 'The font encoding' }
);
@outargs = (
{ name => 'text_layer', type => 'layer',
desc => 'The new text layer or -1 if no layer was created.' }
);
%invoke = (
code => <<'CODE'
{
if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
success = FALSE;
if (success)
{
gchar *real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
text_layer = text_render (image, drawable, context,
x, y, real_fontname, text,
border, antialias);
g_free (real_fontname);
}
}
CODE
);
}
sub text_get_extents {
&std_pdb_deprecated ('gimp-text-get-extents-fontname');
@inargs = (
{ name => 'text', type => 'string',
desc => 'The text to generate (in UTF-8 encoding)' },
{ name => 'size', type => '0 < float',
desc => 'The size of text in either pixels or points' },
{ name => 'size_type', type => 'enum GimpSizeType',
desc => 'The units of specified size: %%desc%%' },
{ name => 'foundry', type => 'string', no_validate => 1,
desc => 'The font foundry' },
{ name => 'family', type => 'string', no_validate => 1,
desc => 'The font family' },
{ name => 'weight', type => 'string', no_validate => 1,
desc => 'The font weight' },
{ name => 'slant', type => 'string', no_validate => 1,
desc => 'The font slant' },
{ name => 'set_width', type => 'string', no_validate => 1,
desc => 'The font set-width' },
{ name => 'spacing', type => 'string', no_validate => 1,
desc => 'The font spacing' },
{ name => 'registry', type => 'string', no_validate => 1,
desc => 'The font registry' },
{ name => 'encoding', type => 'string', no_validate => 1,
desc => 'The font encoding' }
);
@outargs = (
{ name => 'width', type => 'int32', void_ret => 1,
desc => 'The width of the specified font' },
{ name => 'height', type => 'int32',
desc => 'The height of the specified font' },
{ name => 'ascent', type => 'int32',
desc => 'The ascent of the specified font' },
{ name => 'descent', type => 'int32',
desc => 'The descent of the specified font' }
);
%invoke = (
code => <<'CODE'
{
gchar *real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
success = text_get_extents (real_fontname, text,
&width, &height,
&ascent, &descent);
g_free (real_fontname);
}
CODE
);
}
@headers = qw("libgimpbase/gimpbase.h" "text/gimptext-compat.h");
@procs = qw(text_fontname text_get_extents_fontname
text text_get_extents);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Text procedures';
1;