07-21-2023, 04:02 AM
(This post was last modified: 07-21-2023, 04:10 AM by jacques_duflos.)
ok, so there are two functions you can use for a text layer : gimp_text_layer_get_text and gimp_text_layer_get_markup. Either one xor the other returns a string, the other returns None. There is surely a good reason for that beyond my understanding. Now I get the text this way :
And it works ! thanks for the help.
about the encoding in uft-8 I don't understand what you mean. The texts you looked up are the ones returned by the translator tool. They display normally in gimp. Is "r\xc3\xa9ponse" instead of "réponse" uft-8 ? would it be better if it were uft-16 ?
Code:
import re
# Récupérer le contenu texte du calque dupliqué
text = pdb.gimp_text_layer_get_text(layer)
if text is None :
print ("----------text had markup-------------")
text = pdb.gimp_text_layer_get_markup(layer)
# quitter les markups avec une RegEx
text= re.sub(r"<.*?>", "", text)
And it works ! thanks for the help.
about the encoding in uft-8 I don't understand what you mean. The texts you looked up are the ones returned by the translator tool. They display normally in gimp. Is "r\xc3\xa9ponse" instead of "réponse" uft-8 ? would it be better if it were uft-16 ?