2000-06-01 20:20:13 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2003-07-03 08:47:26 +08:00
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
2000-06-01 20:20:13 +08:00
|
|
|
*
|
|
|
|
* gimptexttool_pdb.c
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2000-06-01 20:20:13 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2000-06-01 20:20:13 +08:00
|
|
|
*
|
|
|
|
* 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
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2000-06-01 20:20:13 +08:00
|
|
|
*/
|
|
|
|
|
2007-01-09 18:52:47 +08:00
|
|
|
/* NOTE: This file is auto-generated by pdbgen.pl */
|
2000-06-01 20:20:13 +08:00
|
|
|
|
2002-05-14 07:30:23 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2022-03-28 21:13:17 +08:00
|
|
|
#include "stamp-pdbgen.h"
|
|
|
|
|
2000-06-01 20:20:13 +08:00
|
|
|
#include "gimp.h"
|
|
|
|
|
2010-07-07 17:43:10 +08:00
|
|
|
|
|
|
|
/**
|
2019-07-31 16:04:43 +08:00
|
|
|
* SECTION: gimptexttool
|
2010-07-07 17:43:10 +08:00
|
|
|
* @title: gimptexttool
|
|
|
|
* @short_description: Functions for controlling the text tool.
|
|
|
|
*
|
|
|
|
* Functions for controlling the text tool.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2000-08-25 07:06:53 +08:00
|
|
|
/**
|
|
|
|
* gimp_text_fontname:
|
2019-08-11 20:20:05 +08:00
|
|
|
* @image: The image.
|
2019-08-25 17:50:17 +08:00
|
|
|
* @drawable: (nullable): The affected drawable: (%NULL for a new text layer).
|
2000-08-25 07:06:53 +08:00
|
|
|
* @x: The x coordinate for the left of the text bounding box.
|
|
|
|
* @y: The y coordinate for the top of the text bounding box.
|
2005-01-11 05:17:43 +08:00
|
|
|
* @text: The text to generate (in UTF-8 encoding).
|
2000-08-25 07:06:53 +08:00
|
|
|
* @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.
|
2003-07-31 00:48:12 +08:00
|
|
|
* @fontname: The name of the font.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Add text at the specified location as a floating selection or a new
|
|
|
|
* layer.
|
|
|
|
*
|
2001-08-12 05:35:23 +08:00
|
|
|
* 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
|
2019-08-25 17:50:17 +08:00
|
|
|
* parameter is not valid (%NULL), the text will appear as a new layer.
|
2001-08-12 05:35:23 +08:00
|
|
|
* Finally, a border can be specified around the final rendered text.
|
2006-06-28 14:46:07 +08:00
|
|
|
* The border is measured in pixels. Parameter size-type is not used
|
|
|
|
* and is currently ignored. 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.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
2019-08-25 17:50:17 +08:00
|
|
|
* Returns: (nullable) (transfer none):
|
|
|
|
* The new text layer or %NULL if no layer was created.
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2019-08-13 19:59:33 +08:00
|
|
|
GimpLayer *
|
2019-08-11 20:20:05 +08:00
|
|
|
gimp_text_fontname (GimpImage *image,
|
2019-08-13 19:59:33 +08:00
|
|
|
GimpDrawable *drawable,
|
2006-04-12 18:27:31 +08:00
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
const gchar *text,
|
|
|
|
gint border,
|
|
|
|
gboolean antialias,
|
|
|
|
gdouble size,
|
|
|
|
GimpSizeType size_type,
|
|
|
|
const gchar *fontname)
|
2000-06-01 20:20:13 +08:00
|
|
|
{
|
2019-07-30 16:51:16 +08:00
|
|
|
GimpValueArray *args;
|
|
|
|
GimpValueArray *return_vals;
|
2019-08-13 19:59:33 +08:00
|
|
|
GimpLayer *text_layer = NULL;
|
2000-06-01 20:20:13 +08:00
|
|
|
|
2019-08-08 19:01:50 +08:00
|
|
|
args = gimp_value_array_new_from_types (NULL,
|
2019-08-29 17:25:35 +08:00
|
|
|
GIMP_TYPE_IMAGE, image,
|
|
|
|
GIMP_TYPE_DRAWABLE, drawable,
|
2019-08-08 19:01:50 +08:00
|
|
|
G_TYPE_DOUBLE, x,
|
|
|
|
G_TYPE_DOUBLE, y,
|
|
|
|
G_TYPE_STRING, text,
|
2019-08-15 20:04:56 +08:00
|
|
|
G_TYPE_INT, border,
|
2019-08-08 19:01:50 +08:00
|
|
|
G_TYPE_BOOLEAN, antialias,
|
|
|
|
G_TYPE_DOUBLE, size,
|
|
|
|
GIMP_TYPE_SIZE_TYPE, size_type,
|
|
|
|
G_TYPE_STRING, fontname,
|
2019-07-30 16:51:16 +08:00
|
|
|
G_TYPE_NONE);
|
|
|
|
|
2019-09-04 05:55:49 +08:00
|
|
|
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
"gimp-text-fontname",
|
|
|
|
args);
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (args);
|
2019-08-12 20:44:07 +08:00
|
|
|
|
2019-09-04 07:49:35 +08:00
|
|
|
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
2019-09-04 08:49:33 +08:00
|
|
|
text_layer = GIMP_VALUES_GET_LAYER (return_vals, 1);
|
2019-08-12 20:44:07 +08:00
|
|
|
|
|
|
|
gimp_value_array_unref (return_vals);
|
|
|
|
|
2019-08-13 19:59:33 +08:00
|
|
|
return text_layer;
|
2019-08-12 20:44:07 +08:00
|
|
|
}
|
|
|
|
|
2000-08-25 07:06:53 +08:00
|
|
|
/**
|
|
|
|
* gimp_text_get_extents_fontname:
|
2005-01-11 05:17:43 +08:00
|
|
|
* @text: The text to generate (in UTF-8 encoding).
|
2000-08-25 07:06:53 +08:00
|
|
|
* @size: The size of text in either pixels or points.
|
|
|
|
* @size_type: The units of specified size.
|
2003-07-31 00:48:12 +08:00
|
|
|
* @fontname: The name of the font.
|
2019-08-01 04:51:35 +08:00
|
|
|
* @width: (out): The width of the specified font.
|
|
|
|
* @height: (out): The height of the specified font.
|
|
|
|
* @ascent: (out): The ascent of the specified font.
|
|
|
|
* @descent: (out): The descent of the specified font.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* 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
|
2006-06-28 14:46:07 +08:00
|
|
|
* and descent for the specified font are returned as well. Parameter
|
|
|
|
* size-type is not used and is currently ignored. If you need to
|
|
|
|
* display 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.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2000-08-23 09:44:59 +08:00
|
|
|
gboolean
|
2003-07-02 09:20:08 +08:00
|
|
|
gimp_text_get_extents_fontname (const gchar *text,
|
2006-04-12 18:27:31 +08:00
|
|
|
gdouble size,
|
|
|
|
GimpSizeType size_type,
|
|
|
|
const gchar *fontname,
|
|
|
|
gint *width,
|
|
|
|
gint *height,
|
|
|
|
gint *ascent,
|
|
|
|
gint *descent)
|
2000-06-01 20:20:13 +08:00
|
|
|
{
|
2019-07-30 16:51:16 +08:00
|
|
|
GimpValueArray *args;
|
|
|
|
GimpValueArray *return_vals;
|
2000-08-23 09:44:59 +08:00
|
|
|
gboolean success = TRUE;
|
2000-06-01 20:20:13 +08:00
|
|
|
|
2019-08-08 19:01:50 +08:00
|
|
|
args = gimp_value_array_new_from_types (NULL,
|
|
|
|
G_TYPE_STRING, text,
|
|
|
|
G_TYPE_DOUBLE, size,
|
|
|
|
GIMP_TYPE_SIZE_TYPE, size_type,
|
|
|
|
G_TYPE_STRING, fontname,
|
2019-07-30 16:51:16 +08:00
|
|
|
G_TYPE_NONE);
|
|
|
|
|
2019-09-04 05:55:49 +08:00
|
|
|
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
"gimp-text-get-extents-fontname",
|
|
|
|
args);
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (args);
|
2000-06-01 20:20:13 +08:00
|
|
|
|
2000-06-23 04:06:02 +08:00
|
|
|
*width = 0;
|
|
|
|
*height = 0;
|
|
|
|
*ascent = 0;
|
|
|
|
*descent = 0;
|
|
|
|
|
2019-09-04 07:49:35 +08:00
|
|
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
2000-08-23 09:44:59 +08:00
|
|
|
|
|
|
|
if (success)
|
2000-06-01 20:20:13 +08:00
|
|
|
{
|
2019-09-04 08:49:33 +08:00
|
|
|
*width = GIMP_VALUES_GET_INT (return_vals, 1);
|
|
|
|
*height = GIMP_VALUES_GET_INT (return_vals, 2);
|
|
|
|
*ascent = GIMP_VALUES_GET_INT (return_vals, 3);
|
|
|
|
*descent = GIMP_VALUES_GET_INT (return_vals, 4);
|
2000-06-01 20:20:13 +08:00
|
|
|
}
|
|
|
|
|
2019-07-30 16:51:16 +08:00
|
|
|
gimp_value_array_unref (return_vals);
|
2000-08-23 09:44:59 +08:00
|
|
|
|
|
|
|
return success;
|
2000-06-01 20:20:13 +08:00
|
|
|
}
|