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
|
|
|
/**
|
Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.
gimp_text_font() is easily tested in the Python console with:
> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())
And gimp_text_get_extents_font() with:
> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-03 02:38:18 +08:00
|
|
|
* gimp_text_font:
|
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.
|
Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.
gimp_text_font() is easily tested in the Python console with:
> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())
And gimp_text_get_extents_font() with:
> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-03 02:38:18 +08:00
|
|
|
* @size: The size of text in pixels.
|
|
|
|
* @font: The font.
|
2000-08-25 07:06:53 +08:00
|
|
|
*
|
|
|
|
* Add text at the specified location as a floating selection or a new
|
|
|
|
* layer.
|
|
|
|
*
|
Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.
gimp_text_font() is easily tested in the Python console with:
> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())
And gimp_text_get_extents_font() with:
> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-03 02:38:18 +08:00
|
|
|
* 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 (%NULL), 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.
|
|
|
|
* The size is always in pixels. 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 *
|
Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.
gimp_text_font() is easily tested in the Python console with:
> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())
And gimp_text_get_extents_font() with:
> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-03 02:38:18 +08:00
|
|
|
gimp_text_font (GimpImage *image,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
const gchar *text,
|
|
|
|
gint border,
|
|
|
|
gboolean antialias,
|
|
|
|
gdouble size,
|
|
|
|
GimpFont *font)
|
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,
|
Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.
gimp_text_font() is easily tested in the Python console with:
> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())
And gimp_text_get_extents_font() with:
> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-03 02:38:18 +08:00
|
|
|
GIMP_TYPE_FONT, font,
|
2019-07-30 16:51:16 +08:00
|
|
|
G_TYPE_NONE);
|
|
|
|
|
2023-10-17 04:07:55 +08:00
|
|
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
"gimp-text-font",
|
|
|
|
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
|
|
|
/**
|
Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.
gimp_text_font() is easily tested in the Python console with:
> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())
And gimp_text_get_extents_font() with:
> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-03 02:38:18 +08:00
|
|
|
* gimp_text_get_extents_font:
|
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.
|
Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.
gimp_text_font() is easily tested in the Python console with:
> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())
And gimp_text_get_extents_font() with:
> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-03 02:38:18 +08:00
|
|
|
* @font: The name of the font.
|
2023-10-03 03:30:20 +08:00
|
|
|
* @width: (out): The width of the glyph extents.
|
|
|
|
* @height: (out): The height of the glyph extents.
|
|
|
|
* @ascent: (out): The ascent of the glyph extents.
|
|
|
|
* @descent: (out): The descent of the glyph extents.
|
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
|
2023-10-03 03:30:20 +08:00
|
|
|
* specified text rendered with the specified font information. Ascent
|
|
|
|
* and descent of the glyph extents are returned as well.
|
|
|
|
* The ascent is the distance from the baseline to the highest point of
|
|
|
|
* the character. This is positive if the glyph ascends above the
|
|
|
|
* baseline. The descent is the distance from the baseline to the
|
|
|
|
* lowest point of the character. This is positive if the glyph
|
|
|
|
* descends below the baseline.
|
|
|
|
* The size is always in pixels. If you need to set 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
|
Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.
gimp_text_font() is easily tested in the Python console with:
> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())
And gimp_text_get_extents_font() with:
> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-03 02:38:18 +08:00
|
|
|
gimp_text_get_extents_font (const gchar *text,
|
|
|
|
gdouble size,
|
|
|
|
GimpFont *font,
|
|
|
|
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,
|
Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.
gimp_text_font() is easily tested in the Python console with:
> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())
And gimp_text_get_extents_font() with:
> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-03 02:38:18 +08:00
|
|
|
GIMP_TYPE_FONT, font,
|
2019-07-30 16:51:16 +08:00
|
|
|
G_TYPE_NONE);
|
|
|
|
|
2023-10-17 04:07:55 +08:00
|
|
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
"gimp-text-get-extents-font",
|
|
|
|
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
|
|
|
}
|