GNOME Bugzilla – Bug 724101
[PATCH] Add gimp-text-layer-set-markup pdb function
Last modified: 2018-05-24 14:17:41 UTC
Currently the GIMP provides a pdb function to get the markup of a text layer, but has no corresponding function to set the markup from a script - only the plain text can be set, losing all formatting. The attached patch provides such a function, including adding the root <markup> node if required, and running the markup text through pango_parse_markup() to check for errors before actually setting it on the text layer.
Created attachment 268768 [details] [review] Patch to add gimp-text-layer-set-markup pdb function
Thanks, that patch looks 100% correct and can be used as a first step, however the reason this API didn't exist so far is that the text tool only understands a specific subset of markup, the one it created itself. We either need to mark this layer as uneditable by the text tool, or add whatever validating that makes sure only that subset gets set.
Sorry for the delay in replying - I've been too busy recently to look at this and the patch I submitted has been sufficient for my immediate needs. I've been thinking - I don't want to restrict what markup can be set by a script, but it might make sense for the text tool to warn when trying to edit a text layer with unsupported markup - similar to how it currently warns when editing a text layer that has been modified by other tools. It could ask to discard all unsupported markup, or attempt to edit anyway. I guess the gimp_text_layer_set_markup API should also document this limitation and recommend sticking to the subset of markup supported by the text tool. It seems that the text tool actually already behaves somewhat reasonably when editing a text layer with unsupported markup - unsupported tags (big, small, sub, sup, tt and spans that start with an unsupported attribute) seem to be dropped as soon as the layer is edited, but not before - just selecting a layer with the text tool does not discard them. It might be a good idea to have it recognise simple aliases (foreground == fgcolor == color) and in the long run perhaps even preserve unsupported tags. It will probably be a while before I get round to coding any of this up, but what do you think? Do any of these ideas seem reasonable?
You sound totally reasonable. Given that we need a PDB API for text layers at some point, we should get started with something :)
Mitch, didn't your comment 4 mean that you validated the patch to be pushed in its current version (and later we could improve it, likely with warning when using unsupported markup as comment 3 suggests)? If that's what it meant, let's check it still applies fine and let's push, no?! :-)
This still applies, with one minor change (in an auto-generated file, anyway).
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gimp/issues/534.