mirror of https://github.com/GNOME/gimp.git
parent
04fb65d8a0
commit
139811d03d
|
@ -1,4 +1,92 @@
|
|||
Some proto-PDB code generation stuff lives here. More docs to come. For now,
|
||||
don't mess with it.
|
||||
Some mostly unfinished docs are here.
|
||||
|
||||
-Yosh
|
||||
|
||||
PDBGEN
|
||||
------------------
|
||||
|
||||
What is this?
|
||||
It's a tool to automate much of the drudge work of making PDB interfaces
|
||||
to GIMP internals. Right now, it generates PDB description records,
|
||||
argument marshallers (with sanity checking) for the app side, as well
|
||||
as libgimp wrappers for C plugins. It's written so that extending it
|
||||
to provide support for CORBA and other languages suited to static
|
||||
autogeneration.
|
||||
|
||||
Anatomy of a PDB descriptor:
|
||||
PDB descriptors are Perl code. You define a subroutine, which corresponds
|
||||
to the PDB function you want to create. You then fill certain special
|
||||
variables to fully describe all the information pdbgen needs to generate
|
||||
code. Since it's perl, you can do practically whatever perl lets you
|
||||
do to help you do this. However, at the simplest level, you don't need
|
||||
to know perl at all to make PDB descriptors.
|
||||
|
||||
Annotated description:
|
||||
For example, we will look at gimp_display_new, specified in gdisplay.pdb.
|
||||
|
||||
sub display_new {
|
||||
|
||||
We start with the name of our PDB function (not including the "gimp_" prefix).
|
||||
|
||||
$blurb = 'Create a new display for the specified image.';
|
||||
|
||||
This directly corresponds to the "blurb" field in the ProcRecord.
|
||||
|
||||
$help = <<'HELP';
|
||||
Creates a new display for the specified image. If the image already has a
|
||||
display, another is added. Multiple displays are handled transparently by the
|
||||
GIMP. The newly created display is returned and can be subsequently destroyed
|
||||
with a call to 'gimp-display-delete'. This procedure only makes sense for use
|
||||
with the GIMP UI.
|
||||
HELP
|
||||
|
||||
This is the help field. Notice because it is a long string, we used HERE
|
||||
document syntax to split it over multiple lines. Any extra whitespace
|
||||
in $blurb or $help, including newlines, is automatically stripped, so you
|
||||
don't have to worry about that.
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
This is the "author", "copyright", and "date" fields. Since S&P are quite
|
||||
common, they get a special shortcut which fills these in for you. Stuff
|
||||
like this is defined in stddefs.pdb.
|
||||
|
||||
@inargs = ( &std_image_arg );
|
||||
|
||||
You specify arguments in a list. Again, your basic image is very common,
|
||||
so it gets a shortcut.
|
||||
|
||||
@outargs = (
|
||||
{ name => 'display', type => 'display',
|
||||
desc => 'The new display', alias => 'gdisp', init => 1 }
|
||||
);
|
||||
|
||||
This is a real argument. It has a name, type, description at a minumum.
|
||||
"alias" lets you use the alias name in your invoker code, but the real
|
||||
name is still shown in the ProcRecord. This is useful not only as a
|
||||
shorthand, but for grabbing variables defined somewhere else (or constants),
|
||||
in conjunction with the "no_declare" flag. "init" simply says initialize
|
||||
this variable to a dummy value (in this case to placate gcc warnings)
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("gdisplay.h") ],
|
||||
|
||||
These are the headers needed for the functions you call.
|
||||
|
||||
vars => [ 'guint scale = 0x101' ],
|
||||
|
||||
Extra variables can be put here for your invoker.
|
||||
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (gimage->layers == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
success = ((gdisp = gdisplay_new (gimage, scale)) != NULL);
|
||||
}
|
||||
CODE
|
||||
|
||||
The actual invoker code. Since it's a multiline block, we put curly braces
|
||||
in the beginning.
|
||||
|
||||
|
||||
|
|
|
@ -29,6 +29,18 @@ $destdir = "$main::destdir/app";
|
|||
*write_file = \&Gimp::CodeGen::util::write_file;
|
||||
*FILE_EXT = \$Gimp::CodeGen::util::FILE_EXT;
|
||||
|
||||
use Text::Wrap qw(wrap);
|
||||
|
||||
sub quotewrap {
|
||||
my ($str, $indent) = @_;
|
||||
my $leading = ' ' x $indent . '"';
|
||||
$Text::Wrap::columns = 1000;
|
||||
$str = wrap($leading, $leading, $str);
|
||||
$str =~ s/^\s*//s;
|
||||
$str =~ s/(.)$/$1"/mg;
|
||||
$str;
|
||||
}
|
||||
|
||||
sub declare_args {
|
||||
my $proc = shift;
|
||||
my $out = shift;
|
||||
|
@ -98,7 +110,7 @@ sub make_args {
|
|||
{
|
||||
PDB_$arg_types{$type}->{name},
|
||||
"$arg->{name}",
|
||||
"$desc"
|
||||
@{[ "ewrap($desc, 4) ]}
|
||||
},
|
||||
CODE
|
||||
}
|
||||
|
@ -152,36 +164,60 @@ CODE
|
|||
$code .= ' ? TRUE : FALSE' if $pdbtype eq 'boolean';
|
||||
$code .= ";\n";
|
||||
|
||||
if ($pdbtype eq 'string') {
|
||||
$code .= ' ' x 2 . "success = $var != NULL;\n";
|
||||
}
|
||||
elsif (defined $typeinfo[0] || defined $typeinfo[2]) {
|
||||
my $tests = 0; my $extra = "";
|
||||
|
||||
if ($pdbtype eq 'enum') {
|
||||
my $name = pop @typeinfo;
|
||||
|
||||
foreach (@typeinfo) { $extra .= " && $var != $_" }
|
||||
|
||||
$typeinfo[0] = $enums{$name}->{start};
|
||||
$typeinfo[1] = '>=';
|
||||
$typeinfo[2] = $enums{$name}->{end};
|
||||
$typeinfo[3] = '<=';
|
||||
if (!exists $_->{no_success}) {
|
||||
if ($pdbtype eq 'string') {
|
||||
$code .= ' ' x 2 . "success = $var != NULL;\n";
|
||||
}
|
||||
elsif ($pdbtype eq 'enum' && !$enums{$typeinfo[0]}->{contig}) {
|
||||
my %vals; my $symbols = $enums{pop @typeinfo}->{symbols};
|
||||
@vals{@$symbols}++; delete @vals{@typeinfo};
|
||||
|
||||
$code .= <<CODE;
|
||||
switch ($var)
|
||||
{
|
||||
CODE
|
||||
|
||||
$code .= ' ' x 2 . "success = ";
|
||||
foreach (@$symbols) {
|
||||
$code .= ' ' x 4 . "case $_:\n" if exists $vals{$_};
|
||||
}
|
||||
|
||||
if (defined $typeinfo[0]) {
|
||||
$code .= "$var $typeinfo[1] $typeinfo[0]";
|
||||
$tests++;
|
||||
$code .= <<CODE;
|
||||
break;
|
||||
|
||||
default:
|
||||
success = FALSE;
|
||||
break;
|
||||
}
|
||||
CODE
|
||||
}
|
||||
elsif (defined $typeinfo[0] || defined $typeinfo[2]) {
|
||||
my $tests = 0; my $extra = "";
|
||||
|
||||
if (defined $typeinfo[2]) {
|
||||
$code .= ' && ' if $tests;
|
||||
$code .= "$var $typeinfo[3] $typeinfo[2]";
|
||||
if ($pdbtype eq 'enum') {
|
||||
my $symbols = $enums{pop @typeinfo}->{symbols};
|
||||
|
||||
foreach (@typeinfo) { $extra .= " && $var != $_" }
|
||||
|
||||
$typeinfo[0] = $symbols->[0];
|
||||
$typeinfo[1] = '>=';
|
||||
$typeinfo[2] = $symbols->[$#$symbols];
|
||||
$typeinfo[3] = '<=';
|
||||
}
|
||||
|
||||
$code .= ' ' x 2 . "success = ";
|
||||
|
||||
if (defined $typeinfo[0]) {
|
||||
$code .= "$var $typeinfo[1] $typeinfo[0]";
|
||||
$tests++;
|
||||
}
|
||||
|
||||
if (defined $typeinfo[2]) {
|
||||
$code .= ' && ' if $tests;
|
||||
$code .= "$var $typeinfo[3] $typeinfo[2]";
|
||||
}
|
||||
|
||||
$code .= "$extra;\n";
|
||||
}
|
||||
|
||||
$code .= "$extra;\n";
|
||||
}
|
||||
|
||||
if ($code =~ /success/) {
|
||||
|
@ -339,8 +375,8 @@ CODE
|
|||
static ProcRecord ${name}_proc =
|
||||
{
|
||||
"gimp_$name",
|
||||
"$proc->{blurb}",
|
||||
"$proc->{help}",
|
||||
@{[ "ewrap($proc->{blurb}, 2) ]},
|
||||
@{[ "ewrap($proc->{help}, 2) ]},
|
||||
"$proc->{author}",
|
||||
"$proc->{copyright}",
|
||||
"$proc->{date}",
|
||||
|
|
|
@ -0,0 +1,193 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
# The GIMP -- an image manipulation program
|
||||
# Copyright (C) 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
# 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 WITHOUTFILE 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.
|
||||
|
||||
BEGIN {
|
||||
$destdir = '.';
|
||||
}
|
||||
|
||||
use Text::Wrap qw(wrap $columns);
|
||||
$columns = 79;
|
||||
|
||||
my $header = <<'HEADER';
|
||||
:# The GIMP -- an image manipulation program
|
||||
:# Copyright (C) 1999 Manish Singh <yosh@gimp.org>
|
||||
:
|
||||
:# 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 WITHOUTFILE 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.
|
||||
:
|
||||
:# autogenerated by enumgen.pl
|
||||
:
|
||||
:package Gimp::CodeGen::enums;
|
||||
:
|
||||
:%enums = (
|
||||
HEADER
|
||||
|
||||
my $footer = <<'FOOTER';
|
||||
:);
|
||||
:
|
||||
:foreach $e (values %enums) {
|
||||
: $e->{info} = "";
|
||||
: foreach (@{$e->{symbols}}) { $e->{info} .= "$_ ($e->{mapping}->{$_}), " }
|
||||
: $e->{info} =~ s/, $//;
|
||||
:}
|
||||
:
|
||||
:1;
|
||||
FOOTER
|
||||
|
||||
$header =~ s/^://mg;
|
||||
$footer =~ s/^://mg;
|
||||
|
||||
my ($enumname, $contig, $symbols, @mapping, $before);
|
||||
|
||||
# Most of this enum parsing stuff was swiped from makeenums.pl in GTK+
|
||||
sub parse_entries {
|
||||
my $file = shift;
|
||||
|
||||
while (<$file>) {
|
||||
# Read lines until we have no open comments
|
||||
while (m@/\*
|
||||
([^*]|\*(?!/))*$
|
||||
@x) {
|
||||
my $new;
|
||||
defined ($new = <$file>) || die "Unmatched comment";
|
||||
$_ .= $new;
|
||||
}
|
||||
# Now strip comments
|
||||
s@/\*(?!<)
|
||||
([^*]+|\*(?!/))*
|
||||
\*/@@gx;
|
||||
|
||||
s@\n@ @;
|
||||
|
||||
next if m@^\s*$@;
|
||||
|
||||
# Handle include files
|
||||
if (/^\#include\s*<([^>]*)>/ ) {
|
||||
my $file= "../$1";
|
||||
open NEWFILE, $file or die "Cannot open include file $file: $!\n";
|
||||
|
||||
if (&parse_entries (\*NEWFILE)) {
|
||||
return 1;
|
||||
} else {
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
if (/^\s*\}\s*(\w+)/) {
|
||||
$enumname = $1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (m@^\s*
|
||||
(\w+)\s* # name
|
||||
(?:=( # value
|
||||
(?:[^,/]|/(?!\*))*
|
||||
))?,?\s*
|
||||
(?:/\*< # options
|
||||
(([^*]|\*(?!/))*)
|
||||
>\*/)?
|
||||
\s*$
|
||||
@x) {
|
||||
my ($name, $value) = ($1, $2);
|
||||
|
||||
$symbols .= $name . ' ';
|
||||
|
||||
# Figure out a default value (not really foolproof)
|
||||
$value = $before + 1 if !defined $value;
|
||||
$value =~ s/\s*$//s;
|
||||
$value =~ s/^\s*//s;
|
||||
|
||||
push @mapping, $name, $value;
|
||||
|
||||
my $test = $before + 1;
|
||||
|
||||
# Warnings in our eval should be fatal so they set $@
|
||||
local $SIG{__WARN__} = sub { die $_[0] };
|
||||
|
||||
# Try to get a numeric value
|
||||
eval "\$test = $value * 1;";
|
||||
|
||||
# Assume noncontiguous if it's not a number
|
||||
$contig = 0 if $contig && ($@ || $test - 1 != $before);
|
||||
|
||||
$before = $test;
|
||||
} else {
|
||||
print STDERR "Can't understand: $_\n";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
my $code = "";
|
||||
while (<>) {
|
||||
if (eof) {
|
||||
close (ARGV); # reset line numbering
|
||||
}
|
||||
|
||||
if (/^\s*typedef\s+enum\s*({)?/) {
|
||||
# Didn't have trailing '{' look on next lines
|
||||
if (!defined $1) {
|
||||
while (<>) {
|
||||
if (s/^\s*\{//) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$symbols = ""; $contig = 1; $before = -1; @mapping = ();
|
||||
|
||||
# Now parse the entries
|
||||
&parse_entries (\*ARGV);
|
||||
|
||||
$symbols =~ s/\s*$//s;
|
||||
$symbols = wrap("\t\t\t ", "\t\t\t " , $symbols);
|
||||
$symbols =~ s/^\s*//s;
|
||||
|
||||
my $mapping = ""; $pos = 1;
|
||||
foreach (@mapping) {
|
||||
$mapping .= $pos++ % 2 ? "$_ => " : "'$_',\n\t\t ";
|
||||
}
|
||||
$mapping =~ s/,\n\s*$//s;
|
||||
|
||||
$code .= <<ENTRY;
|
||||
$enumname =>
|
||||
{ contig => $contig,
|
||||
symbols => [ qw($symbols) ],
|
||||
mapping => { $mapping }
|
||||
},
|
||||
ENTRY
|
||||
}
|
||||
}
|
||||
|
||||
$code =~ s/,\n$/\n/s;
|
||||
|
||||
open OUTFILE, "> $destdir/enums.pl";
|
||||
print OUTFILE $header, $code, $footer;
|
||||
close OUTFILE;
|
|
@ -1,5 +1,5 @@
|
|||
# The GIMP -- an image manipulation program
|
||||
# Copyright (C) 1998 Manish Singh <yosh@gimp.org>
|
||||
# Copyright (C) 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
# 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
|
||||
|
@ -7,7 +7,7 @@
|
|||
# (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
|
||||
# but WITHOUTFILE ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
|
@ -15,23 +15,27 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
# autogenerated by enumgen.pl
|
||||
|
||||
package Gimp::CodeGen::enums;
|
||||
|
||||
%enums = (
|
||||
ConvertPaletteType =>
|
||||
{ name => 'ConvertPaletteType', base => 0,
|
||||
{ contig => 1,
|
||||
symbols => [ qw(MAKE_PALETTE REUSE_PALETTE WEB_PALETTE MONO_PALETTE
|
||||
CUSTOM_PALETTE) ] }
|
||||
|
||||
CUSTOM_PALETTE) ],
|
||||
mapping => { MAKE_PALETTE => '0',
|
||||
REUSE_PALETTE => '1',
|
||||
WEB_PALETTE => '2',
|
||||
MONO_PALETTE => '3',
|
||||
CUSTOM_PALETTE => '4' }
|
||||
}
|
||||
);
|
||||
|
||||
foreach $enum (values %enums) {
|
||||
$enum->{start} = $enum->{symbols}->[0];
|
||||
$enum->{end} = $enum->{symbols}->[$#{$enum->{symbols}}];
|
||||
|
||||
my $pos = 0; $enum->{info} = "";
|
||||
foreach (@{$enum->{symbols}}) { $enum->{info} .= "$_ ($pos), "; $pos++ }
|
||||
$enum->{info} =~ s/, $//;
|
||||
foreach $e (values %enums) {
|
||||
$e->{info} = "";
|
||||
foreach (@{$e->{symbols}}) { $e->{info} .= "$_ ($e->{mapping}->{$_}), " }
|
||||
$e->{info} =~ s/, $//;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# The GIMP -- an image manipulation program
|
||||
# Copyright (C) 1998 Manish Singh <yosh@gimp.org>
|
||||
# Copyright (C) 1998-1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
# 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
|
||||
|
@ -17,4 +17,4 @@
|
|||
|
||||
# Modify this list for the groups to parse in the pdb directory
|
||||
@groups = qw(gdisplay edit floating_sel undo palette gradient
|
||||
convert channel_ops);
|
||||
convert);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# The GIMP -- an image manipulation program
|
||||
# Copyright (C) 1998 Manish Singh <yosh@gimp.org>
|
||||
# Copyright (C) 1998-1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
# 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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# The GIMP -- an image manipulation program
|
||||
# Copyright (C) 1998 Manish Singh <yosh@gimp.org>
|
||||
# Copyright (C) 1998-1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
# 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
|
||||
|
@ -72,7 +72,7 @@ package Gimp::CodeGen::pdb;
|
|||
enum => { name => 'INT32', type => 'gint32 ' },
|
||||
boolean => { name => 'INT32', type => 'gboolean ' },
|
||||
|
||||
region => { name => 'REGION', type => 'gpointer ' }, # not supported
|
||||
region => { name => 'REGION', type => 'gpointer ' } # not supported
|
||||
);
|
||||
|
||||
# Split out the parts of an arg constraint
|
||||
|
@ -97,7 +97,12 @@ sub arg_parse {
|
|||
|
||||
return @retvals;
|
||||
}
|
||||
elsif ($arg =~ /^([\d\.-].*?)? *(<=|<)? *(\w+) *(<=|<)? *([\d\.-].*?)?/) {
|
||||
elsif ($arg =~ /^([+-.\d].*?)? \s*
|
||||
(<=|<)? \s*
|
||||
(\w+) \s*
|
||||
(<=|<)? \s*
|
||||
([\d\.-].*?)?
|
||||
/x) {
|
||||
return ($3, $1, $2 ? $testmap{$2} : $2, $5, $4 ? $testmap{$4} : $4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ HELP
|
|||
{ name => 'dither', type => 'boolean',
|
||||
desc => 'Floyd-Steinberg dithering' },
|
||||
{ name => 'palette_type', type => 'enum ConvertPaletteType',
|
||||
desc => 'The type of palette to use: %%desc%%' },
|
||||
desc => 'The type of palette to use: %%desc%%', no_success => 1 },
|
||||
{ name => 'num_cols', type => 'int32',
|
||||
desc => 'the number of colors to quantize to, ignored unless
|
||||
(palette_type == MAKE_PALETTE)' },
|
||||
|
@ -137,7 +137,7 @@ HELP
|
|||
switch (palette_type)
|
||||
{
|
||||
case MAKE_PALETTE:
|
||||
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
|
||||
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
|
||||
success = FALSE;
|
||||
break;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ CODE
|
|||
}
|
||||
|
||||
sub display_delete {
|
||||
$blurb = 'Delete the specified display';
|
||||
$blurb = 'Delete the specified display.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure removes the specified display. If this is the last remaining
|
||||
|
|
|
@ -54,7 +54,7 @@ CODE
|
|||
}
|
||||
|
||||
sub display_delete {
|
||||
$blurb = 'Delete the specified display';
|
||||
$blurb = 'Delete the specified display.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure removes the specified display. If this is the last remaining
|
||||
|
|
|
@ -52,12 +52,6 @@ sub threshold_arg () {{
|
|||
desc => 'Threshold in intensity levels %%desc%%'
|
||||
}}
|
||||
|
||||
sub antialias_arg () {{
|
||||
name => 'antialias',
|
||||
type => 'boolean',
|
||||
desc => 'Antialiasing (%%desc%%)'
|
||||
}}
|
||||
|
||||
sub feather_select_args () {(
|
||||
{ name => 'feather', type => 'boolean',
|
||||
desc => 'Feather option for selections' },
|
||||
|
@ -247,7 +241,7 @@ HELP
|
|||
desc => 'The color to select' },
|
||||
&threshold_arg,
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args,
|
||||
&sample_merged_arg
|
||||
);
|
||||
|
@ -455,7 +449,7 @@ HELP
|
|||
{ name => 'height', type => '0 < float',
|
||||
desc => 'The height of the ellipse: %%desc%%' },
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_args
|
||||
);
|
||||
|
||||
|
@ -592,7 +586,7 @@ HELP
|
|||
array => { desc => 'Number of points (count 1 coordinate as two
|
||||
points)' } },
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args
|
||||
);
|
||||
|
||||
|
@ -641,7 +635,7 @@ HELP
|
|||
coordinates)' },
|
||||
&threshold_arg,
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args,
|
||||
&sample_merged_arg
|
||||
);
|
||||
|
@ -1110,83 +1104,12 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub text {
|
||||
$blurb = <<'BLURB';
|
||||
Add text at the specified location as a floating selection or a new layer.
|
||||
BLURB
|
||||
@procs = qw(airbrush blend bucket_fill by_color_select clone color_picker
|
||||
convolve crop ellipse_select eraser flip free_select fuzzy_select
|
||||
paintbrush pencil perspective rect_select rotate_invoker scale
|
||||
shear);
|
||||
%exports = (app => [@procs]);
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool requires font information in the form of nine parameters: size,
|
||||
foundry, family, weight, slant, set_width, spacing, registry, encoding. The
|
||||
font size can either be specified 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 antialias parameter is
|
||||
non-zero, the generated text will blend more smoothly with underlying layers.
|
||||
This option requires more time and memory to compute than non-antialiased text;
|
||||
the resulting floating selection or layer, however, will require the same
|
||||
amount of memory with or without antialiasing. 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
|
||||
$desc = 'Tool procedures';
|
||||
|
||||
&std_pdb_misc;
|
||||
$author = 'Martin Edlman';
|
||||
$date = '1998';
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ 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',
|
||||
{ name => 'border', type => '-1 <= int32',
|
||||
desc => 'The size of the border: %%desc%%' }
|
||||
&antialias_arg,
|
||||
{ name => 'size', type => '0 < float',
|
||||
desc => 'The size of text in either pixels or points' },
|
||||
{ name => 'size_type', type => 'enum SizeType',
|
||||
desc => 'The units of specified size: %%desc%%' }
|
||||
);
|
||||
|
||||
foreach (qw(foundry family weight slant set-width spacing registry
|
||||
encoding)) {
|
||||
my $var = $_;
|
||||
$var =~ s/-/_/g;
|
||||
|
||||
push @inargs, { name => $var, type => 'string',
|
||||
desc => qq/The font $_, "*" for any/ }
|
||||
}
|
||||
|
||||
@outargs = (
|
||||
{ name => 'text_layer', type => 'layer',
|
||||
desc => 'The new text layer' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("text_tool.h") ],
|
||||
vars => ['GimpImage *gimage', 'gchar *fontname[2048]'],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (antialias)
|
||||
size *= SUPERSAMPLE;
|
||||
|
||||
success = text_get_xlfd (size, size_type, foundry, family, weight,
|
||||
slant, set_width, spacing, registry, encoding,
|
||||
fontname);
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
text_layer = text_render (gimage, drawable, x, y, fontname, text,
|
||||
border, antialias);
|
||||
success = text_layer != NULL;
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -52,12 +52,6 @@ sub threshold_arg () {{
|
|||
desc => 'Threshold in intensity levels %%desc%%'
|
||||
}}
|
||||
|
||||
sub antialias_arg () {{
|
||||
name => 'antialias',
|
||||
type => 'boolean',
|
||||
desc => 'Antialiasing (%%desc%%)'
|
||||
}}
|
||||
|
||||
sub feather_select_args () {(
|
||||
{ name => 'feather', type => 'boolean',
|
||||
desc => 'Feather option for selections' },
|
||||
|
@ -247,7 +241,7 @@ HELP
|
|||
desc => 'The color to select' },
|
||||
&threshold_arg,
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args,
|
||||
&sample_merged_arg
|
||||
);
|
||||
|
@ -455,7 +449,7 @@ HELP
|
|||
{ name => 'height', type => '0 < float',
|
||||
desc => 'The height of the ellipse: %%desc%%' },
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_args
|
||||
);
|
||||
|
||||
|
@ -592,7 +586,7 @@ HELP
|
|||
array => { desc => 'Number of points (count 1 coordinate as two
|
||||
points)' } },
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args
|
||||
);
|
||||
|
||||
|
@ -641,7 +635,7 @@ HELP
|
|||
coordinates)' },
|
||||
&threshold_arg,
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args,
|
||||
&sample_merged_arg
|
||||
);
|
||||
|
@ -1110,83 +1104,12 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub text {
|
||||
$blurb = <<'BLURB';
|
||||
Add text at the specified location as a floating selection or a new layer.
|
||||
BLURB
|
||||
@procs = qw(airbrush blend bucket_fill by_color_select clone color_picker
|
||||
convolve crop ellipse_select eraser flip free_select fuzzy_select
|
||||
paintbrush pencil perspective rect_select rotate_invoker scale
|
||||
shear);
|
||||
%exports = (app => [@procs]);
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool requires font information in the form of nine parameters: size,
|
||||
foundry, family, weight, slant, set_width, spacing, registry, encoding. The
|
||||
font size can either be specified 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 antialias parameter is
|
||||
non-zero, the generated text will blend more smoothly with underlying layers.
|
||||
This option requires more time and memory to compute than non-antialiased text;
|
||||
the resulting floating selection or layer, however, will require the same
|
||||
amount of memory with or without antialiasing. 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
|
||||
$desc = 'Tool procedures';
|
||||
|
||||
&std_pdb_misc;
|
||||
$author = 'Martin Edlman';
|
||||
$date = '1998';
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ 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',
|
||||
{ name => 'border', type => '-1 <= int32',
|
||||
desc => 'The size of the border: %%desc%%' }
|
||||
&antialias_arg,
|
||||
{ name => 'size', type => '0 < float',
|
||||
desc => 'The size of text in either pixels or points' },
|
||||
{ name => 'size_type', type => 'enum SizeType',
|
||||
desc => 'The units of specified size: %%desc%%' }
|
||||
);
|
||||
|
||||
foreach (qw(foundry family weight slant set-width spacing registry
|
||||
encoding)) {
|
||||
my $var = $_;
|
||||
$var =~ s/-/_/g;
|
||||
|
||||
push @inargs, { name => $var, type => 'string',
|
||||
desc => qq/The font $_, "*" for any/ }
|
||||
}
|
||||
|
||||
@outargs = (
|
||||
{ name => 'text_layer', type => 'layer',
|
||||
desc => 'The new text layer' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("text_tool.h") ],
|
||||
vars => ['GimpImage *gimage', 'gchar *fontname[2048]'],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (antialias)
|
||||
size *= SUPERSAMPLE;
|
||||
|
||||
success = text_get_xlfd (size, size_type, foundry, family, weight,
|
||||
slant, set_width, spacing, registry, encoding,
|
||||
fontname);
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
text_layer = text_render (gimage, drawable, x, y, fontname, text,
|
||||
border, antialias);
|
||||
success = text_layer != NULL;
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -0,0 +1,215 @@
|
|||
# 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',
|
||||
desc => 'The text to generate'
|
||||
}}
|
||||
|
||||
sub fontname_arg () {{
|
||||
name => 'fontname',
|
||||
type => 'string',
|
||||
desc => 'The fontname (conforming to the X Logical Font Description
|
||||
Conventions)'
|
||||
}}
|
||||
|
||||
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',
|
||||
desc => 'The size of the border: %%desc%%' }
|
||||
&std_antialias_arg
|
||||
)}
|
||||
|
||||
sub size_args () {(
|
||||
{ name => 'size', type => '0 < float',
|
||||
desc => 'The size of text in either pixels or points' },
|
||||
{ name => 'size_type', type => 'enum SizeType',
|
||||
desc => 'The units of specified size: %%desc%%' }
|
||||
)}
|
||||
|
||||
sub font_prop_args {
|
||||
my @result;
|
||||
foreach (qw(foundry family weight slant set-width spacing registry
|
||||
encoding)) {
|
||||
my $var = $_;
|
||||
$var =~ s/-/_/g;
|
||||
|
||||
push @result, { name => $var, type => 'string',
|
||||
desc => qq/The font $_, "*" for any/ }
|
||||
}
|
||||
@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" }
|
||||
}
|
||||
}
|
||||
|
||||
sub text {
|
||||
$blurb = <<'BLURB';
|
||||
Add text at the specified location as a floating selection or a new layer.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool requires font information in the form of nine parameters: size,
|
||||
foundry, family, weight, slant, set_width, spacing, registry, encoding. The
|
||||
font size can either be specified 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 antialias parameter is
|
||||
non-zero, the generated text will blend more smoothly with underlying layers.
|
||||
This option requires more time and memory to compute than non-antialiased text;
|
||||
the resulting floating selection or layer, however, will require the same
|
||||
amount of memory with or without antialiasing. 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
|
||||
|
||||
&pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&render_args,
|
||||
&size_args,
|
||||
&font_prop_args
|
||||
);
|
||||
|
||||
&render_outargs;
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("text_tool.h") ],
|
||||
vars => ['GimpImage *gimage', 'gchar *fontname[2048]'],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (antialias)
|
||||
size *= SUPERSAMPLE;
|
||||
|
||||
if (drawable)
|
||||
success = drawable_gimage (GIMP_DRAWABLE (drawable)) == gimage;
|
||||
|
||||
if (success)
|
||||
success = text_get_xlfd (size, size_type, foundry, family, weight,
|
||||
slant, set_width, spacing, registry, encoding,
|
||||
fontname);
|
||||
|
||||
if (success)
|
||||
{
|
||||
text_layer = text_render (gimage, drawable, x, y, fontname, text,
|
||||
border, antialias);
|
||||
success = text_layer != NULL;
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub text_get_extents {
|
||||
$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;
|
||||
|
||||
@inargs = (
|
||||
&text_arg,
|
||||
&size_args,
|
||||
&font_prop_args
|
||||
);
|
||||
|
||||
&extents_outargs;
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("text_tool.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
success = text_get_xlfd (size, size_type, foundry, family, weight,
|
||||
slant, set_width, spacing, registry, encoding,
|
||||
fontname);
|
||||
|
||||
if (success)
|
||||
success = text_get_extents (fontname, text, &width, &height, &ascent,
|
||||
&descent);
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
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 font information as a fontname conforming to the 'X Logical
|
||||
Font Description Conventions'. 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
|
||||
antialias parameter is non-zero, the generated text will blend more smoothly
|
||||
with underlying layers. This option requires more time and memory to compute
|
||||
than non-antialiased text; the resulting floating selection or layer, however,
|
||||
will require the same amount of memory with or without antialiasing. 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
|
||||
|
||||
&pdb_misc;
|
||||
$author .= ', Sven Neumann';
|
||||
|
||||
@inargs = (
|
||||
&render_args,
|
||||
&fontname_arg
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("text_tool.h") ],
|
||||
);
|
||||
}
|
|
@ -52,12 +52,6 @@ sub threshold_arg () {{
|
|||
desc => 'Threshold in intensity levels %%desc%%'
|
||||
}}
|
||||
|
||||
sub antialias_arg () {{
|
||||
name => 'antialias',
|
||||
type => 'boolean',
|
||||
desc => 'Antialiasing (%%desc%%)'
|
||||
}}
|
||||
|
||||
sub feather_select_args () {(
|
||||
{ name => 'feather', type => 'boolean',
|
||||
desc => 'Feather option for selections' },
|
||||
|
@ -247,7 +241,7 @@ HELP
|
|||
desc => 'The color to select' },
|
||||
&threshold_arg,
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args,
|
||||
&sample_merged_arg
|
||||
);
|
||||
|
@ -455,7 +449,7 @@ HELP
|
|||
{ name => 'height', type => '0 < float',
|
||||
desc => 'The height of the ellipse: %%desc%%' },
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_args
|
||||
);
|
||||
|
||||
|
@ -592,7 +586,7 @@ HELP
|
|||
array => { desc => 'Number of points (count 1 coordinate as two
|
||||
points)' } },
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args
|
||||
);
|
||||
|
||||
|
@ -641,7 +635,7 @@ HELP
|
|||
coordinates)' },
|
||||
&threshold_arg,
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args,
|
||||
&sample_merged_arg
|
||||
);
|
||||
|
@ -1110,83 +1104,12 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub text {
|
||||
$blurb = <<'BLURB';
|
||||
Add text at the specified location as a floating selection or a new layer.
|
||||
BLURB
|
||||
@procs = qw(airbrush blend bucket_fill by_color_select clone color_picker
|
||||
convolve crop ellipse_select eraser flip free_select fuzzy_select
|
||||
paintbrush pencil perspective rect_select rotate_invoker scale
|
||||
shear);
|
||||
%exports = (app => [@procs]);
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool requires font information in the form of nine parameters: size,
|
||||
foundry, family, weight, slant, set_width, spacing, registry, encoding. The
|
||||
font size can either be specified 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 antialias parameter is
|
||||
non-zero, the generated text will blend more smoothly with underlying layers.
|
||||
This option requires more time and memory to compute than non-antialiased text;
|
||||
the resulting floating selection or layer, however, will require the same
|
||||
amount of memory with or without antialiasing. 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
|
||||
$desc = 'Tool procedures';
|
||||
|
||||
&std_pdb_misc;
|
||||
$author = 'Martin Edlman';
|
||||
$date = '1998';
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ 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',
|
||||
{ name => 'border', type => '-1 <= int32',
|
||||
desc => 'The size of the border: %%desc%%' }
|
||||
&antialias_arg,
|
||||
{ name => 'size', type => '0 < float',
|
||||
desc => 'The size of text in either pixels or points' },
|
||||
{ name => 'size_type', type => 'enum SizeType',
|
||||
desc => 'The units of specified size: %%desc%%' }
|
||||
);
|
||||
|
||||
foreach (qw(foundry family weight slant set-width spacing registry
|
||||
encoding)) {
|
||||
my $var = $_;
|
||||
$var =~ s/-/_/g;
|
||||
|
||||
push @inargs, { name => $var, type => 'string',
|
||||
desc => qq/The font $_, "*" for any/ }
|
||||
}
|
||||
|
||||
@outargs = (
|
||||
{ name => 'text_layer', type => 'layer',
|
||||
desc => 'The new text layer' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("text_tool.h") ],
|
||||
vars => ['GimpImage *gimage', 'gchar *fontname[2048]'],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (antialias)
|
||||
size *= SUPERSAMPLE;
|
||||
|
||||
success = text_get_xlfd (size, size_type, foundry, family, weight,
|
||||
slant, set_width, spacing, registry, encoding,
|
||||
fontname);
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
text_layer = text_render (gimage, drawable, x, y, fontname, text,
|
||||
border, antialias);
|
||||
success = text_layer != NULL;
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -52,12 +52,6 @@ sub threshold_arg () {{
|
|||
desc => 'Threshold in intensity levels %%desc%%'
|
||||
}}
|
||||
|
||||
sub antialias_arg () {{
|
||||
name => 'antialias',
|
||||
type => 'boolean',
|
||||
desc => 'Antialiasing (%%desc%%)'
|
||||
}}
|
||||
|
||||
sub feather_select_args () {(
|
||||
{ name => 'feather', type => 'boolean',
|
||||
desc => 'Feather option for selections' },
|
||||
|
@ -247,7 +241,7 @@ HELP
|
|||
desc => 'The color to select' },
|
||||
&threshold_arg,
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args,
|
||||
&sample_merged_arg
|
||||
);
|
||||
|
@ -455,7 +449,7 @@ HELP
|
|||
{ name => 'height', type => '0 < float',
|
||||
desc => 'The height of the ellipse: %%desc%%' },
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_args
|
||||
);
|
||||
|
||||
|
@ -592,7 +586,7 @@ HELP
|
|||
array => { desc => 'Number of points (count 1 coordinate as two
|
||||
points)' } },
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args
|
||||
);
|
||||
|
||||
|
@ -641,7 +635,7 @@ HELP
|
|||
coordinates)' },
|
||||
&threshold_arg,
|
||||
&operation_arg,
|
||||
&antialias_arg,
|
||||
&std_antialias_arg,
|
||||
&feather_select_args,
|
||||
&sample_merged_arg
|
||||
);
|
||||
|
@ -1110,83 +1104,12 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub text {
|
||||
$blurb = <<'BLURB';
|
||||
Add text at the specified location as a floating selection or a new layer.
|
||||
BLURB
|
||||
@procs = qw(airbrush blend bucket_fill by_color_select clone color_picker
|
||||
convolve crop ellipse_select eraser flip free_select fuzzy_select
|
||||
paintbrush pencil perspective rect_select rotate_invoker scale
|
||||
shear);
|
||||
%exports = (app => [@procs]);
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool requires font information in the form of nine parameters: size,
|
||||
foundry, family, weight, slant, set_width, spacing, registry, encoding. The
|
||||
font size can either be specified 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 antialias parameter is
|
||||
non-zero, the generated text will blend more smoothly with underlying layers.
|
||||
This option requires more time and memory to compute than non-antialiased text;
|
||||
the resulting floating selection or layer, however, will require the same
|
||||
amount of memory with or without antialiasing. 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
|
||||
$desc = 'Tool procedures';
|
||||
|
||||
&std_pdb_misc;
|
||||
$author = 'Martin Edlman';
|
||||
$date = '1998';
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ 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',
|
||||
{ name => 'border', type => '-1 <= int32',
|
||||
desc => 'The size of the border: %%desc%%' }
|
||||
&antialias_arg,
|
||||
{ name => 'size', type => '0 < float',
|
||||
desc => 'The size of text in either pixels or points' },
|
||||
{ name => 'size_type', type => 'enum SizeType',
|
||||
desc => 'The units of specified size: %%desc%%' }
|
||||
);
|
||||
|
||||
foreach (qw(foundry family weight slant set-width spacing registry
|
||||
encoding)) {
|
||||
my $var = $_;
|
||||
$var =~ s/-/_/g;
|
||||
|
||||
push @inargs, { name => $var, type => 'string',
|
||||
desc => qq/The font $_, "*" for any/ }
|
||||
}
|
||||
|
||||
@outargs = (
|
||||
{ name => 'text_layer', type => 'layer',
|
||||
desc => 'The new text layer' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("text_tool.h") ],
|
||||
vars => ['GimpImage *gimage', 'gchar *fontname[2048]'],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (antialias)
|
||||
size *= SUPERSAMPLE;
|
||||
|
||||
success = text_get_xlfd (size, size_type, foundry, family, weight,
|
||||
slant, set_width, spacing, registry, encoding,
|
||||
fontname);
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
text_layer = text_render (gimage, drawable, x, y, fontname, text,
|
||||
border, antialias);
|
||||
success = text_layer != NULL;
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
# The GIMP -- an image manipulation program
|
||||
# Copyright (C) 1998 Manish Singh <yosh@gimp.org>
|
||||
# Copyright (C) 1998-1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
# 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
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
# The GIMP -- an image manipulation program
|
||||
# Copyright (C) 1998-1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
# 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.
|
||||
|
||||
# Boilerplate PDB stuff
|
||||
|
||||
sub std_pdb_misc {
|
||||
|
@ -12,4 +29,10 @@ sub std_image_arg () {{
|
|||
alias => 'gimage'
|
||||
}}
|
||||
|
||||
sub std_antialias_arg () {{
|
||||
name => 'antialias',
|
||||
type => 'boolean',
|
||||
desc => 'Antialiasing (%%desc%%)'
|
||||
}}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# The GIMP -- an image manipulation program
|
||||
# Copyright (C) 1998 Manish Singh <yosh@gimp.org>
|
||||
# Copyright (C) 1998-1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
# 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
|
||||
|
|
Loading…
Reference in New Issue