1999-03-19 23:04:16 +00:00
|
|
|
# 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>
|
|
|
|
|
|
|
|
# Text
|
|
|
|
|
|
|
|
sub pdb_misc {
|
|
|
|
&std_pdb_misc;
|
|
|
|
$author = 'Martin Edlman';
|
|
|
|
$date = '1998';
|
|
|
|
}
|
|
|
|
|
|
|
|
sub text_arg () {{
|
|
|
|
name => 'text',
|
|
|
|
type => 'string',
|
2003-08-19 19:08:11 +00:00
|
|
|
desc => 'The text to generate'
|
1999-03-19 23:04:16 +00:00
|
|
|
}}
|
|
|
|
|
|
|
|
sub fontname_arg () {{
|
|
|
|
name => 'fontname',
|
|
|
|
type => 'string',
|
2003-08-19 19:08:11 +00:00
|
|
|
desc => 'The name of the font'
|
1999-03-19 23:04:16 +00:00
|
|
|
}}
|
|
|
|
|
1999-03-21 02:14:08 +00:00
|
|
|
sub size_args () {(
|
|
|
|
{ name => 'size', type => '0 < float',
|
|
|
|
desc => 'The size of text in either pixels or points' },
|
2004-07-05 20:55:05 +00:00
|
|
|
{ name => 'size_type', type => 'enum GimpSizeType',
|
1999-03-21 02:14:08 +00:00
|
|
|
desc => 'The units of specified size: %%desc%%' }
|
|
|
|
)}
|
|
|
|
|
1999-03-19 23:04:16 +00:00
|
|
|
sub render_args () {(
|
|
|
|
&std_image_arg,
|
|
|
|
{ name => 'drawable', type => 'drawable',
|
|
|
|
desc => 'The affected drawable: (-1 for a new text layer)',
|
|
|
|
no_success => 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' },
|
|
|
|
&text_arg,
|
|
|
|
{ name => 'border', type => '-1 <= int32',
|
1999-03-21 02:14:08 +00:00
|
|
|
desc => 'The size of the border: %%desc%%' },
|
|
|
|
&std_antialias_arg,
|
|
|
|
&size_args
|
1999-03-19 23:04:16 +00:00
|
|
|
)}
|
|
|
|
|
1999-04-10 04:52:07 +00:00
|
|
|
@props = qw(foundry family weight slant set_width spacing registry encoding);
|
1999-03-19 23:04:16 +00:00
|
|
|
|
|
|
|
sub font_prop_args {
|
|
|
|
my @result;
|
1999-03-21 02:14:08 +00:00
|
|
|
foreach (@props) {
|
1999-04-10 04:52:07 +00:00
|
|
|
(my $desc = $_) =~ s/_/-/g;
|
2003-08-19 19:08:11 +00:00
|
|
|
push @result, { name => $_, type => 'string', no_validate => 1,
|
2003-07-30 00:43:56 +00:00
|
|
|
desc => qq/The font $desc/ }
|
1999-03-19 23:04:16 +00:00
|
|
|
}
|
|
|
|
@result;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub render_outargs {
|
|
|
|
@outargs = (
|
|
|
|
{ name => 'text_layer', type => 'layer',
|
|
|
|
desc => 'The new text layer', init => 1 }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub extents_outargs {
|
|
|
|
foreach (qw(width height ascent descent)) {
|
|
|
|
push @outargs, { name => $_, type => 'int32',
|
|
|
|
desc => "The $_ of the specified font" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-10 04:52:07 +00:00
|
|
|
sub text_fontname {
|
1999-03-19 23:04:16 +00:00
|
|
|
$blurb = <<'BLURB';
|
|
|
|
Add text at the specified location as a floating selection or a new layer.
|
|
|
|
BLURB
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
2001-08-11 21:35:23 +00:00
|
|
|
This tool requires a fontname matching an installed PangoFT2 font.
|
|
|
|
You can specify the fontsize in units of pixels
|
1999-04-10 04:52:07 +00:00
|
|
|
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
|
2001-08-11 21:35:23 +00:00
|
|
|
around the final rendered text. The border is measured in pixels.
|
2000-01-11 21:23:38 +00:00
|
|
|
|
1999-03-19 23:04:16 +00:00
|
|
|
HELP
|
|
|
|
|
1999-03-21 02:14:08 +00:00
|
|
|
&pdb_misc;
|
1999-04-10 04:52:07 +00:00
|
|
|
$author .= ' & Sven Neumann';
|
2001-08-11 21:35:23 +00:00
|
|
|
$date .= '- 2001';
|
1999-03-19 23:04:16 +00:00
|
|
|
|
1999-03-21 02:14:08 +00:00
|
|
|
@inargs = (
|
1999-04-10 04:52:07 +00:00
|
|
|
&render_args,
|
|
|
|
&fontname_arg
|
1999-03-21 02:14:08 +00:00
|
|
|
);
|
1999-03-19 23:04:16 +00:00
|
|
|
|
1999-03-21 02:14:08 +00:00
|
|
|
&render_outargs;
|
1999-03-19 23:04:16 +00:00
|
|
|
|
1999-03-21 02:14:08 +00:00
|
|
|
%invoke = (
|
1999-03-19 23:04:16 +00:00
|
|
|
code => <<'CODE'
|
|
|
|
{
|
2004-01-26 16:18:16 +00:00
|
|
|
if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
|
1999-04-10 04:52:07 +00:00
|
|
|
success = FALSE;
|
1999-03-19 23:04:16 +00:00
|
|
|
|
2004-01-26 15:34:47 +00:00
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
|
|
|
|
|
2004-04-14 23:37:34 +00:00
|
|
|
text_layer = text_render (gimage, drawable, context,
|
|
|
|
x, y, real_fontname, text,
|
2004-01-26 15:34:47 +00:00
|
|
|
border, antialias);
|
|
|
|
if (text_layer == NULL)
|
|
|
|
success = FALSE;
|
|
|
|
|
|
|
|
g_free (real_fontname);
|
|
|
|
}
|
1999-03-19 23:04:16 +00:00
|
|
|
}
|
|
|
|
CODE
|
1999-04-10 04:52:07 +00:00
|
|
|
);
|
1999-03-19 23:04:16 +00:00
|
|
|
}
|
|
|
|
|
1999-04-10 04:52:07 +00:00
|
|
|
sub text_get_extents_fontname {
|
1999-03-19 23:04:16 +00:00
|
|
|
$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
|
|
|
|
|
|
|
|
&pdb_misc;
|
1999-04-10 04:52:07 +00:00
|
|
|
$author .= ' & Sven Neumann';
|
2001-08-11 21:35:23 +00:00
|
|
|
$date .= '- 2001';
|
1999-04-10 04:52:07 +00:00
|
|
|
|
1999-03-19 23:04:16 +00:00
|
|
|
@inargs = (
|
|
|
|
&text_arg,
|
|
|
|
&size_args,
|
1999-04-10 04:52:07 +00:00
|
|
|
&fontname_arg
|
1999-03-19 23:04:16 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
&extents_outargs;
|
2000-06-22 03:21:20 +00:00
|
|
|
$outargs[0]->{void_ret} = 1;
|
1999-03-19 23:04:16 +00:00
|
|
|
|
|
|
|
%invoke = (
|
1999-04-10 04:52:07 +00:00
|
|
|
vars => [ 'gchar *real_fontname' ],
|
|
|
|
code => <<'CODE'
|
|
|
|
{
|
2001-08-11 21:35:23 +00:00
|
|
|
real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
|
1999-04-10 04:52:07 +00:00
|
|
|
|
|
|
|
success = text_get_extents (real_fontname, text,
|
|
|
|
&width, &height,
|
|
|
|
&ascent, &descent);
|
|
|
|
|
|
|
|
g_free (real_fontname);
|
|
|
|
}
|
|
|
|
CODE
|
1999-03-19 23:04:16 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
1999-04-10 04:52:07 +00:00
|
|
|
sub text {
|
1999-03-19 23:04:16 +00:00
|
|
|
$blurb = <<'BLURB';
|
|
|
|
Add text at the specified location as a floating selection or a new layer.
|
|
|
|
BLURB
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
2004-06-15 21:44:19 +00:00
|
|
|
This function is deprecated, use gimp_get_text_fontname() instead.
|
1999-03-19 23:04:16 +00:00
|
|
|
HELP
|
|
|
|
|
2004-06-15 21:44:19 +00:00
|
|
|
$deprecated = 1;
|
|
|
|
|
1999-03-19 23:04:16 +00:00
|
|
|
&pdb_misc;
|
|
|
|
|
|
|
|
@inargs = (
|
1999-04-10 04:52:07 +00:00
|
|
|
&render_args,
|
|
|
|
&font_prop_args
|
1999-03-19 23:04:16 +00:00
|
|
|
);
|
|
|
|
|
1999-03-21 02:14:08 +00:00
|
|
|
&render_outargs;
|
|
|
|
|
1999-03-19 23:04:16 +00:00
|
|
|
%invoke = (
|
2003-02-14 22:33:22 +00:00
|
|
|
code => <<'CODE'
|
|
|
|
{
|
2004-01-26 16:18:16 +00:00
|
|
|
if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
|
2003-02-14 22:33:22 +00:00
|
|
|
success = FALSE;
|
|
|
|
|
2004-01-26 15:34:47 +00:00
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
gchar *real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
|
|
|
|
|
2004-04-14 23:37:34 +00:00
|
|
|
text_layer = text_render (gimage, drawable, context,
|
|
|
|
x, y, real_fontname, text,
|
2004-01-26 15:34:47 +00:00
|
|
|
border, antialias);
|
|
|
|
if (text_layer == NULL)
|
|
|
|
success = FALSE;
|
|
|
|
|
|
|
|
g_free (real_fontname);
|
|
|
|
}
|
2003-02-14 22:33:22 +00:00
|
|
|
}
|
|
|
|
CODE
|
1999-04-10 04:52:07 +00:00
|
|
|
);
|
1999-03-19 23:04:16 +00:00
|
|
|
}
|
1999-03-21 02:14:08 +00:00
|
|
|
|
1999-04-10 04:52:07 +00:00
|
|
|
sub text_get_extents {
|
1999-03-21 02:14:08 +00:00
|
|
|
$blurb = 'Get extents of the bounding box for the specified text.';
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
2004-06-15 21:44:19 +00:00
|
|
|
This function is deprecated, use gimp_get_text_extents_fontname() instead.
|
1999-03-21 02:14:08 +00:00
|
|
|
HELP
|
|
|
|
|
2004-06-15 21:44:19 +00:00
|
|
|
$deprecated = 1;
|
|
|
|
|
1999-03-21 02:14:08 +00:00
|
|
|
&pdb_misc;
|
1999-04-10 04:52:07 +00:00
|
|
|
|
1999-03-21 02:14:08 +00:00
|
|
|
@inargs = (
|
|
|
|
&text_arg,
|
|
|
|
&size_args,
|
1999-04-10 04:52:07 +00:00
|
|
|
&font_prop_args
|
1999-03-21 02:14:08 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
&extents_outargs;
|
2000-06-22 03:21:20 +00:00
|
|
|
$outargs[0]->{void_ret} = 1;
|
1999-03-21 02:14:08 +00:00
|
|
|
|
|
|
|
%invoke = (
|
2003-02-14 22:33:22 +00:00
|
|
|
vars => [ 'gchar *real_fontname' ],
|
|
|
|
code => <<'CODE'
|
|
|
|
{
|
|
|
|
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
|
1999-03-21 02:14:08 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2004-01-26 16:18:16 +00:00
|
|
|
@headers = qw("libgimpbase/gimpbase.h" "text/gimptext-compat.h");
|
1999-04-04 05:59:08 +00:00
|
|
|
|
1999-04-10 04:52:07 +00:00
|
|
|
@procs = qw(text_fontname text_get_extents_fontname text text_get_extents);
|
2000-06-01 12:20:13 +00:00
|
|
|
%exports = (app => [@procs], lib => [@procs]);
|
1999-03-21 02:14:08 +00:00
|
|
|
|
|
|
|
$desc = 'Text procedures';
|
|
|
|
|
|
|
|
1;
|