2023-09-26 00:35:21 +02:00
|
|
|
# PIKA - Photo and Image Kooker Application
|
|
|
|
# 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 3 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, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
|
|
|
|
|
2023-10-30 23:55:30 +01:00
|
|
|
sub text_font {
|
2023-09-26 00:35:21 +02:00
|
|
|
$blurb = <<'BLURB';
|
|
|
|
Add text at the specified location as a floating selection or a new layer.
|
|
|
|
BLURB
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
2023-10-30 23:55:30 +01:00
|
|
|
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 (%NULL), 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.
|
|
|
|
|
|
|
|
The size is always in pixels. 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.
|
2023-09-26 00:35:21 +02:00
|
|
|
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: (%NULL 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' },
|
|
|
|
{ name => 'antialias', type => 'boolean',
|
|
|
|
desc => 'Antialiasing' },
|
|
|
|
{ name => 'size', type => '0 < float',
|
2023-10-30 23:55:30 +01:00
|
|
|
desc => 'The size of text in pixels' },
|
|
|
|
{ name => 'font', type => 'font',
|
|
|
|
desc => 'The font' }
|
2023-09-26 00:35:21 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
@outargs = (
|
|
|
|
{ name => 'text_layer', type => 'layer', none_ok => 1,
|
|
|
|
desc => 'The new text layer or %NULL if no layer was created.' }
|
|
|
|
);
|
|
|
|
|
|
|
|
%invoke = (
|
|
|
|
code => <<'CODE'
|
|
|
|
{
|
|
|
|
if (drawable &&
|
|
|
|
(! pika_pdb_item_is_attached (PIKA_ITEM (drawable), image,
|
|
|
|
PIKA_PDB_ITEM_CONTENT, error) ||
|
|
|
|
! pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error)))
|
|
|
|
success = FALSE;
|
|
|
|
|
|
|
|
if (success)
|
2023-10-30 23:55:30 +01:00
|
|
|
text_layer = text_render (image, drawable, context,
|
|
|
|
x, y, font, size, text,
|
|
|
|
border, antialias);
|
2023-09-26 00:35:21 +02:00
|
|
|
}
|
|
|
|
CODE
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-10-30 23:55:30 +01:00
|
|
|
sub text_get_extents_font {
|
2023-09-26 00:35:21 +02: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
|
2023-10-30 23:55:30 +01:00
|
|
|
rendered with the specified font information. Ascent and descent of the glyph
|
|
|
|
extents are returned as well.
|
|
|
|
|
|
|
|
The ascent is the distance from the baseline to the highest point of the
|
|
|
|
character. This is positive if the glyph ascends above the baseline.
|
|
|
|
The descent is the distance from the baseline to the lowest point of the
|
|
|
|
character. This is positive if the glyph descends below the baseline.
|
|
|
|
|
|
|
|
The size is always in pixels. If you need to set 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.
|
2023-09-26 00:35:21 +02:00
|
|
|
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' },
|
2023-10-30 23:55:30 +01:00
|
|
|
{ name => 'font', type => 'font',
|
2023-09-26 00:35:21 +02:00
|
|
|
desc => 'The name of the font' }
|
|
|
|
);
|
|
|
|
|
|
|
|
@outargs = (
|
|
|
|
{ name => 'width', type => 'int32', void_ret => 1,
|
2023-10-30 23:55:30 +01:00
|
|
|
desc => 'The width of the glyph extents' },
|
2023-09-26 00:35:21 +02:00
|
|
|
{ name => 'height', type => 'int32',
|
2023-10-30 23:55:30 +01:00
|
|
|
desc => 'The height of the glyph extents' },
|
2023-09-26 00:35:21 +02:00
|
|
|
{ name => 'ascent', type => 'int32',
|
2023-10-30 23:55:30 +01:00
|
|
|
desc => 'The ascent of the glyph extents' },
|
2023-09-26 00:35:21 +02:00
|
|
|
{ name => 'descent', type => 'int32',
|
2023-10-30 23:55:30 +01:00
|
|
|
desc => 'The descent of the glyph extents' }
|
2023-09-26 00:35:21 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
%invoke = (
|
|
|
|
code => <<'CODE'
|
|
|
|
{
|
|
|
|
success = text_get_extents (pika,
|
2023-10-30 23:55:30 +01:00
|
|
|
font, size, text,
|
2023-09-26 00:35:21 +02:00
|
|
|
&width, &height,
|
|
|
|
&ascent, &descent);
|
|
|
|
}
|
|
|
|
CODE
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@headers = qw("libpikabase/pikabase.h"
|
|
|
|
"text/pikatext-compat.h"
|
|
|
|
"pikapdb-utils.h");
|
|
|
|
|
2023-10-30 23:55:30 +01:00
|
|
|
@procs = qw(text_font
|
|
|
|
text_get_extents_font);
|
2023-09-26 00:35:21 +02:00
|
|
|
|
|
|
|
%exports = (app => [@procs], lib => [@procs]);
|
|
|
|
|
|
|
|
$desc = 'Text procedures';
|
|
|
|
$doc_title = 'pikatexttool';
|
|
|
|
$doc_short_desc = 'Functions for controlling the text tool.';
|
|
|
|
$doc_long_desc = 'Functions for controlling the text tool.';
|
|
|
|
|
|
|
|
1;
|