From e70fa1dd99a2d17ea0a262ce7ef5d7def87587a1 Mon Sep 17 00:00:00 2001 From: Idriss Fekir Date: Fri, 23 Feb 2024 23:03:35 +0100 Subject: [PATCH 1/4] Pdf-Save:Set width/height only with fixed text box The Pango layout width/height should not be set when the text layer is dynamic (this is the behavior in core). This is based on Massimo's comment on issue #7092. --- app/pdb/internal-procs.c | 2 +- app/pdb/text-layer-cmds.c | 58 +++++++++++++++++++++++++++++++++ libgimp/gimp.def | 1 + libgimp/gimptextlayer_pdb.c | 34 +++++++++++++++++++ libgimp/gimptextlayer_pdb.h | 1 + pdb/groups/text_layer.pdb | 33 ++++++++++++++++++- plug-ins/common/file-pdf-save.c | 22 +++++++------ 7 files changed, 139 insertions(+), 12 deletions(-) diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c index e33f6b0e550..7aa6e697ae7 100644 --- a/app/pdb/internal-procs.c +++ b/app/pdb/internal-procs.c @@ -30,7 +30,7 @@ #include "internal-procs.h" -/* 784 procedures registered total */ +/* 785 procedures registered total */ void internal_procs_init (GimpPDB *pdb) diff --git a/app/pdb/text-layer-cmds.c b/app/pdb/text-layer-cmds.c index f054ddf7aaa..caf4b47fe74 100644 --- a/app/pdb/text-layer-cmds.c +++ b/app/pdb/text-layer-cmds.c @@ -991,6 +991,35 @@ text_layer_resize_invoker (GimpProcedure *procedure, error ? *error : NULL); } +static GimpValueArray * +text_layer_is_dynamic_invoker (GimpProcedure *procedure, + Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const GimpValueArray *args, + GError **error) +{ + gboolean success = TRUE; + GimpValueArray *return_vals; + GimpTextLayer *layer; + gboolean is_dynamic = FALSE; + + layer = g_value_get_object (gimp_value_array_index (args, 0)); + + if (success) + { + is_dynamic = gimp_text_layer_get_text (layer)->box_mode == GIMP_TEXT_BOX_DYNAMIC; + } + + return_vals = gimp_procedure_get_return_values (procedure, success, + error ? *error : NULL); + + if (success) + g_value_set_boolean (gimp_value_array_index (return_vals, 1), is_dynamic); + + return return_vals; +} + void register_text_layer_procs (GimpPDB *pdb) { @@ -1928,4 +1957,33 @@ register_text_layer_procs (GimpPDB *pdb) GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); + + /* + * gimp-text-layer-is-dynamic + */ + procedure = gimp_procedure_new (text_layer_is_dynamic_invoker); + gimp_object_set_static_name (GIMP_OBJECT (procedure), + "gimp-text-layer-is-dynamic"); + gimp_procedure_set_static_help (procedure, + "Checks whether or not a text layer is dynamic.", + "This procedure checks whether or not a text layer is dynamic.", + NULL); + gimp_procedure_set_static_attribution (procedure, + "", + "", + ""); + gimp_procedure_add_argument (procedure, + gimp_param_spec_text_layer ("layer", + "layer", + "The text layer", + FALSE, + GIMP_PARAM_READWRITE)); + gimp_procedure_add_return_value (procedure, + g_param_spec_boolean ("is-dynamic", + "is dynamic", + "Whether a text layer is dynamic", + FALSE, + GIMP_PARAM_READWRITE)); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); } diff --git a/libgimp/gimp.def b/libgimp/gimp.def index efa42d6319b..938c65bc3b3 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -863,6 +863,7 @@ EXPORTS gimp_text_layer_get_markup gimp_text_layer_get_text gimp_text_layer_get_type + gimp_text_layer_is_dynamic gimp_text_layer_new gimp_text_layer_resize gimp_text_layer_set_antialias diff --git a/libgimp/gimptextlayer_pdb.c b/libgimp/gimptextlayer_pdb.c index eb3416e21dc..ef9ee9105df 100644 --- a/libgimp/gimptextlayer_pdb.c +++ b/libgimp/gimptextlayer_pdb.c @@ -1210,3 +1210,37 @@ gimp_text_layer_resize (GimpTextLayer *layer, return success; } + +/** + * gimp_text_layer_is_dynamic: + * @layer: The text layer. + * + * Checks whether or not a text layer is dynamic. + * + * This procedure checks whether or not a text layer is dynamic. + * + * Returns: Whether a text layer is dynamic. + **/ +gboolean +gimp_text_layer_is_dynamic (GimpTextLayer *layer) +{ + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean is_dynamic = FALSE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_TEXT_LAYER, layer, + G_TYPE_NONE); + + return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (), + "gimp-text-layer-is-dynamic", + args); + gimp_value_array_unref (args); + + if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) + is_dynamic = GIMP_VALUES_GET_BOOLEAN (return_vals, 1); + + gimp_value_array_unref (return_vals); + + return is_dynamic; +} diff --git a/libgimp/gimptextlayer_pdb.h b/libgimp/gimptextlayer_pdb.h index 15a80a6a0a9..842afe9e423 100644 --- a/libgimp/gimptextlayer_pdb.h +++ b/libgimp/gimptextlayer_pdb.h @@ -84,6 +84,7 @@ gboolean gimp_text_layer_set_letter_spacing (GimpTextLayer gboolean gimp_text_layer_resize (GimpTextLayer *layer, gdouble width, gdouble height); +gboolean gimp_text_layer_is_dynamic (GimpTextLayer *layer); G_END_DECLS diff --git a/pdb/groups/text_layer.pdb b/pdb/groups/text_layer.pdb index ac999c99ef0..8eb18ea3265 100644 --- a/pdb/groups/text_layer.pdb +++ b/pdb/groups/text_layer.pdb @@ -990,6 +990,36 @@ CODE ); } +sub text_layer_is_dynamic { + $blurb = 'Checks whether or not a text layer is dynamic.'; + + $help = <<'HELP'; +This procedure checks whether or not a text layer is dynamic. +HELP + + $author = 'Idriss Fekir '; + $copyright = 'Idriss Fekir'; + $date = '2024'; + $since = '2.99.19'; + + @inargs = ( + { name => 'layer', type => 'text_layer', + desc => 'The text layer' }, + ); + + @outargs = ( + { name => 'is_dynamic', type => 'boolean', + desc => 'Whether a text layer is dynamic' }, + ); + + %invoke = ( + code => <<'CODE' +{ + is_dynamic = gimp_text_layer_get_text (layer)->box_mode == GIMP_TEXT_BOX_DYNAMIC; +} +CODE + ); +} @headers = qw( "libgimpbase/gimpbase.h" @@ -1030,7 +1060,8 @@ CODE text_layer_set_line_spacing text_layer_get_letter_spacing text_layer_set_letter_spacing - text_layer_resize); + text_layer_resize + text_layer_is_dynamic); %exports = (app => [@procs], lib => [@procs]); diff --git a/plug-ins/common/file-pdf-save.c b/plug-ins/common/file-pdf-save.c index 9753357bc15..e2318279d24 100644 --- a/plug-ins/common/file-pdf-save.c +++ b/plug-ins/common/file-pdf-save.c @@ -1711,16 +1711,18 @@ drawText (GimpLayer *layer, pango_layout_set_font_description (layout, font_description); - /* Width */ - if (! PANGO_GRAVITY_IS_VERTICAL (pango_context_get_base_gravity (context))) - pango_layout_set_width (layout, - gimp_drawable_get_width (GIMP_DRAWABLE (layer)) * - PANGO_SCALE); - else - pango_layout_set_width (layout, - gimp_drawable_get_height (GIMP_DRAWABLE (layer)) * - PANGO_SCALE); - + if (! gimp_text_layer_is_dynamic (GIMP_TEXT_LAYER (layer))) + { + /* Width */ + if (! PANGO_GRAVITY_IS_VERTICAL (pango_context_get_base_gravity (context))) + pango_layout_set_width (layout, + gimp_drawable_get_width (GIMP_DRAWABLE (layer)) * + PANGO_SCALE); + else + pango_layout_set_width (layout, + gimp_drawable_get_height (GIMP_DRAWABLE (layer)) * + PANGO_SCALE); + } /* Justification, and Alignment */ justify = FALSE; j = gimp_text_layer_get_justification (GIMP_TEXT_LAYER (layer)); -- GitLab From ee65cd37cfb3466b4797223638c85958c832951f Mon Sep 17 00:00:00 2001 From: Idriss Fekir Date: Sat, 24 Feb 2024 15:24:01 +0100 Subject: [PATCH 2/4] pdf-save:Fix letter spacing For some reason, unless letter spacing is set in the pango markup it is ignored. It is taken into account only when present in the pango markup. --- plug-ins/common/file-pdf-save.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/plug-ins/common/file-pdf-save.c b/plug-ins/common/file-pdf-save.c index e2318279d24..95126ab33e0 100644 --- a/plug-ins/common/file-pdf-save.c +++ b/plug-ins/common/file-pdf-save.c @@ -1571,7 +1571,6 @@ drawText (GimpLayer *layer, gdouble indent; gdouble line_spacing; gdouble letter_spacing; - PangoAttribute *letter_spacing_at; PangoAttrList *attr_list = pango_attr_list_new (); PangoFontMap *fontmap; @@ -1756,8 +1755,21 @@ drawText (GimpLayer *layer, /* Letter Spacing */ letter_spacing = gimp_text_layer_get_letter_spacing (GIMP_TEXT_LAYER (layer)); - letter_spacing_at = pango_attr_letter_spacing_new ((int)(PANGO_SCALE * letter_spacing)); - pango_attr_list_insert (attr_list, letter_spacing_at); + /* + * for some reason if the letter spacing is not specified in the pango markup + * (and is instead set for the pango layout) it is ignored. + */ + if (fabs (letter_spacing) > 0.1) + { + if (markup != NULL && markup[0] != '\0') + markup = g_strdup_printf ("%s", + (gint) (letter_spacing * PANGO_SCALE), + markup); + else + markup = g_strdup_printf ("%s", + (gint) (letter_spacing * PANGO_SCALE), + text); + } pango_layout_set_attributes (layout, attr_list); @@ -1785,6 +1797,9 @@ drawText (GimpLayer *layer, pango_cairo_show_layout (cr, layout); + if (fabs (letter_spacing) > 0.1) + g_free (markup); + g_free (text); g_free (language); -- GitLab From 0fed3f9a0d616b38f743773f34621aa98e35c856 Mon Sep 17 00:00:00 2001 From: Idriss Fekir Date: Sat, 24 Feb 2024 21:11:52 +0100 Subject: [PATCH 3/4] Pdf-save: Add offset to match core Core text rendering code adds an offset to accomodate cases where the the logical rectangle is different than the ink rectangle. The pdf export code should do the same, otherwise text won't appear at the exact same position it was on canvas. See Massimo's comments on issue #7092. --- app/pdb/internal-procs.c | 2 +- app/pdb/text-layer-cmds.c | 83 +++++++++++++++++++++++++++++++-- app/text/gimptextlayer.c | 41 ++++++++++++++++ app/text/gimptextlayer.h | 29 ++++++------ libgimp/gimp.def | 1 + libgimp/gimptextlayer_pdb.c | 50 ++++++++++++++++++++ libgimp/gimptextlayer_pdb.h | 3 ++ pdb/groups/text_layer.pdb | 45 +++++++++++++++++- plug-ins/common/file-pdf-save.c | 4 ++ 9 files changed, 239 insertions(+), 19 deletions(-) diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c index 7aa6e697ae7..3b5b36ed2e0 100644 --- a/app/pdb/internal-procs.c +++ b/app/pdb/internal-procs.c @@ -30,7 +30,7 @@ #include "internal-procs.h" -/* 785 procedures registered total */ +/* 786 procedures registered total */ void internal_procs_init (GimpPDB *pdb) diff --git a/app/pdb/text-layer-cmds.c b/app/pdb/text-layer-cmds.c index caf4b47fe74..cea2f4ed6d6 100644 --- a/app/pdb/text-layer-cmds.c +++ b/app/pdb/text-layer-cmds.c @@ -41,6 +41,7 @@ #include "text/gimpfont.h" #include "text/gimptext.h" #include "text/gimptextlayer.h" +#include "text/gimptextlayout.h" #include "gimppdb.h" #include "gimppdberror.h" @@ -1020,6 +1021,47 @@ text_layer_is_dynamic_invoker (GimpProcedure *procedure, return return_vals; } +static GimpValueArray * +text_layer_get_offsets_invoker (GimpProcedure *procedure, + Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const GimpValueArray *args, + GError **error) +{ + gboolean success = TRUE; + GimpValueArray *return_vals; + GimpTextLayer *layer; + gint x = 0; + gint y = 0; + + layer = g_value_get_object (gimp_value_array_index (args, 0)); + + if (success) + { + GimpTextLayout *layout = gimp_text_layer_get_layout (layer); + + if (layout == NULL) + success = FALSE; + else + { + gimp_text_layout_get_offsets (layout, &x, &y); + g_object_unref (layout); + } + } + + return_vals = gimp_procedure_get_return_values (procedure, success, + error ? *error : NULL); + + if (success) + { + g_value_set_int (gimp_value_array_index (return_vals, 1), x); + g_value_set_int (gimp_value_array_index (return_vals, 2), y); + } + + return return_vals; +} + void register_text_layer_procs (GimpPDB *pdb) { @@ -1969,9 +2011,9 @@ register_text_layer_procs (GimpPDB *pdb) "This procedure checks whether or not a text layer is dynamic.", NULL); gimp_procedure_set_static_attribution (procedure, - "", - "", - ""); + "Idriss Fekir ", + "Idriss Fekir", + "2024"); gimp_procedure_add_argument (procedure, gimp_param_spec_text_layer ("layer", "layer", @@ -1986,4 +2028,39 @@ register_text_layer_procs (GimpPDB *pdb) GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); + + /* + * gimp-text-layer-get-offsets + */ + procedure = gimp_procedure_new (text_layer_get_offsets_invoker); + gimp_object_set_static_name (GIMP_OBJECT (procedure), + "gimp-text-layer-get-offsets"); + gimp_procedure_set_static_help (procedure, + "Gets x, y offsets of the associated text layout.", + "This procedure returns the offsets of the text layout.", + NULL); + gimp_procedure_set_static_attribution (procedure, + "Idriss Fekir ", + "Idriss Fekir", + "2024"); + gimp_procedure_add_argument (procedure, + gimp_param_spec_text_layer ("layer", + "layer", + "The text layer", + FALSE, + GIMP_PARAM_READWRITE)); + gimp_procedure_add_return_value (procedure, + g_param_spec_int ("x", + "x", + "x offset", + G_MININT32, G_MAXINT32, 0, + GIMP_PARAM_READWRITE)); + gimp_procedure_add_return_value (procedure, + g_param_spec_int ("y", + "y", + "y offset", + G_MININT32, G_MAXINT32, 0, + GIMP_PARAM_READWRITE)); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); } diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c index 82af355a31f..4dc3acf556d 100644 --- a/app/text/gimptextlayer.c +++ b/app/text/gimptextlayer.c @@ -595,6 +595,47 @@ gimp_item_is_text_layer (GimpItem *item) GIMP_TEXT_LAYER (item)->modified == FALSE); } +GimpTextLayout * +gimp_text_layer_get_layout (GimpTextLayer *layer) +{ + GimpTextLayout *layout; + GimpItem *item; + GimpImage *image; + GimpContainer *container; + gdouble xres; + gdouble yres; + GError *error = NULL; + + if (! layer->text) + return FALSE; + + item = GIMP_ITEM (layer); + image = gimp_item_get_image (item); + container = gimp_data_factory_get_container (image->gimp->font_factory); + + gimp_data_factory_data_wait (image->gimp->font_factory); + + if (gimp_container_is_empty (container)) + { + gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_ERROR, + _("Due to lack of any fonts, " + "text functionality is not available.")); + return NULL; + } + + gimp_image_get_resolution (image, &xres, &yres); + + layout = gimp_text_layout_new (layer->text, image, xres, yres, &error); + + if (error) + { + gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_ERROR, error->message); + g_error_free (error); + return NULL; + } + + return layout; +} /* private functions */ diff --git a/app/text/gimptextlayer.h b/app/text/gimptextlayer.h index 53a233ff0a1..87f2c43a1e2 100644 --- a/app/text/gimptextlayer.h +++ b/app/text/gimptextlayer.h @@ -60,20 +60,21 @@ struct _GimpTextLayerClass }; -GType gimp_text_layer_get_type (void) G_GNUC_CONST; - -GimpLayer * gimp_text_layer_new (GimpImage *image, - GimpText *text); -GimpText * gimp_text_layer_get_text (GimpTextLayer *layer); -void gimp_text_layer_set_text (GimpTextLayer *layer, - GimpText *text); -void gimp_text_layer_discard (GimpTextLayer *layer); -void gimp_text_layer_set (GimpTextLayer *layer, - const gchar *undo_desc, - const gchar *first_property_name, - ...) G_GNUC_NULL_TERMINATED; - -gboolean gimp_item_is_text_layer (GimpItem *item); +GType gimp_text_layer_get_type (void) G_GNUC_CONST; + +GimpLayer * gimp_text_layer_new (GimpImage *image, + GimpText *text); +GimpText * gimp_text_layer_get_text (GimpTextLayer *layer); +void gimp_text_layer_set_text (GimpTextLayer *layer, + GimpText *text); +void gimp_text_layer_discard (GimpTextLayer *layer); +void gimp_text_layer_set (GimpTextLayer *layer, + const gchar *undo_desc, + const gchar *first_property_name, + ...) G_GNUC_NULL_TERMINATED; + +gboolean gimp_item_is_text_layer (GimpItem *item); +GimpTextLayout * gimp_text_layer_get_layout (GimpTextLayer *layer); #endif /* __GIMP_TEXT_LAYER_H__ */ diff --git a/libgimp/gimp.def b/libgimp/gimp.def index 938c65bc3b3..7e8872e583b 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -861,6 +861,7 @@ EXPORTS gimp_text_layer_get_letter_spacing gimp_text_layer_get_line_spacing gimp_text_layer_get_markup + gimp_text_layer_get_offsets gimp_text_layer_get_text gimp_text_layer_get_type gimp_text_layer_is_dynamic diff --git a/libgimp/gimptextlayer_pdb.c b/libgimp/gimptextlayer_pdb.c index ef9ee9105df..cd7bc445853 100644 --- a/libgimp/gimptextlayer_pdb.c +++ b/libgimp/gimptextlayer_pdb.c @@ -1220,6 +1220,8 @@ gimp_text_layer_resize (GimpTextLayer *layer, * This procedure checks whether or not a text layer is dynamic. * * Returns: Whether a text layer is dynamic. + * + * Since: 2.99.19 **/ gboolean gimp_text_layer_is_dynamic (GimpTextLayer *layer) @@ -1244,3 +1246,51 @@ gimp_text_layer_is_dynamic (GimpTextLayer *layer) return is_dynamic; } + +/** + * gimp_text_layer_get_offsets: + * @layer: The text layer. + * @x: (out): x offset. + * @y: (out): y offset. + * + * Gets x, y offsets of the associated text layout. + * + * This procedure returns the offsets of the text layout. + * + * Returns: TRUE on success. + * + * Since: 2.99.19 + **/ +gboolean +gimp_text_layer_get_offsets (GimpTextLayer *layer, + gint *x, + gint *y) +{ + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_TEXT_LAYER, layer, + G_TYPE_NONE); + + return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (), + "gimp-text-layer-get-offsets", + args); + gimp_value_array_unref (args); + + *x = 0; + *y = 0; + + success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; + + if (success) + { + *x = GIMP_VALUES_GET_INT (return_vals, 1); + *y = GIMP_VALUES_GET_INT (return_vals, 2); + } + + gimp_value_array_unref (return_vals); + + return success; +} diff --git a/libgimp/gimptextlayer_pdb.h b/libgimp/gimptextlayer_pdb.h index 842afe9e423..2c491d7dccd 100644 --- a/libgimp/gimptextlayer_pdb.h +++ b/libgimp/gimptextlayer_pdb.h @@ -85,6 +85,9 @@ gboolean gimp_text_layer_resize (GimpTextLayer gdouble width, gdouble height); gboolean gimp_text_layer_is_dynamic (GimpTextLayer *layer); +gboolean gimp_text_layer_get_offsets (GimpTextLayer *layer, + gint *x, + gint *y); G_END_DECLS diff --git a/pdb/groups/text_layer.pdb b/pdb/groups/text_layer.pdb index 8eb18ea3265..3b9fb781db9 100644 --- a/pdb/groups/text_layer.pdb +++ b/pdb/groups/text_layer.pdb @@ -1021,12 +1021,54 @@ CODE ); } +sub text_layer_get_offsets { + $blurb = 'Gets x, y offsets of the associated text layout.'; + + $help = <<'HELP'; +This procedure returns the offsets of the text layout. +HELP + + $author = 'Idriss Fekir '; + $copyright = 'Idriss Fekir'; + $date = '2024'; + $since = '2.99.19'; + + @inargs = ( + { name => 'layer', type => 'text_layer', + desc => 'The text layer' } + ); + + @outargs = ( + { name => 'x', type => 'int32', void_ret => 1, + desc => 'x offset' }, + { name => 'y', type => 'int32', + desc => 'y offset' } + ); + + %invoke = ( + code => <<'CODE' +{ + GimpTextLayout *layout = gimp_text_layer_get_layout (layer); + + if (layout == NULL) + success = FALSE; + else + { + gimp_text_layout_get_offsets (layout, &x, &y); + g_object_unref (layout); + } +} +CODE + ); +} + @headers = qw( "libgimpbase/gimpbase.h" "core/gimpcontext.h" "text/gimpfont.h" "text/gimptext.h" "text/gimptextlayer.h" + "text/gimptextlayout.h" "gimppdb-utils.h" "gimppdberror.h" "gimp-intl.h"); @@ -1061,7 +1103,8 @@ CODE text_layer_get_letter_spacing text_layer_set_letter_spacing text_layer_resize - text_layer_is_dynamic); + text_layer_is_dynamic + text_layer_get_offsets); %exports = (app => [@procs], lib => [@procs]); diff --git a/plug-ins/common/file-pdf-save.c b/plug-ins/common/file-pdf-save.c index 95126ab33e0..770463127e0 100644 --- a/plug-ins/common/file-pdf-save.c +++ b/plug-ins/common/file-pdf-save.c @@ -1584,6 +1584,10 @@ drawText (GimpLayer *layer, gimp_drawable_get_offsets (GIMP_DRAWABLE (layer), &x, &y); cairo_translate (cr, x, y); + /* Offset */ + gimp_text_layer_get_offsets (GIMP_TEXT_LAYER (layer), &x, &y); + cairo_translate (cr, x, y); + /* Color */ /* When dealing with a gray/indexed image, the viewed color of the text layer * can be different than the one kept in the memory */ -- GitLab From 40cf1c47c4a0df62d4c02c970fe2eb541d545697 Mon Sep 17 00:00:00 2001 From: Idriss Fekir Date: Sun, 25 Feb 2024 20:42:14 +0100 Subject: [PATCH 4/4] pdf-save: convert line-spacing and indent into their actual units --- plug-ins/common/file-pdf-save.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plug-ins/common/file-pdf-save.c b/plug-ins/common/file-pdf-save.c index 770463127e0..bed3b703ed0 100644 --- a/plug-ins/common/file-pdf-save.c +++ b/plug-ins/common/file-pdf-save.c @@ -1751,11 +1751,11 @@ drawText (GimpLayer *layer, /* Indentation */ indent = gimp_text_layer_get_indent (GIMP_TEXT_LAYER (layer)); - pango_layout_set_indent (layout, (int)(PANGO_SCALE * indent)); + pango_layout_set_indent (layout, pango_units_from_double (gimp_units_to_pixels (indent, unit, y_res))); /* Line Spacing */ line_spacing = gimp_text_layer_get_line_spacing (GIMP_TEXT_LAYER (layer)); - pango_layout_set_spacing (layout, (int)(PANGO_SCALE * line_spacing)); + pango_layout_set_spacing (layout, pango_units_from_double (gimp_units_to_pixels (line_spacing, unit, y_res))); /* Letter Spacing */ letter_spacing = gimp_text_layer_get_letter_spacing (GIMP_TEXT_LAYER (layer)); -- GitLab