home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / libgimp / gimptexttool_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-25  |  11.4 KB  |  337 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimptexttool_pdb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include "gimp.h"
  25.  
  26. /**
  27.  * gimp_text_fontname:
  28.  * @image_ID: The image.
  29.  * @drawable_ID: The affected drawable: (-1 for a new text layer).
  30.  * @x: The x coordinate for the left of the text bounding box.
  31.  * @y: The y coordinate for the top of the text bounding box.
  32.  * @text: The text to generate.
  33.  * @border: The size of the border.
  34.  * @antialias: Antialiasing.
  35.  * @size: The size of text in either pixels or points.
  36.  * @size_type: The units of specified size.
  37.  * @fontname: The fontname (conforming to the X Logical Font Description Conventions).
  38.  *
  39.  * Add text at the specified location as a floating selection or a new
  40.  * layer.
  41.  *
  42.  * This tool requires font information as a fontname conforming to the
  43.  * 'X Logical Font Description Conventions'. You can specify the
  44.  * fontsize in units of pixels or points, and the appropriate metric is
  45.  * specified using the size_type argument. The x and y parameters
  46.  * together control the placement of the new text by specifying the
  47.  * upper left corner of the text bounding box. If the antialias
  48.  * parameter is non-zero, the generated text will blend more smoothly
  49.  * with underlying layers. This option requires more time and memory to
  50.  * compute than non-antialiased text; the resulting floating selection
  51.  * or layer, however, will require the same amount of memory with or
  52.  * without antialiasing. If the specified drawable parameter is valid,
  53.  * the text will be created as a floating selection attached to the
  54.  * drawable. If the drawable parameter is not valid (-1), the text will
  55.  * appear as a new layer. Finally, a border can be specified around the
  56.  * final rendered text. The border is measured in pixels. If the border
  57.  * is specified as -1, empty spaces around the text will not be
  58.  * cropped.
  59.  *
  60.  * Returns: The new text layer.
  61.  */
  62. gint32
  63. gimp_text_fontname (gint32        image_ID,
  64.             gint32        drawable_ID,
  65.             gdouble       x,
  66.             gdouble       y,
  67.             gchar        *text,
  68.             gint          border,
  69.             gboolean      antialias,
  70.             gdouble       size,
  71.             GimpSizeType  size_type,
  72.             gchar        *fontname)
  73. {
  74.   GimpParam *return_vals;
  75.   gint nreturn_vals;
  76.   gint32 text_layer_ID = -1;
  77.  
  78.   return_vals = gimp_run_procedure ("gimp_text_fontname",
  79.                     &nreturn_vals,
  80.                     GIMP_PDB_IMAGE, image_ID,
  81.                     GIMP_PDB_DRAWABLE, drawable_ID,
  82.                     GIMP_PDB_FLOAT, x,
  83.                     GIMP_PDB_FLOAT, y,
  84.                     GIMP_PDB_STRING, text,
  85.                     GIMP_PDB_INT32, border,
  86.                     GIMP_PDB_INT32, antialias,
  87.                     GIMP_PDB_FLOAT, size,
  88.                     GIMP_PDB_INT32, size_type,
  89.                     GIMP_PDB_STRING, fontname,
  90.                     GIMP_PDB_END);
  91.  
  92.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  93.     text_layer_ID = return_vals[1].data.d_layer;
  94.  
  95.   gimp_destroy_params (return_vals, nreturn_vals);
  96.  
  97.   return text_layer_ID;
  98. }
  99.  
  100. /**
  101.  * gimp_text_get_extents_fontname:
  102.  * @text: The text to generate.
  103.  * @size: The size of text in either pixels or points.
  104.  * @size_type: The units of specified size.
  105.  * @fontname: The fontname (conforming to the X Logical Font Description Conventions).
  106.  * @width: The width of the specified font.
  107.  * @height: The height of the specified font.
  108.  * @ascent: The ascent of the specified font.
  109.  * @descent: The descent of the specified font.
  110.  *
  111.  * Get extents of the bounding box for the specified text.
  112.  *
  113.  * This tool returns the width and height of a bounding box for the
  114.  * specified text string with the specified font information. Ascent
  115.  * and descent for the specified font are returned as well.
  116.  *
  117.  * Returns: TRUE on success.
  118.  */
  119. gboolean
  120. gimp_text_get_extents_fontname (gchar        *text,
  121.                 gdouble       size,
  122.                 GimpSizeType  size_type,
  123.                 gchar        *fontname,
  124.                 gint         *width,
  125.                 gint         *height,
  126.                 gint         *ascent,
  127.                 gint         *descent)
  128. {
  129.   GimpParam *return_vals;
  130.   gint nreturn_vals;
  131.   gboolean success = TRUE;
  132.  
  133.   return_vals = gimp_run_procedure ("gimp_text_get_extents_fontname",
  134.                     &nreturn_vals,
  135.                     GIMP_PDB_STRING, text,
  136.                     GIMP_PDB_FLOAT, size,
  137.                     GIMP_PDB_INT32, size_type,
  138.                     GIMP_PDB_STRING, fontname,
  139.                     GIMP_PDB_END);
  140.  
  141.   *width = 0;
  142.   *height = 0;
  143.   *ascent = 0;
  144.   *descent = 0;
  145.  
  146.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  147.  
  148.   if (success)
  149.     {
  150.       *width = return_vals[1].data.d_int32;
  151.       *height = return_vals[2].data.d_int32;
  152.       *ascent = return_vals[3].data.d_int32;
  153.       *descent = return_vals[4].data.d_int32;
  154.     }
  155.  
  156.   gimp_destroy_params (return_vals, nreturn_vals);
  157.  
  158.   return success;
  159. }
  160.  
  161. /**
  162.  * gimp_text:
  163.  * @image_ID: The image.
  164.  * @drawable_ID: The affected drawable: (-1 for a new text layer).
  165.  * @x: The x coordinate for the left of the text bounding box.
  166.  * @y: The y coordinate for the top of the text bounding box.
  167.  * @text: The text to generate.
  168.  * @border: The size of the border.
  169.  * @antialias: Antialiasing.
  170.  * @size: The size of text in either pixels or points.
  171.  * @size_type: The units of specified size.
  172.  * @foundry: The font foundry, \"*\" for any.
  173.  * @family: The font family, \"*\" for any.
  174.  * @weight: The font weight, \"*\" for any.
  175.  * @slant: The font slant, \"*\" for any.
  176.  * @set_width: The font set-width, \"*\" for any.
  177.  * @spacing: The font spacing, \"*\" for any.
  178.  * @registry: The font registry, \"*\" for any.
  179.  * @encoding: The font encoding, \"*\" for any.
  180.  *
  181.  * Add text at the specified location as a floating selection or a new
  182.  * layer.
  183.  *
  184.  * This tool requires font information in the form of nine parameters:
  185.  * size, foundry, family, weight, slant, set_width, spacing, registry,
  186.  * encoding. The font size can either be specified in units of pixels
  187.  * or points, and the appropriate metric is specified using the
  188.  * size_type argument. The x and y parameters together control the
  189.  * placement of the new text by specifying the upper left corner of the
  190.  * text bounding box. If the antialias parameter is non-zero, the
  191.  * generated text will blend more smoothly with underlying layers. This
  192.  * option requires more time and memory to compute than non-antialiased
  193.  * text; the resulting floating selection or layer, however, will
  194.  * require the same amount of memory with or without antialiasing. If
  195.  * the specified drawable parameter is valid, the text will be created
  196.  * as a floating selection attached to the drawable. If the drawable
  197.  * parameter is not valid (-1), the text will appear as a new layer.
  198.  * Finally, a border can be specified around the final rendered text.
  199.  * The border is measured in pixels. If the border is specified as -1,
  200.  * empty spaces around the text will not be cropped.
  201.  *
  202.  * Returns: The new text layer.
  203.  */
  204. gint32
  205. gimp_text (gint32        image_ID,
  206.        gint32        drawable_ID,
  207.        gdouble       x,
  208.        gdouble       y,
  209.        gchar        *text,
  210.        gint          border,
  211.        gboolean      antialias,
  212.        gdouble       size,
  213.        GimpSizeType  size_type,
  214.        gchar        *foundry,
  215.        gchar        *family,
  216.        gchar        *weight,
  217.        gchar        *slant,
  218.        gchar        *set_width,
  219.        gchar        *spacing,
  220.        gchar        *registry,
  221.        gchar        *encoding)
  222. {
  223.   GimpParam *return_vals;
  224.   gint nreturn_vals;
  225.   gint32 text_layer_ID = -1;
  226.  
  227.   return_vals = gimp_run_procedure ("gimp_text",
  228.                     &nreturn_vals,
  229.                     GIMP_PDB_IMAGE, image_ID,
  230.                     GIMP_PDB_DRAWABLE, drawable_ID,
  231.                     GIMP_PDB_FLOAT, x,
  232.                     GIMP_PDB_FLOAT, y,
  233.                     GIMP_PDB_STRING, text,
  234.                     GIMP_PDB_INT32, border,
  235.                     GIMP_PDB_INT32, antialias,
  236.                     GIMP_PDB_FLOAT, size,
  237.                     GIMP_PDB_INT32, size_type,
  238.                     GIMP_PDB_STRING, foundry,
  239.                     GIMP_PDB_STRING, family,
  240.                     GIMP_PDB_STRING, weight,
  241.                     GIMP_PDB_STRING, slant,
  242.                     GIMP_PDB_STRING, set_width,
  243.                     GIMP_PDB_STRING, spacing,
  244.                     GIMP_PDB_STRING, registry,
  245.                     GIMP_PDB_STRING, encoding,
  246.                     GIMP_PDB_END);
  247.  
  248.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  249.     text_layer_ID = return_vals[1].data.d_layer;
  250.  
  251.   gimp_destroy_params (return_vals, nreturn_vals);
  252.  
  253.   return text_layer_ID;
  254. }
  255.  
  256. /**
  257.  * gimp_text_get_extents:
  258.  * @text: The text to generate.
  259.  * @size: The size of text in either pixels or points.
  260.  * @size_type: The units of specified size.
  261.  * @foundry: The font foundry, \"*\" for any.
  262.  * @family: The font family, \"*\" for any.
  263.  * @weight: The font weight, \"*\" for any.
  264.  * @slant: The font slant, \"*\" for any.
  265.  * @set_width: The font set-width, \"*\" for any.
  266.  * @spacing: The font spacing, \"*\" for any.
  267.  * @registry: The font registry, \"*\" for any.
  268.  * @encoding: The font encoding, \"*\" for any.
  269.  * @width: The width of the specified font.
  270.  * @height: The height of the specified font.
  271.  * @ascent: The ascent of the specified font.
  272.  * @descent: The descent of the specified font.
  273.  *
  274.  * Get extents of the bounding box for the specified text.
  275.  *
  276.  * This tool returns the width and height of a bounding box for the
  277.  * specified text string with the specified font information. Ascent
  278.  * and descent for the specified font are returned as well.
  279.  *
  280.  * Returns: TRUE on success.
  281.  */
  282. gboolean
  283. gimp_text_get_extents (gchar        *text,
  284.                gdouble       size,
  285.                GimpSizeType  size_type,
  286.                gchar        *foundry,
  287.                gchar        *family,
  288.                gchar        *weight,
  289.                gchar        *slant,
  290.                gchar        *set_width,
  291.                gchar        *spacing,
  292.                gchar        *registry,
  293.                gchar        *encoding,
  294.                gint         *width,
  295.                gint         *height,
  296.                gint         *ascent,
  297.                gint         *descent)
  298. {
  299.   GimpParam *return_vals;
  300.   gint nreturn_vals;
  301.   gboolean success = TRUE;
  302.  
  303.   return_vals = gimp_run_procedure ("gimp_text_get_extents",
  304.                     &nreturn_vals,
  305.                     GIMP_PDB_STRING, text,
  306.                     GIMP_PDB_FLOAT, size,
  307.                     GIMP_PDB_INT32, size_type,
  308.                     GIMP_PDB_STRING, foundry,
  309.                     GIMP_PDB_STRING, family,
  310.                     GIMP_PDB_STRING, weight,
  311.                     GIMP_PDB_STRING, slant,
  312.                     GIMP_PDB_STRING, set_width,
  313.                     GIMP_PDB_STRING, spacing,
  314.                     GIMP_PDB_STRING, registry,
  315.                     GIMP_PDB_STRING, encoding,
  316.                     GIMP_PDB_END);
  317.  
  318.   *width = 0;
  319.   *height = 0;
  320.   *ascent = 0;
  321.   *descent = 0;
  322.  
  323.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  324.  
  325.   if (success)
  326.     {
  327.       *width = return_vals[1].data.d_int32;
  328.       *height = return_vals[2].data.d_int32;
  329.       *ascent = return_vals[3].data.d_int32;
  330.       *descent = return_vals[4].data.d_int32;
  331.     }
  332.  
  333.   gimp_destroy_params (return_vals, nreturn_vals);
  334.  
  335.   return success;
  336. }
  337.