18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
24
$author = 'Martin Edlman';
31
desc => 'The text to generate (in UTF-8 encoding)'
34
sub fontname_arg () {{
37
desc => 'The name of the font'
41
{ name => 'size', type => '0 < float',
42
desc => 'The size of text in either pixels or points' },
43
{ name => 'size_type', type => 'enum GimpSizeType',
44
desc => 'The units of specified size: %%desc%%' }
49
{ name => 'drawable', type => 'drawable',
50
desc => 'The affected drawable: (-1 for a new text layer)',
52
{ name => 'x', type => 'float',
53
desc => 'The x coordinate for the left of the text bounding box' },
54
{ name => 'y', type => 'float',
55
desc => 'The y coordinate for the top of the text bounding box' },
57
{ name => 'border', type => '-1 <= int32',
58
desc => 'The size of the border: %%desc%%' },
63
@props = qw(foundry family weight slant set_width spacing registry encoding);
68
(my $desc = $_) =~ s/_/-/g;
69
push @result, { name => $_, type => 'string', no_validate => 1,
70
desc => qq/The font $desc/ }
77
{ name => 'text_layer', type => 'layer',
78
desc => 'The new text layer or -1 if no layer was created.',
79
init => 1, return_fail => -1 }
84
foreach (qw(width height ascent descent)) {
85
push @outargs, { name => $_, type => 'int32',
86
desc => "The $_ of the specified font" }
90
20
sub text_fontname {
91
21
$blurb = <<'BLURB';
92
22
Add text at the specified location as a floating selection or a new layer.
101
31
specified drawable parameter is valid, the text will be created as a floating
102
32
selection attached to the drawable. If the drawable parameter is not valid
103
33
(-1), the text will appear as a new layer. Finally, a border can be specified
104
around the final rendered text. The border is measured in pixels.
34
around the final rendered text. The border is measured in pixels. Parameter
35
size-type is not used and is currently ignored. If you need to display a font
36
in points, divide the size in points by 72.0 and multiply it by the image's
109
$author .= ' & Sven Neumann';
41
$author = 'Martin Edlman & Sven Neumann';
45
{ name => 'image', type => 'image',
46
desc => 'The image' },
47
{ name => 'drawable', type => 'drawable',
48
desc => 'The affected drawable: (-1 for a new text layer)',
50
{ name => 'x', type => 'float',
51
desc => 'The x coordinate for the left of the text bounding box' },
52
{ name => 'y', type => 'float',
53
desc => 'The y coordinate for the top of the text bounding box' },
54
{ name => 'text', type => 'string',
55
desc => 'The text to generate (in UTF-8 encoding)' },
56
{ name => 'border', type => '-1 <= int32',
57
desc => 'The size of the border' },
58
{ name => 'antialias', type => 'boolean',
59
desc => 'Antialiasing' },
60
{ name => 'size', type => '0 < float',
61
desc => 'The size of text in either pixels or points' },
62
{ name => 'size_type', type => 'enum GimpSizeType',
63
desc => 'The units of specified size' },
64
{ name => 'fontname', type => 'string',
65
desc => 'The name of the font' }
69
{ name => 'text_layer', type => 'layer',
70
desc => 'The new text layer or -1 if no layer was created.' }
122
76
if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
144
98
This tool returns the width and height of a bounding box for the specified text
145
99
string with the specified font information. Ascent and descent for the
146
specified font are returned as well.
100
specified font are returned as well. Parameter size-type is not used and is
101
currently ignored. If you need to display a font in points, divide the
102
size in points by 72.0 and multiply it by the vertical resolution of the
103
image you are taking into account.
150
$author .= ' & Sven Neumann';
107
$author = 'Martin Edlman & Sven Neumann';
108
$date = '1998- 2001';
111
{ name => 'text', type => 'string',
112
desc => 'The text to generate (in UTF-8 encoding)' },
113
{ name => 'size', type => '0 < float',
114
desc => 'The size of text in either pixels or points' },
115
{ name => 'size_type', type => 'enum GimpSizeType',
116
desc => 'The units of specified size' },
117
{ name => 'fontname', type => 'string',
118
desc => 'The name of the font' }
160
$outargs[0]->{void_ret} = 1;
122
{ name => 'width', type => 'int32', void_ret => 1,
123
desc => 'The width of the specified font' },
124
{ name => 'height', type => 'int32',
125
desc => 'The height of the specified font' },
126
{ name => 'ascent', type => 'int32',
127
desc => 'The ascent of the specified font' },
128
{ name => 'descent', type => 'int32',
129
desc => 'The descent of the specified font' }
163
vars => [ 'gchar *real_fontname' ],
166
real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
135
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
168
137
success = text_get_extents (real_fontname, text,
172
141
g_free (real_fontname);
179
&std_pdb_deprecated ('gimp_text_fontname');
148
&std_pdb_deprecated ('gimp-text-fontname');
151
{ name => 'image', type => 'image',
152
desc => 'The image' },
153
{ name => 'drawable', type => 'drawable',
154
desc => 'The affected drawable: (-1 for a new text layer)',
156
{ name => 'x', type => 'float',
157
desc => 'The x coordinate for the left of the text bounding box' },
158
{ name => 'y', type => 'float',
159
desc => 'The y coordinate for the top of the text bounding box' },
160
{ name => 'text', type => 'string',
161
desc => 'The text to generate (in UTF-8 encoding)' },
162
{ name => 'border', type => '-1 <= int32',
163
desc => 'The size of the border' },
164
{ name => 'antialias', type => 'boolean',
165
desc => 'Antialiasing' },
166
{ name => 'size', type => '0 < float',
167
desc => 'The size of text in either pixels or points' },
168
{ name => 'size_type', type => 'enum GimpSizeType',
169
desc => 'The units of specified size' },
170
{ name => 'foundry', type => 'string', no_validate => 1,
171
desc => 'The font foundry' },
172
{ name => 'family', type => 'string', no_validate => 1,
173
desc => 'The font family' },
174
{ name => 'weight', type => 'string', no_validate => 1,
175
desc => 'The font weight' },
176
{ name => 'slant', type => 'string', no_validate => 1,
177
desc => 'The font slant' },
178
{ name => 'set_width', type => 'string', no_validate => 1,
179
desc => 'The font set-width' },
180
{ name => 'spacing', type => 'string', no_validate => 1,
181
desc => 'The font spacing' },
182
{ name => 'registry', type => 'string', no_validate => 1,
183
desc => 'The font registry' },
184
{ name => 'encoding', type => 'string', no_validate => 1,
185
desc => 'The font encoding' }
189
{ name => 'text_layer', type => 'layer',
190
desc => 'The new text layer or -1 if no layer was created.' }
191
196
if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
209
214
sub text_get_extents {
210
&std_pdb_deprecated ('gimp_text_get_extents_fontname');
215
&std_pdb_deprecated ('gimp-text-get-extents-fontname');
218
{ name => 'text', type => 'string',
219
desc => 'The text to generate (in UTF-8 encoding)' },
220
{ name => 'size', type => '0 < float',
221
desc => 'The size of text in either pixels or points' },
222
{ name => 'size_type', type => 'enum GimpSizeType',
223
desc => 'The units of specified size' },
224
{ name => 'foundry', type => 'string', no_validate => 1,
225
desc => 'The font foundry' },
226
{ name => 'family', type => 'string', no_validate => 1,
227
desc => 'The font family' },
228
{ name => 'weight', type => 'string', no_validate => 1,
229
desc => 'The font weight' },
230
{ name => 'slant', type => 'string', no_validate => 1,
231
desc => 'The font slant' },
232
{ name => 'set_width', type => 'string', no_validate => 1,
233
desc => 'The font set-width' },
234
{ name => 'spacing', type => 'string', no_validate => 1,
235
desc => 'The font spacing' },
236
{ name => 'registry', type => 'string', no_validate => 1,
237
desc => 'The font registry' },
238
{ name => 'encoding', type => 'string', no_validate => 1,
239
desc => 'The font encoding' }
219
$outargs[0]->{void_ret} = 1;
243
{ name => 'width', type => 'int32', void_ret => 1,
244
desc => 'The width of the specified font' },
245
{ name => 'height', type => 'int32',
246
desc => 'The height of the specified font' },
247
{ name => 'ascent', type => 'int32',
248
desc => 'The ascent of the specified font' },
249
{ name => 'descent', type => 'int32',
250
desc => 'The descent of the specified font' }
222
vars => [ 'gchar *real_fontname' ],
225
real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
256
gchar *real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
227
258
success = text_get_extents (real_fontname, text,
231
262
g_free (real_fontname);