~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/text_tool.pdb

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# The GIMP -- an image manipulation program
 
1
# GIMP - The GNU Image Manipulation Program
2
2
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 
4
4
# This program is free software; you can redistribute it and/or modify
17
17
 
18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
19
19
 
20
 
# Text
21
 
 
22
 
sub pdb_misc {
23
 
   &std_pdb_misc;
24
 
   $author = 'Martin Edlman';
25
 
   $date = '1998';
26
 
}
27
 
 
28
 
sub text_arg () {{
29
 
    name => 'text',
30
 
    type => 'string',
31
 
    desc => 'The text to generate (in UTF-8 encoding)'
32
 
}}
33
 
 
34
 
sub fontname_arg () {{
35
 
    name => 'fontname',
36
 
    type => 'string',
37
 
    desc => 'The name of the font'
38
 
}}
39
 
 
40
 
sub size_args () {(
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%%' }
45
 
)}
46
 
 
47
 
sub render_args () {(
48
 
    &std_image_arg,
49
 
    { name => 'drawable', type => 'drawable',
50
 
      desc => 'The affected drawable: (-1 for a new text layer)',
51
 
      no_success => 1 },
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' },
56
 
    &text_arg,
57
 
    { name => 'border', type => '-1 <= int32',
58
 
      desc => 'The size of the border: %%desc%%' },
59
 
    &std_antialias_arg,
60
 
    &size_args
61
 
)}
62
 
 
63
 
@props = qw(foundry family weight slant set_width spacing registry encoding);
64
 
 
65
 
sub font_prop_args {
66
 
   my @result;
67
 
   foreach (@props) {
68
 
        (my $desc = $_) =~ s/_/-/g;
69
 
        push @result, { name => $_, type => 'string', no_validate => 1,
70
 
                        desc => qq/The font $desc/ }
71
 
   }
72
 
   @result;
73
 
}
74
 
 
75
 
sub render_outargs {
76
 
   @outargs = (
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 }
80
 
   );
81
 
}
82
 
 
83
 
sub extents_outargs {
84
 
    foreach (qw(width height ascent descent)) {
85
 
        push @outargs, { name => $_, type => 'int32',
86
 
                         desc => "The $_ of the specified font" }
87
 
    }
88
 
}
89
 
 
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.
105
 
 
 
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
 
37
vertical resolution.
106
38
HELP
107
39
 
108
 
    &pdb_misc;
109
 
    $author .= ' & Sven Neumann';
110
 
    $date   .= '- 2001';
 
40
    &std_pdb_misc;
 
41
    $author = 'Martin Edlman & Sven Neumann';
 
42
    $date = '1998- 2001';
111
43
 
112
44
    @inargs = (
113
 
        &render_args,
114
 
        &fontname_arg
 
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)',
 
49
          none_ok => 1 },
 
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' }
115
66
    );
116
67
 
117
 
    &render_outargs;
 
68
    @outargs = (
 
69
        { name => 'text_layer', type => 'layer',
 
70
          desc => 'The new text layer or -1 if no layer was created.' }
 
71
    );
118
72
 
119
73
    %invoke = (
120
 
        code => <<'CODE'
 
74
        code => <<'CODE'
121
75
{
122
76
  if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
123
77
    success = FALSE;
126
80
    {
127
81
      gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
128
82
 
129
 
      text_layer = text_render (gimage, drawable, context,
 
83
      text_layer = text_render (image, drawable, context,
130
84
                                x, y, real_fontname, text,
131
85
                                border, antialias);
132
86
 
143
97
    $help = <<'HELP';
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.
147
104
HELP
148
105
 
149
 
    &pdb_misc;
150
 
    $author .= ' & Sven Neumann';
151
 
    $date   .= '- 2001';
152
 
 
 
106
    &std_pdb_misc;
 
107
    $author = 'Martin Edlman & Sven Neumann';
 
108
    $date = '1998- 2001';
 
109
 
153
110
    @inargs = (
154
 
        &text_arg,
155
 
        &size_args,
156
 
        &fontname_arg
 
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' }
157
119
    );
158
120
 
159
 
    &extents_outargs;
160
 
    $outargs[0]->{void_ret} = 1;
 
121
    @outargs = (
 
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' }
 
130
    );
161
131
 
162
132
    %invoke = (
163
 
        vars => [ 'gchar *real_fontname' ],
164
 
        code => <<'CODE'
 
133
        code => <<'CODE'
165
134
{
166
 
  real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
 
135
  gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
167
136
 
168
137
  success = text_get_extents (real_fontname, text,
169
 
                              &width, &height,
170
 
                              &ascent, &descent);
 
138
                              &width, &height,
 
139
                              &ascent, &descent);
171
140
 
172
141
  g_free (real_fontname);
173
142
}
176
145
}
177
146
 
178
147
sub text {
179
 
    &std_pdb_deprecated ('gimp_text_fontname');
 
148
    &std_pdb_deprecated ('gimp-text-fontname');
180
149
 
181
150
    @inargs = (
182
 
        &render_args,
183
 
        &font_prop_args
 
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)',
 
155
          none_ok => 1 },
 
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' }
184
186
    );
185
187
 
186
 
    &render_outargs;
 
188
    @outargs = (
 
189
        { name => 'text_layer', type => 'layer',
 
190
          desc => 'The new text layer or -1 if no layer was created.' }
 
191
    );
187
192
 
188
193
    %invoke = (
189
 
        code => <<'CODE'
 
194
        code => <<'CODE'
190
195
{
191
196
  if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
192
197
    success = FALSE;
195
200
    {
196
201
      gchar *real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
197
202
 
198
 
      text_layer = text_render (gimage, drawable, context,
 
203
      text_layer = text_render (image, drawable, context,
199
204
                                x, y, real_fontname, text,
200
205
                                border, antialias);
201
206
 
207
212
}
208
213
 
209
214
sub text_get_extents {
210
 
    &std_pdb_deprecated ('gimp_text_get_extents_fontname');
 
215
    &std_pdb_deprecated ('gimp-text-get-extents-fontname');
211
216
 
212
217
    @inargs = (
213
 
        &text_arg,
214
 
        &size_args,
215
 
        &font_prop_args
 
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' }
216
240
    );
217
241
 
218
 
    &extents_outargs;
219
 
    $outargs[0]->{void_ret} = 1;
 
242
    @outargs = (
 
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' }
 
251
    );
220
252
 
221
253
    %invoke = (
222
 
        vars => [ 'gchar *real_fontname' ],
223
 
        code => <<'CODE'
 
254
        code => <<'CODE'
224
255
{
225
 
  real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
 
256
  gchar *real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
226
257
 
227
258
  success = text_get_extents (real_fontname, text,
228
 
                              &width, &height,
229
 
                              &ascent, &descent);
 
259
                              &width, &height,
 
260
                              &ascent, &descent);
230
261
 
231
262
  g_free (real_fontname);
232
263
}
234
265
    );
235
266
}
236
267
 
 
268
 
237
269
@headers = qw("libgimpbase/gimpbase.h" "text/gimptext-compat.h");
238
270
 
239
 
@procs = qw(text_fontname text_get_extents_fontname text text_get_extents);
 
271
@procs = qw(text_fontname text_get_extents_fontname
 
272
            text text_get_extents);
 
273
 
240
274
%exports = (app => [@procs], lib => [@procs]);
241
275
 
242
276
$desc = 'Text procedures';