app, libgimp, pdb: gimp_text_layer_new() now uses GimpFont.

This function is not perfect and in particular doesn't seem usable with binding
because of GimpUnit being some weird mix between an enum and some kind of class.

So this will have to be fixed too. See #8900.
This commit is contained in:
Jehan 2023-09-13 19:24:10 +02:00
parent ea55b7a11a
commit 0273c1031c
6 changed files with 25 additions and 29 deletions

View File

@ -63,14 +63,14 @@ text_layer_new_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpImage *image;
const gchar *text;
const gchar *fontname;
GimpFont *font;
gdouble size;
GimpUnit unit;
GimpTextLayer *layer = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
text = g_value_get_string (gimp_value_array_index (args, 1));
fontname = g_value_get_string (gimp_value_array_index (args, 2));
font = g_value_get_object (gimp_value_array_index (args, 2));
size = g_value_get_double (gimp_value_array_index (args, 3));
unit = g_value_get_int (gimp_value_array_index (args, 4));
@ -83,7 +83,7 @@ text_layer_new_invoker (GimpProcedure *procedure,
gimp_text = g_object_new (GIMP_TYPE_TEXT,
"text", text,
"font", fontname,
"font", font,
"font-size", size,
"font-size-unit", unit,
"color", &color,
@ -1024,12 +1024,11 @@ register_text_layer_procs (GimpPDB *pdb)
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("fontname",
"fontname",
"The name of the font",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_param_spec_font ("font",
"font",
"The font to write the text with",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("size",
"size",

View File

@ -82,11 +82,11 @@ gimp_text_layer_get_by_id (gint32 layer_id)
/**
* gimp_text_layer_new:
* @image: The image to which to add the layer.
* @text: The text to generate (in UTF-8 encoding).
* @fontname: The name of the font.
* @size: The size of text in either pixels or points.
* @unit: The units of specified size.
* @image: The image to which to add the layer.
* @text: The text to generate (in UTF-8 encoding).
* @font: The name of the font.
* @size: The size of text in either pixels or points.
* @unit: The units of specified size.
*
* Create a new layer.
*
@ -107,11 +107,11 @@ gimp_text_layer_get_by_id (gint32 layer_id)
GimpTextLayer *
gimp_text_layer_new (GimpImage *image,
const gchar *text,
const gchar *fontname,
GimpFont *font,
gdouble size,
GimpUnit unit)
{
return _gimp_text_layer_new (image, text, fontname, size, unit);
return _gimp_text_layer_new (image, text, font, size, unit);
}
@ -121,9 +121,8 @@ static GimpLayer *
gimp_text_layer_copy (GimpLayer *layer)
{
GimpTextLayer *new_layer;
GimpFont *font;
gchar *text;
gchar *fontname;
GimpFont *font;
gdouble size;
GimpUnit unit;
@ -131,12 +130,10 @@ gimp_text_layer_copy (GimpLayer *layer)
text = gimp_text_layer_get_text (GIMP_TEXT_LAYER (layer));
font = gimp_text_layer_get_font (GIMP_TEXT_LAYER (layer));
fontname = gimp_resource_get_name (GIMP_RESOURCE (font));
size = gimp_text_layer_get_font_size (GIMP_TEXT_LAYER (layer), &unit);
new_layer = gimp_text_layer_new (gimp_item_get_image (GIMP_ITEM (layer)),
text, fontname, size, unit);
text, font, size, unit);
g_free (text);
g_free (fontname);
return GIMP_LAYER (new_layer);
}

View File

@ -39,7 +39,7 @@ GimpTextLayer * gimp_text_layer_get_by_id (gint32 layer_id);
GimpTextLayer * gimp_text_layer_new (GimpImage *image,
const gchar *text,
const gchar *fontname,
GimpFont *font,
gdouble size,
GimpUnit unit);

View File

@ -40,7 +40,7 @@
* _gimp_text_layer_new:
* @image: The image.
* @text: The text to generate (in UTF-8 encoding).
* @fontname: The name of the font.
* @font: The font to write the text with.
* @size: The size of text in either pixels or points.
* @unit: The units of specified size.
*
@ -60,7 +60,7 @@
GimpTextLayer *
_gimp_text_layer_new (GimpImage *image,
const gchar *text,
const gchar *fontname,
GimpFont *font,
gdouble size,
GimpUnit unit)
{
@ -71,7 +71,7 @@ _gimp_text_layer_new (GimpImage *image,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_STRING, text,
G_TYPE_STRING, fontname,
GIMP_TYPE_FONT, font,
G_TYPE_DOUBLE, size,
GIMP_TYPE_UNIT, unit,
G_TYPE_NONE);

View File

@ -34,7 +34,7 @@ G_BEGIN_DECLS
G_GNUC_INTERNAL GimpTextLayer* _gimp_text_layer_new (GimpImage *image,
const gchar *text,
const gchar *fontname,
GimpFont *font,
gdouble size,
GimpUnit unit);
gchar* gimp_text_layer_get_text (GimpTextLayer *layer);

View File

@ -38,8 +38,8 @@ HELP
desc => 'The image' },
{ name => 'text', type => 'string',
desc => 'The text to generate (in UTF-8 encoding)' },
{ name => 'fontname', type => 'string',
desc => 'The name of the font' },
{ name => 'font', type => 'font',
desc => 'The font to write the text with' },
{ name => 'size', type => '0.0 <= float <= 8192.0',
desc => 'The size of text in either pixels or points' },
{ name => 'unit', type => 'unit',
@ -61,7 +61,7 @@ HELP
gimp_text = g_object_new (GIMP_TYPE_TEXT,
"text", text,
"font", fontname,
"font", font,
"font-size", size,
"font-size-unit", unit,
"color", &color,