Re: [Gimp-developer] gimp-text-fontname and gimp-text-get-extents-fontname for the PDB

2007-10-09 Thread Sven Neumann
Hi,

On Tue, 2007-10-09 at 18:50 +0200, Marcus Heese wrote:

 Alright I see... I would like to help for GIMP 2.6 to get a real good 
 implementation of the text-tool PDB API. So I declare myself a volunteer for 
 this task.

Yery nice. Please remember to bring up this issue again when 2.4 is out
so that we can discuss how to improve the API.

 However, is there a possibility to add another kludge to GIMP 2.4.x?

Sorry, but it is too late for such API additions now. GIMP 2.4 is going
to be released any day now and the API is frozen.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Gimp-developer] gimp-text-fontname and gimp-text-get-extents-fontname for the PDB

2007-10-08 Thread Marcus Heese
Hello there!

I've written a small patch based on the gimp-2.4.0-rc2 sources which 
implements a new gimp-text-fontname and gimp-text-get-extents-fontname 
function for the PDB. In fact, I wrote this because I needed the 
possibilities of adjusting letter/line spacing and indentation as well as the 
possibilities of directly getting access to hinting and auto-hinting in my 
gimp-ruby-scripts.

As I'm totally new to gimp development I don't really know if this was the 
right place to implement, so I just wrote two new 
functions gimp-text-fontname-new and gimp-text-get-extents-fontname-new 
and put them just in the same files where I found the other old equivalent 
functions. I hope my C knowledge wasn't that bad, but as gimp sources were 
really well arranged, it didn't take me too long to get used to the syntax.

I would be happy about some feedback because I urgently need this feature in 
the gimp.

Best regards
Marcus

diff -Naur gimp-2.4.0-rc2/app/pdb/text_tool_cmds.c gimp-2.4.0-rc2.new/app/pdb/text_tool_cmds.c
--- gimp-2.4.0-rc2/app/pdb/text_tool_cmds.c	2007-08-31 15:38:00.0 +0200
+++ gimp-2.4.0-rc2.new/app/pdb/text_tool_cmds.c	2007-09-26 18:47:49.0 +0200
@@ -96,6 +96,76 @@
 }
 
 static GValueArray *
+text_fontname_invoker_new (GimpProcedure *procedure,
+   Gimp  *gimp,
+   GimpContext   *context,
+   GimpProgress  *progress,
+   const GValueArray *args)
+{
+  gboolean success = TRUE;
+  GValueArray *return_vals;
+  GimpImage *image;
+  GimpDrawable *drawable;
+  gdouble x;
+  gdouble y;
+  const gchar *text;
+  gint32 border;
+  gboolean antialias;
+  gdouble size;
+  gint32 size_type;
+  const gchar *fontname;
+  gboolean autohint;
+  gboolean hinting;
+  gdouble indent;
+  gdouble line_spacing;
+  gdouble letter_spacing;
+  GimpLayer *text_layer = NULL;
+
+  image = gimp_value_get_image (args-values[0], gimp);
+  drawable = gimp_value_get_drawable (args-values[1], gimp);
+  x = g_value_get_double (args-values[2]);
+  y = g_value_get_double (args-values[3]);
+  text = g_value_get_string (args-values[4]);
+  border = g_value_get_int (args-values[5]);
+  antialias = g_value_get_boolean (args-values[6]);
+  size = g_value_get_double (args-values[7]);
+  size_type = g_value_get_enum (args-values[8]);
+  fontname = g_value_get_string (args-values[9]);
+  hinting = g_value_get_boolean (args-values[10]);
+  autohint = g_value_get_boolean (args-values[11]);
+  indent = g_value_get_double (args-values[12]);
+  line_spacing = g_value_get_double (args-values[13]);
+  letter_spacing = g_value_get_double (args-values[14]);
+  
+  
+
+  if (success)
+{
+  if (drawable  ! gimp_item_is_attached (GIMP_ITEM (drawable)))
+success = FALSE;
+
+  if (success)
+{
+  gchar *real_fontname = g_strdup_printf (%s %d, fontname, (gint) size);
+
+  text_layer = text_render_new (image, drawable, context,
+x, y, real_fontname, text,
+border, antialias, hinting, autohint,
+indent, line_spacing, letter_spacing);
+
+  g_free (real_fontname);
+}
+}
+
+  return_vals = gimp_procedure_get_return_values (procedure, success);
+
+  if (success)
+gimp_value_set_layer (return_vals-values[1], text_layer);
+
+  return return_vals;
+}
+
+static GValueArray *
 text_get_extents_fontname_invoker (GimpProcedure *procedure,
Gimp  *gimp,
GimpContext   *context,
@@ -143,6 +213,64 @@
 }
 
 static GValueArray *
+text_get_extents_fontname_invoker_new (GimpProcedure *procedure,
+   Gimp  *gimp,
+   GimpContext   *context,
+   GimpProgress  *progress,
+   const GValueArray *args)
+{
+  gboolean success = TRUE;
+  GValueArray *return_vals;
+  GimpImage *image;
+  const gchar *text;
+  gdouble size;
+  gint32 size_type;
+  const gchar *fontname;
+  gboolean antialias;
+  gboolean hinting;
+  gboolean autohint;
+  gdouble indent;
+  gdouble line_spacing;
+  gdouble letter_spacing;
+  gint32 width = 0;
+  gint32 height = 0;
+
+  image = gimp_value_get_image (args-values[0], gimp);
+  text = g_value_get_string (args-values[1]);
+  size = g_value_get_double (args-values[2]);
+  size_type = g_value_get_enum (args-values[3]);
+  fontname = g_value_get_string (args-values[4]);
+  antialias = g_value_get_boolean (args-values[5]);
+  hinting = g_value_get_boolean (args-values[6]);
+  autohint = g_value_get_boolean (args-values[7]);
+  indent = g_value_get_double (args-values[8]);
+  line_spacing = g_value_get_double(args-values[9]);
+  letter_spacing = g_value_get_double(args-values[10]);
+
+