gimptexttool_pdb.c 9.06 KB
Newer Older
1
/* LIBGIMP - The GIMP Library
2
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * gimptexttool_pdb.c
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/* NOTE: This file is autogenerated by pdbgen.pl */

Sven Neumann's avatar
Sven Neumann committed
24 25
#include "config.h"

26 27
#include "gimp.h"

28 29 30 31 32 33 34 35 36 37 38
/**
 * gimp_text_fontname:
 * @image_ID: The image.
 * @drawable_ID: The affected drawable: (-1 for a new text layer).
 * @x: The x coordinate for the left of the text bounding box.
 * @y: The y coordinate for the top of the text bounding box.
 * @text: The text to generate.
 * @border: The size of the border.
 * @antialias: Antialiasing.
 * @size: The size of text in either pixels or points.
 * @size_type: The units of specified size.
Manish Singh's avatar
Manish Singh committed
39
 * @fontname: The name of the font.
40 41 42 43
 *
 * Add text at the specified location as a floating selection or a new
 * layer.
 *
Sven Neumann's avatar
Sven Neumann committed
44 45 46 47 48 49 50 51 52 53
 * This tool requires a fontname matching an installed PangoFT2 font.
 * 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
 * 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.
54
 *
55
 * Returns: The new text layer or -1 if no layer was created.
56
 */
57 58 59 60 61
gint32
gimp_text_fontname (gint32        image_ID,
		    gint32        drawable_ID,
		    gdouble       x,
		    gdouble       y,
62
		    const gchar  *text,
63 64 65 66
		    gint          border,
		    gboolean      antialias,
		    gdouble       size,
		    GimpSizeType  size_type,
67
		    const gchar  *fontname)
68
{
69
  GimpParam *return_vals;
70 71 72 73 74
  gint nreturn_vals;
  gint32 text_layer_ID = -1;

  return_vals = gimp_run_procedure ("gimp_text_fontname",
				    &nreturn_vals,
75 76 77 78 79 80 81 82 83 84 85 86 87
				    GIMP_PDB_IMAGE, image_ID,
				    GIMP_PDB_DRAWABLE, drawable_ID,
				    GIMP_PDB_FLOAT, x,
				    GIMP_PDB_FLOAT, y,
				    GIMP_PDB_STRING, text,
				    GIMP_PDB_INT32, border,
				    GIMP_PDB_INT32, antialias,
				    GIMP_PDB_FLOAT, size,
				    GIMP_PDB_INT32, size_type,
				    GIMP_PDB_STRING, fontname,
				    GIMP_PDB_END);

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
88 89 90 91 92 93 94
    text_layer_ID = return_vals[1].data.d_layer;

  gimp_destroy_params (return_vals, nreturn_vals);

  return text_layer_ID;
}

95 96 97 98 99
/**
 * gimp_text_get_extents_fontname:
 * @text: The text to generate.
 * @size: The size of text in either pixels or points.
 * @size_type: The units of specified size.
Manish Singh's avatar
Manish Singh committed
100
 * @fontname: The name of the font.
101 102 103 104 105 106 107 108 109 110 111 112 113
 * @width: The width of the specified font.
 * @height: The height of the specified font.
 * @ascent: The ascent of the specified font.
 * @descent: The descent of the specified font.
 *
 * Get extents of the bounding box for the specified text.
 *
 * 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.
 *
 * Returns: TRUE on success.
 */
114
gboolean
115
gimp_text_get_extents_fontname (const gchar  *text,
116 117
				gdouble       size,
				GimpSizeType  size_type,
118
				const gchar  *fontname,
119 120 121 122 123
				gint         *width,
				gint         *height,
				gint         *ascent,
				gint         *descent)
{
124
  GimpParam *return_vals;
125
  gint nreturn_vals;
126
  gboolean success = TRUE;
127 128 129

  return_vals = gimp_run_procedure ("gimp_text_get_extents_fontname",
				    &nreturn_vals,
130 131 132 133 134
				    GIMP_PDB_STRING, text,
				    GIMP_PDB_FLOAT, size,
				    GIMP_PDB_INT32, size_type,
				    GIMP_PDB_STRING, fontname,
				    GIMP_PDB_END);
135

136 137 138 139 140
  *width = 0;
  *height = 0;
  *ascent = 0;
  *descent = 0;

141 142 143
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
144 145 146 147 148 149 150 151
    {
      *width = return_vals[1].data.d_int32;
      *height = return_vals[2].data.d_int32;
      *ascent = return_vals[3].data.d_int32;
      *descent = return_vals[4].data.d_int32;
    }

  gimp_destroy_params (return_vals, nreturn_vals);
152 153

  return success;
154 155
}

156 157 158 159 160 161 162 163 164 165 166
/**
 * gimp_text:
 * @image_ID: The image.
 * @drawable_ID: The affected drawable: (-1 for a new text layer).
 * @x: The x coordinate for the left of the text bounding box.
 * @y: The y coordinate for the top of the text bounding box.
 * @text: The text to generate.
 * @border: The size of the border.
 * @antialias: Antialiasing.
 * @size: The size of text in either pixels or points.
 * @size_type: The units of specified size.
Manish Singh's avatar
Manish Singh committed
167 168 169 170 171 172 173 174
 * @foundry: The font foundry.
 * @family: The font family.
 * @weight: The font weight.
 * @slant: The font slant.
 * @set_width: The font set-width.
 * @spacing: The font spacing.
 * @registry: The font registry.
 * @encoding: The font encoding.
175
 *
176
 * This procedure is deprecated! Use gimp_text_fontname() instead.
177
 *
178
 * Returns: The new text layer or -1 if no layer was created.
179
 */
180 181 182 183 184
gint32
gimp_text (gint32        image_ID,
	   gint32        drawable_ID,
	   gdouble       x,
	   gdouble       y,
185
	   const gchar  *text,
186 187 188 189
	   gint          border,
	   gboolean      antialias,
	   gdouble       size,
	   GimpSizeType  size_type,
190 191 192 193 194 195 196 197
	   const gchar  *foundry,
	   const gchar  *family,
	   const gchar  *weight,
	   const gchar  *slant,
	   const gchar  *set_width,
	   const gchar  *spacing,
	   const gchar  *registry,
	   const gchar  *encoding)
198
{
199
  GimpParam *return_vals;
200 201 202 203 204
  gint nreturn_vals;
  gint32 text_layer_ID = -1;

  return_vals = gimp_run_procedure ("gimp_text",
				    &nreturn_vals,
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
				    GIMP_PDB_IMAGE, image_ID,
				    GIMP_PDB_DRAWABLE, drawable_ID,
				    GIMP_PDB_FLOAT, x,
				    GIMP_PDB_FLOAT, y,
				    GIMP_PDB_STRING, text,
				    GIMP_PDB_INT32, border,
				    GIMP_PDB_INT32, antialias,
				    GIMP_PDB_FLOAT, size,
				    GIMP_PDB_INT32, size_type,
				    GIMP_PDB_STRING, foundry,
				    GIMP_PDB_STRING, family,
				    GIMP_PDB_STRING, weight,
				    GIMP_PDB_STRING, slant,
				    GIMP_PDB_STRING, set_width,
				    GIMP_PDB_STRING, spacing,
				    GIMP_PDB_STRING, registry,
				    GIMP_PDB_STRING, encoding,
				    GIMP_PDB_END);

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
225 226 227 228 229 230 231
    text_layer_ID = return_vals[1].data.d_layer;

  gimp_destroy_params (return_vals, nreturn_vals);

  return text_layer_ID;
}

232 233 234 235 236
/**
 * gimp_text_get_extents:
 * @text: The text to generate.
 * @size: The size of text in either pixels or points.
 * @size_type: The units of specified size.
Manish Singh's avatar
Manish Singh committed
237 238 239 240 241 242 243 244
 * @foundry: The font foundry.
 * @family: The font family.
 * @weight: The font weight.
 * @slant: The font slant.
 * @set_width: The font set-width.
 * @spacing: The font spacing.
 * @registry: The font registry.
 * @encoding: The font encoding.
245 246 247 248 249
 * @width: The width of the specified font.
 * @height: The height of the specified font.
 * @ascent: The ascent of the specified font.
 * @descent: The descent of the specified font.
 *
250
 * This procedure is deprecated! Use gimp_text_get_extents_fontname()
251
 * instead.
252 253 254
 *
 * Returns: TRUE on success.
 */
255
gboolean
256
gimp_text_get_extents (const gchar  *text,
257 258
		       gdouble       size,
		       GimpSizeType  size_type,
259 260 261 262 263 264 265 266
		       const gchar  *foundry,
		       const gchar  *family,
		       const gchar  *weight,
		       const gchar  *slant,
		       const gchar  *set_width,
		       const gchar  *spacing,
		       const gchar  *registry,
		       const gchar  *encoding,
267 268 269 270 271
		       gint         *width,
		       gint         *height,
		       gint         *ascent,
		       gint         *descent)
{
272
  GimpParam *return_vals;
273
  gint nreturn_vals;
274
  gboolean success = TRUE;
275 276 277

  return_vals = gimp_run_procedure ("gimp_text_get_extents",
				    &nreturn_vals,
278 279 280 281 282 283 284 285 286 287 288 289
				    GIMP_PDB_STRING, text,
				    GIMP_PDB_FLOAT, size,
				    GIMP_PDB_INT32, size_type,
				    GIMP_PDB_STRING, foundry,
				    GIMP_PDB_STRING, family,
				    GIMP_PDB_STRING, weight,
				    GIMP_PDB_STRING, slant,
				    GIMP_PDB_STRING, set_width,
				    GIMP_PDB_STRING, spacing,
				    GIMP_PDB_STRING, registry,
				    GIMP_PDB_STRING, encoding,
				    GIMP_PDB_END);
290

291 292 293 294 295
  *width = 0;
  *height = 0;
  *ascent = 0;
  *descent = 0;

296 297 298
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
299 300 301 302 303 304 305 306
    {
      *width = return_vals[1].data.d_int32;
      *height = return_vals[2].data.d_int32;
      *ascent = return_vals[3].data.d_int32;
      *descent = return_vals[4].data.d_int32;
    }

  gimp_destroy_params (return_vals, nreturn_vals);
307 308

  return success;
309
}